jpmckinney / validictory

🎓 deprecated general purpose python data validator
Other
240 stars 57 forks source link

additionalProperties with patternProperties does not work #58

Closed jvc26 closed 11 years ago

jvc26 commented 11 years ago

Slightly confusing behaviour:

Passes as expected

schema = {
    "patternProperties": {
        "[a-c]": {
            "properties": {
                "cellid": {
                    "type": "integer"}
            }, "additionalProperties": False,
        }
    }
}
string = """{"c": { "cellid": 1}}"""
data = json.loads(string)
validictory.validate(data, schema)

Should pass, but doesn't

schema = {
    "patternProperties": {
        "[a-c]": {
            "properties": {
                "cellid": {
                    "type": "integer"}
            }, "additionalProperties": False,
        }
    }, "additionalProperties": False,
}
string = """{"c": { "cellid": 1}}"""
data = json.loads(string)
validictory.validate(data, schema)

Should fail, but doesn't

schema = {
    "patternProperties": {
        "[a-c]": {
            "properties": {
                "cellid": {
                    "type": "integer"}
            }, "additionalProperties": False,
        }
    }, "additionalProperties": False,
}
string = """{"d": { "cellid": 1}}"""
data = json.loads(string)
validictory.validate(data, schema)

Does additionalProperties therefore not match patternProperties?

I've tested sunlightlabs/validictory#42, and it looks like @juanmb has fixed the issues with his Pull request.