from pydantic import BaseModel, EmailStr, Field, field_validator

from app.core.password_policy import validate_password_strength


class UserOut(BaseModel):
    id: str
    email: EmailStr
    role: str
    status: str


class UserProfileOut(BaseModel):
    display_name: str
    avatar_url: str | None = None


class UserMeOut(BaseModel):
    user: UserOut
    profile: UserProfileOut


class UserPatchIn(BaseModel):
    display_name: str | None = Field(default=None, min_length=1, max_length=120)


class PasswordChangeIn(BaseModel):
    current_password: str
    new_password: str = Field(min_length=8)

    @field_validator("new_password")
    @classmethod
    def password_policy(cls, value: str) -> str:
        return validate_password_strength(value)
