()
| 49 | |
| 50 | |
| 51 | def test_annotated_validator_after() -> None: |
| 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 |
| 59 | assert Model(x=-2).x == -2 |
| 60 | assert Model(x=1).x == 1 |
| 61 | assert Model(x='-1').x == 0 |
| 62 | |
| 63 | |
| 64 | def test_annotated_validator_before() -> None: |
nothing calls this directly
no test coverage detected