0

I have some problem with create scheme for list without name which same as my example. Have JSON response:

`

[
  {  
    "id": 1
  },
  {same object}
]

`

My scheme:

`

scheme = {"type":"list","valuesrules": 
          {"type": "dict", "schema":
            {"id": {'type': 'integer'}
          }
         }

`

I dont understand what is mistake in my scheme?

`

def _validate(self, schema):
        if isinstance(schema, _str_type):
            schema = self.validator.schema_registry.get(schema, schema)
    
        test_schema = {}
        for field, rules in schema.items():
            if isinstance(rules, _str_type):
                test_schema[field] = rules_set_registry.get(rules, rules)
            else:
                test_rules = {}
                for rule, constraint in rules.items():
                    test_rules[rule.replace(" ", "_")] = constraint
                test_schema[field] = test_rules
    
        if not self.schema_validator(test_schema, normalize=False):
>           raise SchemaError(self.schema_validator.errors)
E           cerberus.schema.SchemaError: {'type': ['must be of dict type']}

`

Shawn
  • 47,241
  • 3
  • 26
  • 60

0 Answers0