Skip to main content

ValidationErrorSerializer

This class facilitates the serialization of validation errors into a structured format suitable for Python consumers. It manages the conversion of internal error representations, including line errors and input types, while providing options to include contextual information and original input data in the final output.

Attributes

AttributeTypeDescription
pyPythonThe Python interpreter instance used to manage memory and interact with Python objects during serialization.
line_errorsPyLineError sliceA collection of validation error details that will be formatted into the final serialized output.
url_prefixstringAn optional string prepended to documentation links in error messages to provide custom help URLs.
include_contextbooleanA flag determining whether to include additional metadata and variables associated with the validation failure in the output.
include_inputbooleanA flag determining whether the original input value that caused the validation error should be included in the serialized response.
state[SerializationState](../../../serializers/extra/serializationstate.md?sid=serializers_extra_serializationstate)The current serialization state used to track recursion depth and shared configuration during the export process.
input_type[InputType](../../../input/input/abstract/inputtype.md?sid=input_input_abstract_inputtype)The specific format of the input data being validated, such as Python objects or JSON strings, which dictates how errors are formatted.

Constructor

Signature

def ValidationErrorSerializer(
py: Python< 'py >,
line_errors: &'py[[PyLineError](pylineerror.md?sid=errors_validation_exception_pylineerror)],
url_prefix: Option< &'py str >,
include_context: bool,
include_input: bool,
state: &'slf mut SerializationState< 'py >,
input_type: &'py InputType
) - > [ValidationErrorSerializer](validationerrorserializer.md?sid=errors_validation_exception_validationerrorserializer)

Parameters

NameTypeDescription
pyPython< 'py >The Python interpreter instance.
line_errors&'py[[PyLineError](pylineerror.md?sid=errors_validation_exception_pylineerror)]A slice of line errors to be serialized.
url_prefixOption< &'py str >An optional URL prefix for error documentation links.
include_contextboolWhether to include context information in the serialized output.
include_inputboolWhether to include the input data that caused the error in the serialized output.
state&'slf mut SerializationState< 'py >The current state of the serialization process.
input_type&'py InputTypeThe type of input being validated.