How to validate date and time in schema

import sys
sys.path.append(“…”)
from schema import BaseModel
from pydantic import Field,validator,EmailStr
from datetime import date, datetime
from typing import Optional

class CreateAppointmentSchema(BaseModel):
start_date : str

@validator(‘start_date’)
def validate_start_date(cls,v):
try:
dateobjects = datetime.strptime(v,‘%d/%m/%y’)
return dateobjects
except:
return ValueError(“wrong format”)

Please first read the pinned thread in order to understand how to post code so that it shows up properly.

Then, please actually explain why you are posting the code. Are you trying to show something off? Did something go wrong when you tried using the code? Something else?