respect-validation/docs/rules/Countable.md
Henrique Moody 210aa4ac01
Recreate "IterableType" rule
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>
2024-03-02 13:20:13 +01:00

588 B

Countable

  • Countable()

Validates if the input is countable, in other words, if you're allowed to use count() function on it.

v::countable()->validate([]); // true
v::countable()->validate(new ArrayObject()); // true
v::countable()->validate('string'); // false

Categorization

  • Types

Changelog

Version Description
1.0.0 Created from ArrayVal

See also: