Skip to content

Validate

ValidationError(message: str, schema_version: SchemaVersion | None = None)

Bases: Exception

Exception raised for errors encountered during XML metadata validation.

This exception is used to signal validation failures, optionally including the schema version involved.

Initialize ValidationError with a message and optional schema version.

PARAMETER DESCRIPTION
message

The error message describing the validation failure.

TYPE: str

schema_version

The schema version related to the validation error, if applicable.

TYPE: SchemaVersion | None DEFAULT: None

Functions

SchemaVersion

Bases: Enum

Enum representing supported schema versions for comic metadata.

This enumeration defines the possible schema versions that can be detected or validated for comic archive metadata, ordered from newest to oldest for validation priority.

Functions

__str__() -> str

Return a human-readable string representation.

ValidateMetadata(xml: bytes)

Validates XML metadata against comic archive schemas.

This class provides functionality to validate XML data against various comic metadata schemas and determine the appropriate schema version.

Initialize the ValidateMetadata instance with XML data.

PARAMETER DESCRIPTION
xml

The XML data as bytes to be validated.

TYPE: bytes

RAISES DESCRIPTION
ValidationError

If the XML data is empty or None.

Functions

__repr__() -> str

Return a string representation of the validator.

get_validation_errors(schema_version: SchemaVersion) -> list[str]

Get detailed validation errors for a specific schema version.

PARAMETER DESCRIPTION
schema_version

The schema version to validate against.

TYPE: SchemaVersion

RETURNS DESCRIPTION
list[str]

A list of validation error messages.

validate() -> SchemaVersion

Determine and return the highest valid schema version for the XML metadata.

This method checks the XML against all supported schema versions in order of preference (newest first) and returns the first valid match.

RETURNS DESCRIPTION
SchemaVersion

The highest valid schema version found, or SchemaVersion.UNKNOWN

SchemaVersion

if no valid schema is found.

validate_all() -> dict[SchemaVersion, bool]

Validate the XML against all available schema versions.

This method is useful for debugging or when you need to know which schemas the XML is compatible with.

RETURNS DESCRIPTION
dict[SchemaVersion, bool]

A dictionary mapping each schema version to its validation result.