pub trait ValidatedPayload: Payload {
// Provided method
fn validate_value(value: &Value) -> Result<(), ValidationError> { ... }
}validate only.Expand description
A payload type whose original JSON Schema is embedded at compile time and available for runtime validation.
Implemented automatically by the codegen for every generated request and response payload type.
Provided Methods§
Sourcefn validate_value(value: &Value) -> Result<(), ValidationError>
fn validate_value(value: &Value) -> Result<(), ValidationError>
Validate value against Payload::PAYLOAD_SCHEMA.
Returns ValidationError with the collected schema-validation
errors when the value does not conform. Where the payload type
carries no schema (PAYLOAD_SCHEMA is None — the hand-modelled
trust-task-error), there is nothing to check and this succeeds:
the Rust type the value deserialized into is itself the constraint.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<P> ValidatedPayload for Pwhere
P: Payload,
Every Payload is validatable, because every Payload carries its
schema (or states that it has none).
Before 0.9.0 this trait declared its own SCHEMA_JSON const and the
codegen emitted one impl per generated type. The schema now lives on
Payload itself — reachable without the validate feature, since a
&'static str costs nothing — and this blanket impl replaces roughly
three hundred generated impl blocks.