Skip to main content

PayloadValidator

Trait PayloadValidator 

Source
pub trait PayloadValidator {
    // Required method
    fn validate(&self, schema_json: &str, payload: &Value) -> Result<(), String>;
}
Expand description

Evaluates a payload against its payload.schema.json (SPEC.md §7.2 item 2).

The framework does not bundle a JSON Schema implementation, for the same reason it does not bundle a cryptosuite: the choice of engine, its draft support, and its resource limits belong to the consumer. Implement this over whichever validator you already run — or over crate::validate::against_schema, which the validate feature provides on top of the jsonschema crate.

Required Methods§

Source

fn validate(&self, schema_json: &str, payload: &Value) -> Result<(), String>

Check payload against schema_json.

schema_json is Payload::PAYLOAD_SCHEMA — a string constant inlined from this repo at codegen time, so it is trusted input. Return a human-readable reason on failure; it lands in the malformedRequest error’s message.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§