-
-
Save Viicos/d7b25251453a050c198c76dede34cf1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pydantic import BaseModel | |
class Model(BaseModel): | |
model_config = { | |
"validate_default": True, | |
} | |
class MyModel(Model): | |
model_config = { | |
"str_max_length": 2, | |
} | |
a: int = "not_an_int" | |
b: str | |
MyModel(b="more_than_two_chars") | |
#> Will raise two validation errors, one for the default value of `a`, the other for `b` being longer than two chars. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment