MCPcopy
hub / github.com/pydantic/pydantic / Model

Class Model

tests/test_validators.py:54–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52 MyInt = Annotated[int, AfterValidator(lambda x, _info: x if x != -1 else 0)]
53
54 class Model(BaseModel):
55 x: MyInt
56
57 assert Model(x=0).x == 0
58 assert Model(x=-1).x == 0

Calls 8

AfterValidatorClass · 0.90
FieldFunction · 0.90
ConfigDictClass · 0.90
field_validatorFunction · 0.90
root_validatorFunction · 0.90
validatorFunction · 0.90
PlainSerializerClass · 0.90
PlainValidatorClass · 0.90