Pydantic Field's strict mode #1115
Unanswered
jonyscathe
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
I am currently refactoring some code.
Am trying to move from have separate use of pydantic, sqlalchemy & api to just using SQLModel.
My current pydantic classes use
strict=True
within the Fields to enforce strict mode rather than lax mode.I had assumed that this behaviour would be available through the SQLModel definition by just adding
strict=True
into the Field.And now that I look closer I see that there are several pydantic Field parameters that are not in the SQLModel Field such as strict, validate_default, init, init_var, kw_only.
Though the only one that I actually care about is strict.
I understand that if I add
model_config = ConfigDict(strict=True)
to the model then the entire model can become strict, however I want to make some integers and floats strict without making some date/datetime fields strict.Wondering if this is possible at all?
Operating System
Linux
Operating System Details
python-slim docker container.
SQLModel Version
0.0.22
Python Version
3.12.6
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions