class Rules implements IteratorAggregate

List of validation & condition rules.

Traits

Strict class for better experience.

Methods

__construct(IControl $control)

No description

setRequired(string|bool $value = true)

Makes control mandatory.

bool
isRequired()

Is control mandatory?

addRule($validator, $errorMessage = null, $arg = null)

Adds a validation rule for the current control.

addCondition($validator, $arg = null)

Adds a validation condition and returns new branch.

addConditionOn(IControl $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)

No description

bool
validate(bool $emptyOptional = false)

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 38
__construct(IControl $control)

Parameters

IControl $control

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

Makes control mandatory.

Parameters

string|bool $value

Return Value

Rules

at line 63
bool isRequired()

Is control mandatory?

Return Value

bool

at line 75
Rules addRule($validator, $errorMessage = null, $arg = null)

Adds a validation rule for the current control.

Parameters

$validator
$errorMessage
$arg

Return Value

Rules

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

Adds a validation condition and returns new branch.

Parameters

$validator
$arg

Return Value

Rules new branch

at line 115
Rules addConditionOn(IControl $control, $validator, $arg = null)

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

Parameters

IControl $control
$validator
$arg

Return Value

Rules new branch

at line 134
Rules elseCondition()

Adds a else statement.

Return Value

Rules else branch

at line 149
Rules endCondition()

Ends current validation condition.

Return Value

Rules parent branch

at line 159
Rules addFilter(callable $filter)

Adds a filter callback.

Parameters

callable $filter

Return Value

Rules

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

Toggles HTML element visibility.

Parameters

string $id
bool $hide

Return Value

Rules

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

Parameters

bool $actual

Return Value

array

at line 191
array getToggleStates(array $toggles = [], bool $success = true)

Parameters

array $toggles
bool $success

Return Value

array

at line 209
bool validate(bool $emptyOptional = false)

Validates against ruleset.

Parameters

bool $emptyOptional

Return Value

bool

at line 233
void reset()

Clear all validation rules.

Return Value

void

at line 242
static bool validateRule(Rule $rule)

Validates single rule.

Parameters

Rule $rule

Return Value

bool

at line 256
Iterator getIterator()

Iterates over complete ruleset.

Return Value

Iterator