from pydantic import BaseModel, field_validator, ConfigDict
from typing import Optional, List, Any
from datetime import date

class InvPartAphisStypePitemsDTO(BaseModel):
    id: Optional[int] = None
    aphis_general_id: Optional[int] = None
    source_type_code: Optional[str] = None
    country_code: Optional[str] = None
    geo_location: Optional[str] = None
    processing_start: Optional[date] = None
    processing_end: Optional[date] = None
    processing_type: Optional[str] = None
    processing_desc: Optional[str] = None

    model_config = ConfigDict(from_attributes=True)

    @field_validator('processing_start', 'processing_end', mode='before')
    @classmethod
    def empty_str_to_none(cls, v: Any) -> Any:
        if v == "":
            return None
        return v
