Skip to content

Commit d640df5

Browse files
[12.x] Add documentation for doesnt_contain validation rule (#10664)
* add doesntContain validation docs * Update validation.md --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 0e1c98f commit d640df5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

validation.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,7 @@ Below is a list of all available validation rules and their function:
10421042
[Array](#rule-array)
10431043
[Between](#rule-between)
10441044
[Contains](#rule-contains)
1045+
[Doesnt Contain](#rule-doesnt-contain)
10451046
[Distinct](#rule-distinct)
10461047
[In Array](#rule-in-array)
10471048
[In Array Keys](#rule-in-array-keys)
@@ -1377,6 +1378,24 @@ Validator::make($data, [
13771378
]);
13781379
```
13791380

1381+
<a name="rule-doesnt-contain"></a>
1382+
#### doesnt_contain:_foo_,_bar_,...
1383+
1384+
The field under validation must be an array that does not contain any of the given parameter values. Since this rule often requires you to `implode` an array, the `Rule::doesntContain` method may be used to fluently construct the rule:
1385+
1386+
```php
1387+
use Illuminate\Support\Facades\Validator;
1388+
use Illuminate\Validation\Rule;
1389+
1390+
Validator::make($data, [
1391+
'roles' => [
1392+
'required',
1393+
'array',
1394+
Rule::doesntContain(['admin', 'editor']),
1395+
],
1396+
]);
1397+
```
1398+
13801399
<a name="rule-current-password"></a>
13811400
#### current_password
13821401

0 commit comments

Comments
 (0)