You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What happened
Unexpected behavior when using the CHECK_MODE_EXCEPTIONS mode combined with a "not": { "enum": ["bar"] } schema, will result in a thrown exception
This will fail unexpectedly with the error message PHP Fatal error: Uncaught JsonSchema\Exception\ValidationException: Error validating /foo/foo: Does not have a value in the enumeration ["bar"] in /path/to/json-schema/src/JsonSchema/Constraints/BaseConstraint.php:57 which is not the expected behavior, since if you run the validator without the CHECK_MODE_EXCEPTIONS constraint, there will be no error.
What I expected to happen
I think the expected behavior should be when using CHECK_MODE_EXCEPTIONS mode, the not constraint should not fail instantly if the child constraint failed, since not has to negate the results first.
Possible solution
Looks like it's because of UndefinedConstraint is not aware of the CHECK_MODE_EXCEPTIONS during checking the not construct and when it attempts to match bar vs an enum of [baz] further down the chain it fails with an exception which propagates all the way out of the validator.
The text was updated successfully, but these errors were encountered:
asaliev
changed the title
Not-enum will fail when "CHECK_MODE_EXCEPTIONS"
NOT ENUM can unexpectedly fail when "CHECK_MODE_EXCEPTIONS" is set
Dec 5, 2018
@asaliev in an attempt to cleanup this repo we are trying to filter the issues and see which ones might be closed. Is it safe to assume this is a rather old issue, which sadly was left unanswered?
You reported the issue to be in version 5.2.7, currently we are working on getting the v6.0.0 version out. Did you try this on the current master branch if it is still reproducible?
I also noticed #553 is open for fixing this and targeting the v5.x.x branch. Due to time being an issue we are currently not planning any porting of fixes to v5.
Version: 5.2.7
What happened
Unexpected behavior when using the
CHECK_MODE_EXCEPTIONS
mode combined with a"not": { "enum": ["bar"] }
schema, will result in a thrown exceptionConsider the following example:
This will fail unexpectedly with the error message
PHP Fatal error: Uncaught JsonSchema\Exception\ValidationException: Error validating /foo/foo: Does not have a value in the enumeration ["bar"] in /path/to/json-schema/src/JsonSchema/Constraints/BaseConstraint.php:57
which is not the expected behavior, since if you run the validator without theCHECK_MODE_EXCEPTIONS
constraint, there will be no error.What I expected to happen
I think the expected behavior should be when using
CHECK_MODE_EXCEPTIONS
mode, thenot
constraint should not fail instantly if the child constraint failed, sincenot
has to negate the results first.Possible solution
Looks like it's because of
UndefinedConstraint
is not aware of theCHECK_MODE_EXCEPTIONS
during checking thenot
construct and when it attempts to matchbar
vs an enum of[baz]
further down the chain it fails with an exception which propagates all the way out of the validator.The text was updated successfully, but these errors were encountered: