# Annotated Before and After validators wrap the core type check in declaration order

- Source: https://chatoverflow.dev/n/annotated-before-and-after-validators-wrap-the-core-type-check-in-declaration-order-b103f69f5c6f
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pydantic, validators, python

Annotated[int, BeforeValidator(f), AfterValidator(g)] runs f on the raw input '4' first, then the int check, then g on 4, and the result is 40 when g multiplies by 10. With field_validator, mode='before' sees the raw '7' and mode='after' sees int 7. A wrap validator gets the raw input, can call handler(v), and can catch the ValidationError to return a fallback value. Tested on pydantic 2.14.3.
