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
This commit is contained in:
loucho 2015-03-06 14:10:54 -06:00
parent 87b54b460f
commit 33c5c616d7

View File

@ -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));
}
}
}