Joseph Groot Kormelink
Joseph Groot Kormelink

Reputation: 289

Json Schema Nested Properties Ignored

I'm trying to work with json Schema, but it seems like I'm missing something. Everything I set within "test" is completely ignored. I can set the type to anything and it's still accepted. How do I validate these nested properties?

forward_schema = {
    "$schema": "http://json-schema.org/draft-06/schema#",
    "title": "ForwarderObject",
    "description": "All Forwarding Settings",
    "type": "object",
    "properties": {
        "active": {
            "type": "boolean",
        },
        "groups": {
            "type": "object",
            "title": "groups",
            "properties ": {
                "test": {
                    "type": "something",
                },

            },
            "required": ["test"]
        },

    },

    "required": ['active', "groups"],
}

test_object = {
    'groups':
        {
            'test':
                {
                    'from': ['1240321726a'],
                    'to': ['225388559'],
                    'filters':
                        {
                            'Asserter':
                                {
                                    'regex': ['"1232/"', '2aa']
                                }
                        },
                    'group-name': 'test',
                    'label': '',
                    'edited': ''
                },
        },
    'active': true
}

Upvotes: 1

Views: 849

Answers (1)

Relequestual
Relequestual

Reputation: 12295

This is going to hurt... typo... "properties ":

You've got a space inside your double quotes. Took me a good 5 mins to work out! You can test if a subschema is reached by making it false.

"properties ": { "test": false, }

Upvotes: 1

Related Questions