thephpleague / json-guard

Validation of json-schema.org compliant schemas.
http://json-guard.thephpleague.com/
MIT License
175 stars 26 forks source link

Unexpected success with "not" constraint and enum with objects #100

Closed marcioAlmada closed 7 years ago

marcioAlmada commented 7 years ago

I've tried to use the following schema using a "not" constraint against an enum value but it seems impossible to make it fail:

{
    "type": "object",
    "properties": {
        "feature_a": {
            "type": "boolean"
        },
        "feature_b": {
            "type": "boolean"
        },
        "feature_c": {
            "type": "boolean"
        }
    },
    "required": [
        "feature_a",
        "feature_b",
        "feature_c",
    ],
    "not": {
        "type": "object",
        "enum": [
            {
                "feature_a": true,
                "feature_b": true,
                "feature_c": true
            }
        ]
    },
    "additionalProperties": false
}

Data:

{
    "feature_a" : true,
    "feature_b" : true,
    "feature_c" : true
}

What happens: Validation passes. Expected: validation should fail with message "JSON is valid against schema from 'not'."

It was easy to assert the correct behavior with http://www.jsonschemavalidator.net