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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant