Repository navigation
What is the best way to validate a field using ormar + pydantic #411
Answered
by
collerek
igormorgado
asked this question in
Q&A
|
I would like to validate some fields, for example, username fields larger than 3 characters. What is the best way to handle this. If possible please show me an example. Here is a small snippet to start with: Of course I could check the |
Answered by
collerek
Nov 5, 2021
Replies: 1 comment
|
For each field in ormar you can use all of the pydantic Field arguments (https://pydantic-docs.helpmanual.io/usage/schema/#field-customisation). So in you case simply add If your definition of pydantic Field is very fancy, you can force replace the field: https://collerek.github.io/ormar/fields/common-parameters/#overwrite_pydantic_type. |
0 replies
Answer selected by
igormorgado
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For each field in ormar you can use all of the pydantic Field arguments (https://pydantic-docs.helpmanual.io/usage/schema/#field-customisation).
So in you case simply add
min_lengthargument to ormar string field.If your definition of pydantic Field is very fancy, you can force replace the field: https://collerek.github.io/ormar/fields/common-parameters/#overwrite_pydantic_type.