Replies: 3 comments
-
At the moment, the following implementation using field_validator with 'before' might be a workaround:
|
Beta Was this translation helpful? Give feedback.
-
This seems still to be the case with FastAPI 0.103.1. The workaround resolves it, but is a bit ugly. Should we create an issue for this? I think it's a bug. |
Beta Was this translation helpful? Give feedback.
-
It is still present in FastAPI 0.111.1. @tiangolo Can we please make this into an issue? It's problematic that you can't use enums with strict validation, and the workaround here needs to be added to every class that includes an enum (creating a general solution in a base class that covers all cases is... problematic, at best). |
Beta Was this translation helpful? Give feedback.
-
First Check
Commit to Help
Example Code
Description
Pydantic v2 has model_validate_json, that parses JSON and validate it with JSON mode.
FastAPI 0.100.0 doesn't use it to parse JSON for now. So it is difficult to use strict mode for models.
Operating System
Linux, macOS
Operating System Details
No response
FastAPI Version
0.100.0
Python Version
3.11.3
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions