Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Trigger bool validator for assignments #28

Open
pederhan opened this issue Feb 13, 2023 · 0 comments
Open

Trigger bool validator for assignments #28

pederhan opened this issue Feb 13, 2023 · 0 comments

Comments

@pederhan
Copy link
Member

Currently, the bool_converter validator is configured as a @root_validator, meaning it does not trigger on field assignments, only on model instantiation.

https://github.com/pederhan/harborapi/blob/27900ab5e98c6dc2b7dbb04212414f4edc8d988e/harborapi/models/base.py#L69-L78

Even if we add validate_assignments = True to the model config, it will not run the root validator again. We either need to manually override all fields that are quasi-bools (Optional[str] field that accepts "true" and "false".), or we need to find out if we can add a custom validator for a specific type (in this case Optional[str]), but I am not sure how to do that, or if it's even possible.

@pederhan pederhan added this to Harbor Feb 15, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant