Skip to content

Latest commit

 

History

History
executable file
·
24 lines (13 loc) · 811 Bytes

4.3 - Stopping on first validation rule failure.md

File metadata and controls

executable file
·
24 lines (13 loc) · 811 Bytes

4.3 - Stopping on first validation failure (bail)

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.