Skip to main content

PydanticCustomError

This class represents a custom error structure used for defining specific validation failures with a unique error type and a customizable message template. It allows for the inclusion of optional context data to provide additional metadata or dynamic values for error reporting.

Attributes

AttributeTypeDescription
error_typestringA unique identifier string that categorizes the specific type of validation error.
message_templatestringA string containing placeholders used to generate the human-readable error message.
contextdict = NoneAn optional dictionary of key-value pairs used to populate values within the message template.

Constructor

Signature

def PydanticCustomError(
error_type: str,
message_template: str,
context: dict | None = None
) - > None

Parameters

NameTypeDescription
error_typestrThe unique identifier for the error type.
message_templatestrA string template used to generate the error message.
context`dictNone` = None

Signature

def PydanticCustomError(
error_type: string,
message_template: string,
context: dict = None
) - > null

Parameters

NameTypeDescription
error_typestringA unique identifier string for the error type used to categorize the failure
message_templatestringA string template that defines the error message, potentially containing placeholders for context variables
contextdict = NoneAn optional dictionary of key-value pairs used to populate placeholders within the message template