respect-validation/docs/rules/Instance.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

583 B

Instance

  • Instance(string $instanceName)

Validates if the input is an instance of the given class or interface.

v::instance('DateTime')->validate(new DateTime); // true
v::instance('Traversable')->validate(new ArrayObject); // true

Message template for this validator includes {{instanceName}}.

Categorization

  • Objects

Changelog

Version Description
0.3.9 Created

See also: