class ConditionalRules (View source)

Properties

protected callable|bool $condition

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

protected array|string|Closure $rules

The rules to be added to the attribute.

protected array|string|Closure $defaultRules

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

Methods

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

Create a new conditional rules instance.

Parameters

callable|bool $condition
array|string|Closure $rules
array|string|Closure $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