Validation icon indicating copy to clipboard operation
Validation copied to clipboard

Bogus error message with KeySet when extra keys are provided

Open dktapps opened this issue 4 years ago • 0 comments

require 'vendor/autoload.php';

$v = \Respect\Validation\Validator::keySet(
	\Respect\Validation\Validator::key("key1", \Respect\Validation\Validator::intVal())
);
try{
	$v->assert(["key1" => 1, "extraKey" => 2]);
}catch(\Respect\Validation\Exceptions\NestedValidationException $e){
	echo $e->getFullMessage();
}

reports the following very confusing error:

- All of the required rules must pass for `{ "key1": 1, "extraKey": 2 }`
  - Must have keys `{ "key1" }`

Using version 2.2.2.

dktapps avatar Mar 17 '21 16:03 dktapps