Skip to content

Commit 7dd06aa

Browse files
committed
Add readme to enable strict checking for rules 'in' and 'not_in'
1 parent 6ac5ca1 commit 7dd06aa

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,29 @@ The field under this rule may have alpha-numeric characters, as well as dashes a
417417

418418
The field under this rule must be included in the given list of values.
419419

420+
This rule is using `in_array` to check the value.
421+
By default `in_array` disable strict checking.
422+
So it doesn't check data type.
423+
If you want enable strict checking, you can invoke validator like this:
424+
425+
```php
426+
$validation = $validator->validate($data, [
427+
'enabled' => [
428+
'required',
429+
$validator('in', [true, 1])->strict()
430+
]
431+
]);
432+
```
433+
434+
Then 'enabled' value should be boolean `true`, or int `1`.
435+
420436
<a id="rule-not_in"></a>
421437
#### not_in:value_1,value_2,...
422438

423439
The field under this rule must not be included in the given list of values.
424440

441+
This rule also using `in_array`. You can enable strict checking by invoking validator and call `strict()` like example in rule `in` above.
442+
425443
<a id="rule-min"></a>
426444
#### min:number
427445

0 commit comments

Comments
 (0)