mirror of
https://github.com/Respect/Validation.git
synced 2024-06-13 19:22:16 +02:00
24885e4a5f
Because we have the Key and Property rules, the KeyNested is redundant, although it's a helpful shortcut. The real problem is dealing with messages and templates because the structure of the validator needs to match the structure of the rule. When using the `getMessages()` method from the exception we throw in `assert()`, we get a flat structure, which is often not the intended structure. The KeyNested rule is cool, but it adds some complexity to the codebase that I'm unwilling to deal with. It's not nice to remove a rule, especially because I know people use it, but it's for the best. I'm trying to keep the codebase small, so hopefully, it will get easier to maintain. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
1.1 KiB
1.1 KiB
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: