from datetime import datetime from pydantic import BaseModel, ValidationError # Define the data model for a transaction record class TxnModel(BaseModel): orderID: int customerID: int productID: list[int] paymentMthd: str totalAmt: float invoiceTime: datetime try: # Validate the sample case against the schema TxnModel.model_validate(sample_txn) print("Validated successfully!") except ValidationError as exc: # Print error messages for any validation error print("Validation Error:") print(exc.errors()) # Output: # Validated successfully