{"record":{"id":"a66ddefc7cf9d24b","repo":"affaan-m/ECC","slug":"passwords-do-not-match","errorCode":null,"errorMessage":"Passwords do not match","messagePattern":"Passwords do not match","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/fastapi-patterns/SKILL.md","lineNumber":138,"sourceCode":"```python\n# app/schemas/user.py\nfrom datetime import datetime\nfrom pydantic import BaseModel, EmailStr, Field, model_validator\n\n\nclass UserBase(BaseModel):\n    email: EmailStr\n    username: str = Field(min_length=3, max_length=50)\n\n\nclass UserCreate(UserBase):\n    password: str = Field(min_length=8)\n    password_confirm: str\n\n    @model_validator(mode=\"after\")\n    def passwords_match(self) -> \"UserCreate\":\n        if self.password != self.password_confirm:\n            raise ValueError(\"Passwords do not match\")\n        return self\n\n\nclass UserUpdate(BaseModel):\n    username: str | None = Field(default=None, min_length=3, max_length=50)\n    email: EmailStr | None = None\n\n\nclass UserResponse(UserBase):\n    id: int\n    is_active: bool\n    created_at: datetime\n\n    model_config = {\"from_attributes\": True}\n\n\nclass UserListResponse(BaseModel):\n    total: int","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/affaan-m/ECC/blob/d8409a4b0813771235555e32e3d8046a73988bfa/skills/fastapi-patterns/SKILL.md#L120-L156","documentation":"Illustrative Pydantic model_validator from the fastapi-patterns skill: on a UserCreate payload, password and password_confirm differ, so schema validation rejects the request before it reaches the service layer. The mismatched request body is the invalid input.","triggerScenarios":"Thrown at skills/fastapi-patterns/SKILL.md:138 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Return the error as a 422 with a field-level message via the API's validation error handler","Confirm the client sends both fields from the same form state","Hash only the validated password, never password_confirm"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d8409a4b0813771235555e32e3d8046a73988bfa","analyzedAt":"2026-08-26T12:15:34.022Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}