PropertyExists
PropertyExists(string $propertyName)
Validates if an object property exists.
$object = new stdClass;
$object->name = 'The Respect Panda';
$object->email = 'therespectpanda@gmail.com';
v::propertyExists('name')->validate($object); // true
v::propertyExists('email')->validate($object); // true
v::propertyExists('website')->validate($object); // false
Notes
This rule will validate public, private, protected, uninitialised, and static properties.
- To validate a property against a given rule requiring the property to exist, use Property instead.
- To validate a property against a given rule only if the property exists, use PropertyOptional instead.
Categorization
- Objects
- Structures
Changelog
Version | Description |
---|---|
3.0.0 | Created from Property |
See also: