Sometimes you may wish to stop running validation rules on an attribute after the first validation failure. To do so, you can use the bail()
method.
$validator->field('fieldName')->bail()->min(1)->max(5);
This will prevent that the max
rule is executed if the min
rule fails validation.
Unlike all other rules, the order of the bail
method does not matter. The example below will have the same result as the example above:
$validator->field('fieldName')->min(1)->max(5)->bail();
Go to the previous section.
Go to the next section.