class ConditionalRules (View source)

Properties

protected callable|bool $condition

The boolean condition indicating if the rules should be added to the attribute.

protected ValidationRule|InvokableRule|Rule|Closure|array|string $rules

The rules to be added to the attribute.

protected ValidationRule|InvokableRule|Rule|Closure|array|string $defaultRules

The rules to be added to the attribute if the condition fails.

Methods

void
__construct(callable|bool $condition, ValidationRule|InvokableRule|Rule|Closure|array|string $rules, ValidationRule|InvokableRule|Rule|Closure|array|string $defaultRules = [])

Create a new conditional rules instance.

bool
passes(array $data = [])

Determine if the conditional rules should be added.

array
rules(array $data = [])

Get the rules.

array
defaultRules(array $data = [])

Get the default rules.

Details

void __construct(callable|bool $condition, ValidationRule|InvokableRule|Rule|Closure|array|string $rules, ValidationRule|InvokableRule|Rule|Closure|array|string $defaultRules = [])

Create a new conditional rules instance.

Parameters

callable|bool $condition
ValidationRule|InvokableRule|Rule|Closure|array|string $rules
ValidationRule|InvokableRule|Rule|Closure|array|string $defaultRules

Return Value

void

bool passes(array $data = [])

Determine if the conditional rules should be added.

Parameters

array $data

Return Value

bool

array rules(array $data = [])

Get the rules.

Parameters

array $data

Return Value

array

array defaultRules(array $data = [])

Get the default rules.

Parameters

array $data

Return Value

array

Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.