mirror of
https://github.com/Respect/Validation.git
synced 2024-06-13 19:22:16 +02:00
The difference with this rule is that it matches the behavior of `is_iterable()`, which is different from `IterableVal` that also allows instances of `stdClass.` This is a necessary change because PHP will trigger an error when trying to pass any object to anything typed as `iterable` Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
1.1 KiB
1.1 KiB
IterableVal
IterableVal()
Validates whether the input is an iterable value, in other words, if you can iterate over it with the foreach language construct.
v::iterableVal()->validate([]); // true
v::iterableVal()->validate(new ArrayObject()); // true
v::iterableVal()->validate(new stdClass()); // true
v::iterableVal()->validate('string'); // false
Note
This rule doesn't behave as PHP's [is_iterable() function because it considers that you can iterate over any object.
Categorization
- Types
Changelog
Version | Description |
---|---|
3.0.0 | Renamed from IterableType to IterableVal |
1.0.8 | Renamed from Iterable to IterableType |
1.0.0 | Created as Iterable |
See also: