Closed gajus closed 10 years ago
New syntax has been implemented.
$test = $vlad->test([
[
['foo', 'bar', 'baz'],
[
['fail' => 'break'],
// Define Validator failure scenario:
// * 'silent' exclude input from the current validator chain.
// * 'soft' record an error and progress to the next Validator.
// * 'hard' (default) record an error and exclude the selector from the rest of the Test.
// * 'break' record an error and interrupt the Test.
'required',
'not_empty',
['fail' => 'hard'], // Reset default Validator failure scenario.
'email',
['length', 'max' => 10] // Length Validator with constructor options.
]
],
[
['qux', 'quux'],
[
// Validate email only if it is non-empty string.
['fail' => 'silent'],
'not_empty',
['fail' => 'hard'],
'email'
]
]
]);
I propose an alternative syntax:
This solves a known limitation of the current implementation:
Where
email
rule is expected to be executed only ifnot_empty
rule passes.