-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type
field cause exception
#545
Comments
please provide a unit test that is as sparse as possible to replicate the problem? it would also be helpful if you provided the full traceback of the exception. |
Example use-case:
Output
|
that's an interesting edge case: @mark.parametrize(
("outer_type", "inner_type"), product(("dict", "list"), ("dict", "list"))
)
def test_normalization_of_dict_with_a_field_named_type(
outer_type, inner_type
):
# https://github.com/pyeve/cerberus/issues/545
validator = Validator(
{"document": {"type": outer_type, "schema": {"type": inner_type,},},}
)
# this test seems to only fail when the token "type" is used as key:
validator({"document": {"type": None}}) regardless, you're aware that the |
@funkyfuture Yes, I know that but someone will input object with wrong type. And I need Cerberus to return an error instead of an exception. |
i haven't gone my step debugging routes through this, but it's quiet certain that it stems from the ambiguity of the if you don't want to try to fix it yourself, consider to first rename the field |
Used Cerberus version / latest commit: 1.3.2
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.
[ x] My question does not concern a practical use-case that I can't figure out
to solve.
Bug report / Feature request
I have a sample schema:
Expected: return
image_thumb
must be a listit will return an exception when an object was
{'metadata': {'image_thumb': {'type': 'error'}}}
with
type
in the body.The text was updated successfully, but these errors were encountered: