-1

I have a python dictionary I am trying to validate using cerberus. However, one of the fields in my dict is called "type" which conflicts with the keyword "type" reserved by the cerberus parser.

Is there any way to get around this without having to change the original dictionary?

Part in question

    {
        {
            ...
            "db": {
                "type": "AzureTables",
                ...
            }
        }
    }
asdf
  • 2,927
  • 2
  • 21
  • 42

1 Answers1

1

So without seeing the schema that you are using I am making an educated guess here.

schema = {
'db': {'type': 'dict',
       'schema': {
            'type': {'type': 'string'},
            'some_field': {'type': 'integer'}

       }
      }
}

document = {
      'db': {'type': 'AzureTables',
             'some_field': 5}
}

The above schema validates the document that follows with no errors. My guess is that you are missing the schema rule. Cerberus will let you use dictionary keys that are reserved if you put the keys in a schema rule as you can see above.

Flargebla
  • 76
  • 3