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

Enable strict modus for domainType #5

Open
PaulVanSchayck opened this issue Sep 25, 2023 · 0 comments
Open

Enable strict modus for domainType #5

PaulVanSchayck opened this issue Sep 25, 2023 · 0 comments

Comments

@PaulVanSchayck
Copy link
Collaborator

There is a bug/problem with FastAPI, where it doesn't use model_validate_json() when passing model data as POST data. This causes domainType not to be validated in strict mode, when it is passed as str in a JSON.

For now we applied the following workaround:

    @field_validator('domainType', mode='before')
    @classmethod
    def value_to_enum(cls, v):
        if isinstance(v, str):
            return DomainType(v)
        return v

See also: fastapi/fastapi#9868

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