Skip to main content

Crate acdp_validation

Crate acdp_validation 

Source
Expand description

Runtime validation against the ACDP schemas.

The JSON schemas are the single source of truth for wire-shape constraints, but JSON Schema cannot express every invariant in the ACDP RFCs. This module implements the runtime checks the schema delegates to producers and registries:

  • String length / array uniqueness / array size limits
  • data_period.start <= end
  • DataRef oneOf (location XOR embedded), URI credential rejection, structured-locator scheme pattern, embedded size cap, embedded content typing per encoding
  • metadata runtime depth / JCS-size / property-count caps
  • agent_id DID pattern + did:web enforcement (v0.1.0)
  • Signature value length per algorithm
  • Embedded content_hash computation and verification
  • Identifier pattern validation (ctx_id, lineage_id, content_hash)

Each function is independently usable; validate_publish_request and validate_body aggregate everything for end-to-end validation.

Functions§

compute_embedded_hash
Compute the SHA-256 ContentHash of decoded embedded content.
embedded_decoded_bytes
Decode an EmbeddedContent to its canonical byte form per acdp-data-ref.schema.json content_hash semantics:
validate_body
Validate a stored Body (retrieval-side check).
validate_body_structural
Same as validate_body but skips the embedded-content_hash recomputation.
validate_capabilities
Validate a acdp_types::CapabilitiesDocument against the runtime constraints listed in RFC-ACDP-0007 §3.
validate_data_ref
Validate a single DataRef against acdp-data-ref.schema.json and the runtime invariants the schema delegates.
validate_data_ref_structural
Same as validate_data_ref but skips the embedded-content_hash recomputation. Callers that want to report per-DataRef hash failures (e.g. acdp::client::VerifiedContext::fetch_report) run the structural checks via this helper, then call verify_embedded_hash themselves and record the outcome instead of short-circuiting.
validate_extensions
Validate the flattened forward-compatibility extensions object with the same property-count / depth / JCS-size caps as metadata.
validate_identifiers
Validate an identifier triple — convenient for retrieval-side use.
validate_metadata
Validate metadata’s runtime invariants per RFC-ACDP-0002 §3.3: max 100 top-level properties, max 8 nesting levels, max 64 KB JCS size.
validate_publish_request
Validate a complete PublishRequest against every schema constraint and runtime invariant.
verify_embedded_hash
Verify a DataRef’s declared content_hash against its embedded payload. Does nothing if the ref has no content_hash or no embedded.