Skip to main content

Module validate

Module validate 

Source
Available on crate feature validate only.
Expand description

Runtime JSON Schema validation for Trust Task payloads.

Available behind the validate Cargo feature. The codegen inlines each spec’s payload.schema.json as a string constant and emits a ValidatedPayload impl so callers can validate any inbound value against the on-the-wire schema, not just the structural shape serde recovers.

use trust_tasks_rs::{specs::acl::grant::v0_1, validate::ValidatedPayload};

let value: serde_json::Value = serde_json::json!({
    "entry": { "subject": "did:web:alice.example", "role": "admin" }
});
v0_1::Payload::validate_value(&value)?;

This is belt-and-suspenders: most schema constraints fall out of typify’s generated struct shapes, but cross-cutting checks (regex pattern, minItems on optional arrays, conditional schemas) only hold up under a true schema validator.

Structs§

ValidationError
One or more schema-validation problems encountered while checking a value.

Traits§

ValidatedPayload
A payload type whose original JSON Schema is embedded at compile time and available for runtime validation.

Functions§

against_schema
Compile schema_json as a JSON Schema and validate value against it.