Skip to content

Commit 7f3dcec

Browse files
committed
Merge branch 'patch-1' of https://github.com/joel-james/docs into joel-james-patch-1
2 parents 265bea3 + c6ba26c commit 7f3dcec

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

releases.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ Likewise, you may use the `*` character when specifying your validation messages
115115
]
116116
],
117117

118+
### Bail Validation Rule
119+
120+
A new validation rule called `bail` added in Laravel 5.2 validator class, allowing you to avoid unexpected errors while using using multiple validation rules. With the new `bail` rule you can stop running validation rules on an attribute after the first validation failure.
121+
122+
For example if you are using `unique` validation which may throw a DB error if the given value is not an integer, you will assign `integer` rule too. But still Laravel will validate both rules and that will will throw DB error with `unique` validation. In this case you can assign `bail` rule to the attribute. So that `unique` rule will not be validated if the `integer` rule is a failure.
123+
124+
$this->validate($request, [
125+
'user_id' => 'bail|integer|unique:users'
126+
]);
127+
128+
118129
### Eloquent Global Scope Improvements
119130

120131
In previous versions of Laravel, global Eloquent scopes were complicated and error-prone to implement; however, in Laravel 5.2, global query scopes only require you to implement a single, simple method: `apply`.

0 commit comments

Comments
 (0)