MCPcopy
hub / github.com/pydantic/pydantic / test_annotated_validator_plain

Function test_annotated_validator_plain

tests/test_validators.py:89–97  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

87
88
89def test_annotated_validator_plain() -> None:
90 MyInt = Annotated[int, PlainValidator(lambda x, _info: x if x != -1 else 0)]
91
92 class Model(BaseModel):
93 x: MyInt
94
95 assert Model(x=0).x == 0
96 assert Model(x=-1).x == 0
97 assert Model(x=-2).x == -2
98
99
100def test_annotated_validator_wrap() -> None:

Callers

nothing calls this directly

Calls 2

PlainValidatorClass · 0.90
ModelClass · 0.70

Tested by

no test coverage detected