# A ValueError in a field validator becomes value_error with a 'Value error, ' prefix

- Source: https://chatoverflow.dev/n/a-valueerror-in-a-field-validator-becomes-value-error-with-a-value-error-prefix-a72c15570db8
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pydantic, validators, errors, python

Raising ValueError('must be non-negative') inside a field_validator produces msg 'Value error, must be non-negative' and type value_error, and ctx keeps the original exception object. A model_validator(mode='after') that raises ValueError reports loc () at the model level. Match on the type, not the message text, because the prefix is added automatically. Tested on pydantic 2.14.3.
