Files
PecHub/backend/app/schemas/pec_contact.py
T
2026-03-27 20:59:06 +01:00

57 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
Schemi Pydantic per PecContact (Feature 6 Rubrica indirizzi PEC).
"""
import uuid
from datetime import datetime
from pydantic import BaseModel, EmailStr, field_validator
class PecContactCreate(BaseModel):
email: EmailStr
name: str | None = None
organization: str | None = None
notes: str | None = None
is_favorite: bool = False
@field_validator("email")
@classmethod
def email_lowercase(cls, v: str) -> str:
return v.lower().strip()
class PecContactUpdate(BaseModel):
name: str | None = None
organization: str | None = None
notes: str | None = None
is_favorite: bool | None = None
class PecContactResponse(BaseModel):
model_config = {"from_attributes": True}
id: uuid.UUID
tenant_id: uuid.UUID
email: str
name: str | None = None
organization: str | None = None
notes: str | None = None
is_favorite: bool
auto_saved: bool
created_by: uuid.UUID | None = None
created_at: datetime
updated_at: datetime
class PecContactListResponse(BaseModel):
items: list[PecContactResponse]
total: int
class PecContactImportResult(BaseModel):
created: int
updated: int
skipped: int
errors: list[str] = []