Hi, I'd like to use the a datetime object (not date) with input string format YYYY-MM-DD but it is not supported. What would be the best way to obtain this behavior? Do I need to make a custom data type? Thanks
use a validator:
class MyModel(BaseModel):
foobar: datetime
@validator('foobar', pre=True)
def parse_foobar(cls, v):
if isinstance(v, str):
return datetime.strptime.... # maybe needs try/except
return v
Most helpful comment
use a validator: