Skip to content

Latest commit

 

History

History
52 lines (36 loc) · 976 Bytes

KeyNested.md

File metadata and controls

52 lines (36 loc) · 976 Bytes

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')->isValid($array); // true

Validating object properties:

$object = new stdClass();
$object->foo = new stdClass();
$object->foo->bar = 42;

v::keyNested('foo.bar')->isValid($object); // true

This rule was inspired by Yii2 ArrayHelper.

Categorization

  • Arrays
  • Nesting
  • Structures

Changelog

Version Description
1.0.0 Created

See also: