respect-validation/docs/rules/KeyNested.md
Henrique Moody 52614d600d
Organize documentation for "Read the Docs"
The current documentation is hosted via GitHub pages rendered by
"Couscous". Every time we need a new version of the documentation
published we need to manually execute the "couscous".

This commit reorganize the documentation to be published to
"Read the Docs" because it will also allow us to have documentations per
version of the library most importantly provider a search field for the
documentation.

The documentation will be then published on:
https://respect-validation.readthedocs.io/

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-23 01:59:39 +02:00

836 B

KeyNested

  • v::keyNested(string $name)
  • v::keyNested(string $name, v $validator)
  • v::keyNested(string $name, v $validator, boolean $mandatory = true)

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.


See also: