22
33Validates every element of an ` array ` with a given set of rules.
44
5+ ``` php
6+ /**
7+ * @var RuleInterface[] $constraints
8+ */
9+ All(
10+ array $constraints,
11+ string $message = 'At "{{ key }}": {{ message }}'
12+ );
13+ ```
14+
515## Basic Usage
616
717``` php
8- Validator::all([Validator::greatarThan(1), Validator::lessThan(10)])->validate([4, 5, 6]); // true
9- Validator::all([Validator::greaterThan(1)->lessThan(10)])->validate([4, 5, 6]); // true
18+ // One rule per array element
19+ Validator::all([Validator::notBlank(), Validator::greaterThan(1), Validator::lessThan(10)])->validate([4, 5, 6]); // true
20+ Validator::all([Validator::notBlank(), Validator::greaterThan(1), Validator::lessThan(10)])->validate([4, 5, 20]); // false
1021
11- Validator::all([Validator::greatarThan(1), Validator::lessThan(10)])->validate([4, 5, 20]); // false
22+ // Multiple rules per array element
23+ Validator::all([Validator::notBlank()->greaterThan(1)->lessThan(10)])->validate([4, 5, 6]); // true
1224```
1325
1426> ** Note**
@@ -31,7 +43,6 @@ Each element must implement a `RuleInterface`, so it is possible to use a single
3143type: ` string ` default: ` At "{{ key }}": {{ message }} `
3244
3345Message that will be shown if at least one element of an array is invalid according to the given ` constraints ` .
34- Check the [ Custom Messages] ( ) section for more information.
3546
3647``` php
3748Validator::all([Validator::notBlank()])->assert([1, 2, ''], 'Test');
0 commit comments