Skip to content

python: Add instance and kind from ValidationError #650

@jpmckinney

Description

@jpmckinney

I see the Rust crate's ValidationError has these fields:

pub struct ValidationError<'a> {
/// Value of the property that failed validation.
pub instance: Cow<'a, Value>,
/// Type of validation error.
pub kind: ValidationErrorKind,
/// Path to the value that failed validation.
pub instance_path: Location,
/// Path to the JSON Schema keyword that failed validation.
pub schema_path: Location,
}

instance and kind would be very useful in the Python package's ValidationError, to be able to construct our own error messages (like how fmt::Display uses the kind) and to add other logic related to the kind.

class ValidationError(ValueError):
message: str
schema_path: list[str | int]
instance_path: list[str | int]

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions