1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/movim_ynh.git synced 2024-09-03 19:46:19 +02:00
movim_ynh/sources/vendor/respect/validation/docs/Key.md
2016-03-14 23:16:11 +01:00

602 B

Key

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

Validates an array key.

$dict = [
    'foo' => 'bar'
];

v::key('foo')->validate($dict); // true

You can also validate the key value itself:

v::key('foo', v::equals('bar'))->validate($dict); // true

Third parameter makes the key presence optional:

v::key('lorem', v::stringType(), false)->validate($dict); // true

The name of this validator is automatically set to the key name.


See also: