Skip to main content

Module validate

Module validate 

Source
Expand description

Constraint validation, kept deliberately separate from serde.

OCPP’s JSON schemas carry constraints that Rust’s type system cannot express (maxLength, minItems, numeric ranges, closed enumerations). Running them inside Deserialize would make every failure a serde error with no structure, and would tax the hot path. Instead, deserialization is pure shape-checking and validation is a second, explicit pass whose output is a list of Violations carrying a JSON pointer and a category — which is exactly what the OCPP error codes are keyed on (see crate::rpc::ErrorCode).

Structs§

ValidationPath
A cursor into the payload being validated.
Violation
A single constraint failure.
Violations
The complete result of validating one payload.

Enums§

PathSegment
One step of a JSON pointer into a payload.
ViolationKind
Why a payload is invalid. Maps 1:1 onto the OCPP error codes.

Traits§

Validate
Checks the constraints the JSON schema places on a value.

Functions§

int_range
minimum / maximum for integers.
list_len
minItems / maxItems.
range
minimum / maximum for numbers, and the JSON-representability of the value.
string
minLength / maxLength, counted in characters as the schemas intend.
unknown_enum_value
Records a value that was accepted into an enumeration’s open UnknownValue variant.