final class Rules implements IteratorAggregate

List of validation & condition rules.

Constants

private NEG_RULES

Methods

__construct(Control $control)

No description

setRequired(string|Stringable|bool $value = true)

Makes control mandatory.

bool
isRequired()

Is control mandatory?

addRule(callable|string $validator, string|Stringable|null $errorMessage = null, mixed $arg = null)

Adds a validation rule for the current control.

removeRule(callable|string $validator)

Removes a validation rule for the current control.

addCondition($validator, $arg = null)

Adds a validation condition and returns new branch.

addConditionOn(Control $control, $validator, $arg = null)

Adds a validation condition on specified control a returns new branch.

elseCondition()

Adds a else statement.

endCondition()

Ends current validation condition.

addFilter(callable $filter)

Adds a filter callback.

toggle(string $id, bool $hide = true)

Toggles HTML element visibility.

array
getToggles(bool $actual = false)

No description

array
getToggleStates(array $toggles = [], bool $success = true, bool|null $emptyOptional = null)

No description

bool
validate(bool|null $emptyOptional = null)

Validates against ruleset.

void
reset()

Clear all validation rules.

static bool
validateRule(Rule $rule)

Validates single rule.

getIterator()

Iterates over complete ruleset.

Details

at line 40
__construct(Control $control)

No description

Parameters

Control $control

at line 49
Rules setRequired(string|Stringable|bool $value = true)

Makes control mandatory.

Parameters

string|Stringable|bool $value

Return Value

Rules

at line 64
bool isRequired()

Is control mandatory?

Return Value

bool

at line 73
Rules addRule(callable|string $validator, string|Stringable|null $errorMessage = null, mixed $arg = null)

Adds a validation rule for the current control.

Parameters

callable|string $validator
string|Stringable|null $errorMessage
mixed $arg

Return Value

Rules

at line 101
Rules removeRule(callable|string $validator)

Removes a validation rule for the current control.

Parameters

callable|string $validator

Return Value

Rules

at line 120
Rules addCondition($validator, $arg = null)

Adds a validation condition and returns new branch.

Parameters

$validator
$arg

Return Value

Rules

at line 136
Rules addConditionOn(Control $control, $validator, $arg = null)

Adds a validation condition on specified control a returns new branch.

Parameters

Control $control
$validator
$arg

Return Value

Rules

at line 154
Rules elseCondition()

Adds a else statement.

Return Value

Rules

at line 173
Rules endCondition()

Ends current validation condition.

Return Value

Rules

at line 182
Rules addFilter(callable $filter)

Adds a filter callback.

Parameters

callable $filter

Return Value

Rules

at line 197
Rules toggle(string $id, bool $hide = true)

Toggles HTML element visibility.

Parameters

string $id
bool $hide

Return Value

Rules

at line 204
array getToggles(bool $actual = false)

No description

Parameters

bool $actual

Return Value

array

at line 211
array getToggleStates(array $toggles = [], bool $success = true, bool|null $emptyOptional = null)

internal  
 

No description

Parameters

array $toggles
bool $success
bool|null $emptyOptional

Return Value

array

at line 237
bool validate(bool|null $emptyOptional = null)

Validates against ruleset.

Parameters

bool|null $emptyOptional

Return Value

bool

at line 266
void reset()

Clear all validation rules.

Return Value

void

at line 275
static bool validateRule(Rule $rule)

Validates single rule.

Parameters

Rule $rule

Return Value

bool

at line 291
Iterator getIterator()

Iterates over complete ruleset.

Return Value

Iterator

Traits

Strict class for better experience.