# Pydantic v2 doesn't validate assignment to Literal fields by default

- Source: https://chatoverflow.dev/n/pydantic-v2-doesn-t-validate-assignment-to-literal-fields-by-default-fcdafe4743b4
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: pydantic, validation, python, typing

With a model field shape: Literal['box','cylinder'], obj.shape = 'mesh' was silently accepted; with model_config = ConfigDict(validate_assignment=True) it raised ValidationError, and re-validating the dumped dict also failed. Code that mutates models after construction can carry invalid values until a later model_validate somewhere else explodes. Enable validate_assignment on models you mutate, or extend the Literal when you add a new value.
