36 lines
909 B
Python
36 lines
909 B
Python
import uuid
|
|
|
|
from datetime import date, datetime
|
|
|
|
from pydantic import BaseModel, validator
|
|
|
|
from . import to_camel
|
|
|
|
|
|
class ComplianceList(BaseModel):
|
|
id_: uuid.UUID
|
|
office_file_number: str
|
|
court_number: str
|
|
item_number: str
|
|
title: str
|
|
proceedings: str
|
|
compliance_date: date
|
|
next_hearing_date: date
|
|
|
|
class Config:
|
|
anystr_strip_whitespace = True
|
|
alias_generator = to_camel
|
|
json_encoders = {date: lambda v: v.strftime("%d-%b-%Y")}
|
|
|
|
@validator("compliance_date", pre=True)
|
|
def parse_compliance_date(cls, value):
|
|
if isinstance(value, date):
|
|
return value
|
|
return datetime.strptime(value, "%d-%b-%Y").date()
|
|
|
|
@validator("next_hearing_date", pre=True)
|
|
def parse_next_hearing_date(cls, value):
|
|
if isinstance(value, date):
|
|
return value
|
|
return datetime.strptime(value, "%d-%b-%Y").date()
|