no-duplicate-field-validator-body
Pydantic field validators in one model repeat the same body.
Why
Two field validators with the same mode and the same body are one validation rule written twice; a later fix to one copy silently leaves the other field validated by the old rule.
Fix
List every field in one @field_validator(...) decorator and branch on info.field_name where the fields genuinely differ.
Examples
from pydantic import BaseModel, field_validator
class Contact(BaseModel): first_name: str last_name: str
@field_validator("first_name", mode="before") @classmethod def strip_first(cls, value: str) -> str: return value.strip()
@field_validator("last_name", mode="before") @classmethod def strip_last(cls, raw: str) -> str: return raw.strip()from pydantic import BaseModel, field_validator
class Contact(BaseModel): first_name: str last_name: str
@field_validator("first_name", "last_name", mode="before") @classmethod def strip_names(cls, value: str) -> str: return value.strip()