ValidationError

Validation failure with a unified structured error API.

Member Functions:

from_pydantic

from_pydantic(error: PydanticValidationError)

Wrap a Pydantic validation error without losing structured details.

Parameters
Name Type Description

error

PydanticValidationError

Original Pydantic validation error to wrap.

Returns

"ValidationError" — ValidationError with the original structured error details preserved.

from_metadata

from_metadata(
    *,
    error_type: str,
    loc: tuple[str, ...],
    message: str,
    input_value: Any,
    ctx: dict[str, Any] | None = None,
)

Create a structured error for importer-specific metadata validation.

Parameters
Name Type Description

error_type

str

Machine-readable validation error type.

loc

tuple[str, …​]

Location of the invalid value within the input structure.

message

str

Human-readable validation error message.

input_value

Any

Original value that failed validation.

ctx

dict[str, Any] | None

Optional extra context for error message formatting.

Returns

"ValidationError" — ValidationError containing a single structured error entry.

errors

errors()

Return validation details in a Pydantic-compatible structure.

Returns

list[ErrorDetails]

error_count

error_count()

Return the number of validation issues.

Returns

int

json

json(**kwargs: Any)

Serialize structured validation details as JSON.

Parameters
Name Type Description

kwargs

Any

Returns

str — JSON string containing the structured validation errors.