From 33c5c616d728d141e7acb021cecab7e40750be81 Mon Sep 17 00:00:00 2001 From: loucho Date: Fri, 6 Mar 2015 14:10:54 -0600 Subject: [PATCH] Make the enum element comparison strict The current check is matching numeric strings that are not equal ( like "604.1" == "604.10" because of PHP's == behavior that converts numeric strings to numbers and then performs a numeric comparison), even if type is checked before the comparison, the value should be identic --- src/JsonSchema/Constraints/Enum.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/JsonSchema/Constraints/Enum.php b/src/JsonSchema/Constraints/Enum.php index c80a2d5..b637d7a 100644 --- a/src/JsonSchema/Constraints/Enum.php +++ b/src/JsonSchema/Constraints/Enum.php @@ -28,11 +28,11 @@ class Enum extends Constraint } foreach ($schema->enum as $enum) { - if ((gettype($element) === gettype($enum)) && ($element == $enum)) { + if ((gettype($element) === gettype($enum)) && ($element === $enum)) { return; } } $this->addError($path, "does not have a value in the enumeration " . print_r($schema->enum, true)); } -} \ No newline at end of file +}