File size: 834 Bytes
b953016
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from pydantic import BaseModel, EmailStr, validator
import re

class UserContactRequest(BaseModel):
    """Request model for user contact information"""
    full_name: str
    email: EmailStr
    phone_number: str

    @validator('phone_number')
    def validate_phone(cls, v):
        # Remove any non-digit characters
        phone = re.sub(r'\D', '', v)
        if not 8 <= len(phone) <= 15:  # Standard phone number length globally
            raise ValueError('Invalid phone number length')
        return phone

    @validator('full_name')
    def validate_name(cls, v):
        if not v.strip():
            raise ValueError('Name cannot be empty')
        return v.strip()

class UserContactResponse(BaseModel):
    """Response model for user contact endpoint"""
    conversation_id: str
    is_existing: bool
    message: str