mirror of
https://github.com/Respect/Validation.git
synced 2026-03-17 07:45:45 +01:00
I want to avoid having the Factory inside the rules. If a rule needs to create another, it can simply instantiate that. The "KeyValue" rule does too many things under the hood, and the behavior can be unpredictable. The "LazyConsecutive" rule makes the validation more explicit and way more flexible, as there could be other cases in which someone only wants to validate something if the previous validator passes. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
950 B
950 B
KeyNested
KeyNested(string $name)KeyNested(string $name, Validatable $rule)KeyNested(string $name, Validatable $rule, bool $mandatory)
Validates an array key or an object property using . to represent nested data.
Validating keys from arrays or ArrayAccess instances:
$array = [
'foo' => [
'bar' => 123,
],
];
v::keyNested('foo.bar')->validate($array); // true
Validating object properties:
$object = new stdClass();
$object->foo = new stdClass();
$object->foo->bar = 42;
v::keyNested('foo.bar')->validate($object); // true
This rule was inspired by Yii2 ArrayHelper.
Categorization
- Arrays
- Nesting
- Structures
Changelog
| Version | Description |
|---|---|
| 1.0.0 | Created |
See also: