Updated claude big changes
This commit is contained in:
@@ -1,18 +1,41 @@
|
||||
## File: app/schemas.py (or your equivalent path)
|
||||
|
||||
from pydantic import BaseModel, ConfigDict # --- MODIFICATION: Import ConfigDict
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||
from typing import List, Optional
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
import re
|
||||
|
||||
# --- NEW SCHEMAS FOR CIM WORKFLOW (Now with correct Pydantic V2 config) ---
|
||||
|
||||
class CardCreate(BaseModel):
|
||||
card_number: str
|
||||
expiration_date: str # Format: "YYYY-MM"
|
||||
cvv: str
|
||||
card_number: str = Field(..., min_length=13, max_length=19, description="Credit card number (13-19 digits)")
|
||||
expiration_date: str = Field(..., description="Expiration date in YYYY-MM format")
|
||||
cvv: str = Field(..., min_length=3, max_length=4, description="Card security code (3-4 digits)")
|
||||
main_card: bool = False
|
||||
|
||||
@field_validator('card_number')
|
||||
@classmethod
|
||||
def validate_card_number(cls, v):
|
||||
digits_only = re.sub(r'\D', '', v)
|
||||
if len(digits_only) < 13 or len(digits_only) > 19:
|
||||
raise ValueError('Card number must be 13-19 digits')
|
||||
return digits_only
|
||||
|
||||
@field_validator('expiration_date')
|
||||
@classmethod
|
||||
def validate_expiration_date(cls, v):
|
||||
if not re.match(r'^\d{4}-\d{2}$', v):
|
||||
raise ValueError('Expiration date must be in YYYY-MM format')
|
||||
return v
|
||||
|
||||
@field_validator('cvv')
|
||||
@classmethod
|
||||
def validate_cvv(cls, v):
|
||||
if not re.match(r'^\d{3,4}$', v):
|
||||
raise ValueError('CVV must be 3-4 digits')
|
||||
return v
|
||||
|
||||
class Card(BaseModel):
|
||||
id: int
|
||||
user_id: int
|
||||
@@ -82,18 +105,18 @@ class Transaction(TransactionBase):
|
||||
|
||||
class CustomerBase(BaseModel):
|
||||
account_number: Optional[str] = None
|
||||
customer_last_name: Optional[str] = None
|
||||
customer_first_name: Optional[str] = None
|
||||
customer_town: Optional[str] = None
|
||||
customer_last_name: Optional[str] = Field(None, max_length=50, description="Last name (max 50 chars)")
|
||||
customer_first_name: Optional[str] = Field(None, max_length=50, description="First name (max 50 chars)")
|
||||
customer_town: Optional[str] = Field(None, max_length=40, description="City (max 40 chars)")
|
||||
customer_state: Optional[int] = None
|
||||
customer_zip: Optional[str] = None
|
||||
customer_zip: Optional[str] = Field(None, max_length=20, description="ZIP code (max 20 chars)")
|
||||
customer_first_call: Optional[datetime] = None
|
||||
customer_email: Optional[str] = None
|
||||
customer_email: Optional[str] = Field(None, max_length=255, description="Email (max 255 chars)")
|
||||
customer_automatic: Optional[int] = None
|
||||
customer_phone_number: Optional[str] = None
|
||||
customer_home_type: Optional[int] = None
|
||||
customer_apt: Optional[str] = None
|
||||
customer_address: Optional[str] = None
|
||||
customer_address: Optional[str] = Field(None, max_length=60, description="Address (max 60 chars)")
|
||||
company_id: Optional[int] = None
|
||||
customer_latitude: Optional[str] = None
|
||||
customer_longitude: Optional[str] = None
|
||||
|
||||
Reference in New Issue
Block a user