pedantic/report
Types
Represents a structural or constraint error.
pub type Error {
Error(
path: List(PathSegment),
message: String,
kind: ErrorKind,
actual: dynamic.Dynamic,
)
}
Constructors
-
Error( path: List(PathSegment), message: String, kind: ErrorKind, actual: dynamic.Dynamic, )Arguments
- path
-
The location of the error.
- message
-
Explicit, human-readable message.
- kind
-
The classification of the failure.
- actual
-
The raw dynamic value that caused the error.
The kind of validation or parsing error that occurred.
pub type ErrorKind {
WrongType(expected: String, actual: String)
MissingField
UnknownField(String)
TooSmall(Int)
TooLarge(Int)
TooShort(Int)
TooLong(Int)
InvalidEnum(List(String))
InvalidFormat(String)
Custom(String)
}
Constructors
-
WrongType(expected: String, actual: String)The value is of the wrong type.
-
MissingFieldA required field is missing from an object.
-
UnknownField(String)An unknown field was present in the input.
-
TooSmall(Int)A numeric value is smaller than the allowed limit.
-
TooLarge(Int)A numeric value is larger than the allowed limit.
-
TooShort(Int)A string, list, or binary is too short.
-
TooLong(Int)A string, list, or binary is too long.
-
InvalidEnum(List(String))The value did not match any of the allowed enum options.
-
InvalidFormat(String)The value did not conform to the expected format.
-
Custom(String)A user-defined custom error.
Metadata holding schema decoration information.
pub type Metadata {
Metadata(
title: option.Option(String),
description: option.Option(String),
example: option.Option(dynamic.Dynamic),
)
}
Constructors
-
Metadata( title: option.Option(String), description: option.Option(String), example: option.Option(dynamic.Dynamic), )
A path is a list of segments that represents the exact location of a value.
pub type Path =
List(PathSegment)
A segment in the path to a value within a nested data structure.
pub type PathSegment {
Field(String)
Index(Int)
}
Constructors
-
Field(String)A field key in an object or dictionary.
-
Index(Int)An index offset in an array or list.
The inspectable type graph representing the shape of a codec.
pub type TypeGraph {
PrimitiveInt
PrimitiveString
PrimitiveBool
PrimitiveFloat
List(TypeGraph)
Option(TypeGraph)
Object(name: String, fields: List(TypeField))
Dict(value: TypeGraph)
Annotated(graph: TypeGraph, meta: Metadata)
Union(options: List(TypeGraph))
}
Constructors
pub type ValidationIssue =
Error
pub type ValidationReport =
Report
pub type ValidationWarning =
Warning
Represents a non-fatal warning during decoding.
pub type Warning {
Warning(path: List(PathSegment), kind: WarningKind)
}
Constructors
-
Warning(path: List(PathSegment), kind: WarningKind)Arguments
- path
-
The location of the warning.
- kind
-
The classification of the warning.
The kind of warning that occurred.
pub type WarningKind {
DiscardedUnknownField(String)
}
Constructors
-
DiscardedUnknownField(String)An unknown field was discarded from the object.
Values
pub fn default_message(kind: ErrorKind) -> String
Returns a human-readable default message for any ErrorKind.
pub fn dynamic_from(a: any) -> dynamic.Dynamic
pub fn make_error(
path: List(PathSegment),
kind: ErrorKind,
actual: dynamic.Dynamic,
) -> Error
Constructs a ValidationIssue/Error with a default message.
pub fn path_to_string(path: List(PathSegment)) -> String
Converts a path to a dotted string representation.
pub fn prefix_path(
report: Report,
segment: PathSegment,
) -> Report
Prefixes the path of all errors and warnings in a report with a segment.