1# KeyNested
2
3- `v::keyNested(string $name)`
4- `v::keyNested(string $name, v $validator)`
5- `v::keyNested(string $name, v $validator, boolean $mandatory = true)`
6
7Validates an array key or an object property using `.` to represent nested data.
8
9Validating keys from arrays or `ArrayAccess` instances:
10
11```php
12$array = [
13    'foo' => [
14        'bar' => 123,
15    ],
16];
17
18v::keyNested('foo.bar')->validate($array); // true
19```
20
21Validating object properties:
22
23```php
24$object = new stdClass();
25$object->foo = new stdClass();
26$object->foo->bar = 42;
27
28v::keyNested('foo.bar')->validate($object); // true
29```
30
31This rule was inspired by [Yii2 ArrayHelper][].
32
33***
34See also:
35
36  * [Attribute](Attribute.md)
37  * [Key](Key.md)
38
39
40[Yii2 ArrayHelper]: https://github.com/yiisoft/yii2/blob/68c30c1/framework/helpers/BaseArrayHelper.php "Yii2 ArrayHelper"
41