class ConditionalRules

Properties

protected bool|Closure $condition

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

Methods

__construct(bool|callable $condition, array|Closure|Rule|string|ValidationRule $rules, array|Closure|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 26
__construct(bool|callable $condition, array|Closure|Rule|string|ValidationRule $rules, array|Closure|Rule|string|ValidationRule $defaultRules = [])

Create a new conditional rules instance.

Parameters

bool|callable $condition

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

array|Closure|Rule|string|ValidationRule $rules

the rules to be added to the attribute

array|Closure|Rule|string|ValidationRule $defaultRules

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

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

Determine if the conditional rules should be added.

Parameters

array $data

Return Value

bool

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

Get the rules.

Parameters

array $data

Return Value

mixed

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

Get the default rules.

Parameters

array $data

Return Value

mixed