Skip to content
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

Validation for Empty Objects on Object Level #42

Open
julian-r opened this issue Jul 10, 2020 · 1 comment
Open

Validation for Empty Objects on Object Level #42

julian-r opened this issue Jul 10, 2020 · 1 comment
Labels
bug Something isn't working generator-pydantic Code generator for python pydantic

Comments

@julian-r
Copy link
Member

ATM the validation of empty object is only working in dict form.

Example:

 RootModel(
        field_a="a", list_items=[ListItem(), ListItem(), ListItem()]
    ).dict() == {"field_a": "a"}

does not raise an validation error. But it actually should.

RootModel(**{"field_a": "a", "list_items": [{}, {}, {}]})

Does.

The problem is in resource header strip_empty_items since it only takes care about the dict representation of the model, which is not executed in case of the construction via Objects. A similar functionality needs to be implemented on a Pydantic object level without the pre parameter in the validator. This should then cover the json variant as well.

@julian-r julian-r added bug Something isn't working generator-pydantic Code generator for python pydantic labels Jul 10, 2020
@julian-r
Copy link
Member Author

the tests should be renamed as well. Thanks @trojanowski

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working generator-pydantic Code generator for python pydantic
Development

No branches or pull requests

1 participant