Skip to content

What is the best way to validate a field using ormar + pydantic #411

Answered by collerek
igormorgado asked this question in Q&A
Discussion options

You must be logged in to vote

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_length argument 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.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by igormorgado
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants