respect-validation/docs/Each.md
William Espindola dc3951edf1
Apply contribution guidelines to "Each" rule
Also removed the possibility of validating keys once it's possible to
reach the same behavior by combining this rule with "Call" rule.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-06-23 21:40:39 +02:00

1.1 KiB

Each

  • Each(Validatable $rule)

Validates whether each value in the input is valid according to another rule.

$releaseDates = [
    'validation' => '2010-01-01',
    'template'   => '2011-01-01',
    'relational' => '2011-02-05',
];

v::each(v::dateTime())->validate($releaseDates); // true

You can also validate array keys combining this rule with Call:

v::call('array_keys', v::each(v::stringType()))->validate($releaseDates); // true

This rule will not validate values that are not iterable, to have a more detailed error message, add IterableType to your chain, for example.

If the input is empty this rule will consider the value as valid, you use NotEmpty if convenient:

v::each(v::dateTime())->validate([]); // true
v::notEmpty()->each(v::dateTime())->validate([]); // false

Changelog

Version Description
2.0.0 Remove support for key validation
0.3.9 Created

See also: