class ConditionalRules

Methods

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

Create a new conditional rules instance.

bool
passes(array $data = [])

Determine if the conditional rules should be added.

mixed
rules(array $data = [])

Get the rules.

mixed
defaultRules(array $data = [])

Get the default rules.

Details

at line 22
__construct(bool|Closure $condition, array|Closure|InvokableRule|Rule|string|ValidationRule $rules, array|Closure|InvokableRule|Rule|string|ValidationRule $defaultRules = [])

Create a new conditional rules instance.

Parameters

bool|Closure $condition

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

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

the rules to be added to the attribute

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

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

at line 32
bool passes(array $data = [])

Determine if the conditional rules should be added.

Parameters

array $data

Return Value

bool

at line 44
mixed rules(array $data = [])

Get the rules.

Parameters

array $data

Return Value

mixed

at line 56
mixed defaultRules(array $data = [])

Get the default rules.

Parameters

array $data

Return Value

mixed