no-nested-pydantic-field-validator
Outer-model Pydantic field validator is owned by a nested helper class.
Why
Pydantic collects validator metadata from the model class namespace. A decorator indented into a nested class is therefore invisible to the outer model, so its declared field silently loses validation.
Fix
Move the field-validator method into the outer model class.
Examples
from pydantic import BaseModel, field_validator
class Settings(BaseModel): language: str
class Config: extra = "forbid"
@field_validator("language") @classmethod def normalize(cls, value): return value.lower()from pydantic import BaseModel, field_validator
class Settings(BaseModel): language: str
@field_validator("language") @classmethod def normalize(cls, value): return value.lower()