From d0865df783d9834740071a279241cdf46a4c40cf Mon Sep 17 00:00:00 2001 From: dantleech Date: Thu, 15 May 2014 19:56:54 +0200 Subject: [PATCH] Allow non-scalar values to be validated in Enum --- .../MetaYaml/NodeValidator/EnumNodeValidator.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/RomaricDrigon/MetaYaml/NodeValidator/EnumNodeValidator.php b/src/RomaricDrigon/MetaYaml/NodeValidator/EnumNodeValidator.php index 3ab7162..affb5a7 100644 --- a/src/RomaricDrigon/MetaYaml/NodeValidator/EnumNodeValidator.php +++ b/src/RomaricDrigon/MetaYaml/NodeValidator/EnumNodeValidator.php @@ -33,7 +33,11 @@ public function validate($name, $node, $data) } if (! in_array($data, $haystack, $strict)) { - throw new NodeValidatorException($name, "The value '$data' is not allowed for node '$name'"); + if (is_scalar($data)) { + throw new NodeValidatorException($name, "The value '$data' is not allowed for node '$name'"); + } + + throw new NodeValidatorException($name, "The value " . var_export($data, true) . " is not allowed for node '$name'"); } return true;