35 lines
1.3 KiB
Python

from pydantic import BaseModel, Field, EmailStr
from typing import Optional
from datetime import datetime
from uuid import UUID
class ContactFormBase(BaseModel):
name: str = Field(..., description="Name of the person submitting the form")
email: EmailStr = Field(..., description="Email address of the person submitting the form")
message: str = Field(..., description="Message content from the contact form")
class ContactFormCreate(ContactFormBase):
pass
class ContactFormUpdate(BaseModel):
name: Optional[str] = Field(None, description="Name of the person submitting the form")
email: Optional[EmailStr] = Field(None, description="Email address of the person submitting the form")
message: Optional[str] = Field(None, description="Message content from the contact form")
class ContactFormSchema(ContactFormBase):
id: UUID
created_at: datetime
updated_at: datetime
class Config:
orm_mode = True
schema_extra = {
"example": {
"id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"name": "John Doe",
"email": "john.doe@example.com",
"message": "I would like to inquire about your services.",
"created_at": "2023-01-01T12:00:00",
"updated_at": "2023-01-01T12:00:00"
}
}