from __future__ import annotations from pydantic import BaseModel, ConfigDict, EmailStr, field_validator class AgentOut(BaseModel): model_config = ConfigDict(from_attributes=True) id: int name: str photo_url: str | None creci: str email: str phone: str bio: str | None is_active: bool display_order: int class AgentIn(BaseModel): name: str photo_url: str | None = None creci: str email: str phone: str bio: str | None = None is_active: bool = True display_order: int = 0 @field_validator("name") @classmethod def name_not_empty(cls, v: str) -> str: if not v.strip(): raise ValueError("name não pode ser vazio") return v.strip() @field_validator("creci") @classmethod def creci_not_empty(cls, v: str) -> str: if not v.strip(): raise ValueError("creci não pode ser vazio") return v.strip() @field_validator("email") @classmethod def email_not_empty(cls, v: str) -> str: if not v.strip(): raise ValueError("email não pode ser vazio") return v.strip() @field_validator("phone") @classmethod def phone_not_empty(cls, v: str) -> str: if not v.strip(): raise ValueError("phone não pode ser vazio") return v.strip()