Files
crm-system/app/schemas/contact.py
T

47 lines
1.2 KiB
Python
Raw Normal View History

2026-06-04 00:06:22 +00:00
"""Pydantic schemas for Contact endpoints."""
from __future__ import annotations
from datetime import datetime
from typing import Optional
from pydantic import BaseModel, ConfigDict, EmailStr, Field
class ContactBase(BaseModel):
first_name: str = Field(..., min_length=1, max_length=128)
last_name: str = Field(..., min_length=1, max_length=128)
email: Optional[EmailStr] = None
phone: Optional[str] = Field(None, max_length=64)
account_id: Optional[int] = None
class ContactCreate(ContactBase):
pass
class ContactUpdate(BaseModel):
first_name: Optional[str] = Field(None, min_length=1, max_length=128)
last_name: Optional[str] = Field(None, min_length=1, max_length=128)
email: Optional[EmailStr] = None
phone: Optional[str] = Field(None, max_length=64)
account_id: Optional[int] = None
class ContactOut(ContactBase):
model_config = ConfigDict(from_attributes=True)
id: int
org_id: int
owner_id: int
created_at: datetime
updated_at: datetime
deleted_at: Optional[datetime] = None
class ContactListItem(ContactOut):
pass
__all__ = ["ContactCreate", "ContactListItem", "ContactOut", "ContactUpdate"]