gilbsgilbs · GitHub

Used Cerberus version / latest commit: 631e05d

  • I have the capacity to improve the docs when my problem is solved.

  • I have the capacity to submit a patch when a bug is identified.

  • My question does not concern a practical use-case that I can't figure out
    to solve.


Bug report / Feature request

Validating the following input:

{
  "letters": [{"foo": "bar"}]
}

against the following schema:

{
  "letters": {
    "type": "list",
    "allowed": ["a", "b", "c"]
  }
}

leads to the following crash:

   File "./cerberus/validator.py", line 997, in validate
     self.__validate_definitions(definitions, field)
   File "./cerberus/validator.py", line 1066, in __validate_definitions
     result = validate_rule(rule)
   File "./cerberus/validator.py", line 1041, in validate_rule
     return validator(definitions.get(rule, None), field, value)
   File "./cerberus/validator.py", line 1087, in _validate_allowed
     unallowed = set(value) - set(allowed_values)
 TypeError: unhashable type: 'dict'

expected behavior: a validation error, not a crash.

Read the original on github.com ↗