OpenAgentID documentation
Source referencesRust module referenceoas-wasm

oas-wasm · validate_document

Declared module signatures, types, configuration, and source documentation.

Source: oas/oas/oas-wasm/src/validate_document.rs. SHA-256: 5f4d7cf8a957d95937b2e8327aaed826dfde71262a09247ee57a376096b2f785.

This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.

validate_document::ValidateDocumentResult

Result of a document validation, serialized as JSON.

#[derive(Debug, Serialize)]
pub struct ValidateDocumentResult {
/// Whether validation passed.

pub ok: bool,
/// The document's DID (if parsing succeeded).

#[serde(skip_serializing_if = "Option::is_none")]
pub did: Option<String>,
/// The document's entity kind (if parsing succeeded).

#[serde(skip_serializing_if = "Option::is_none")]
pub kind: Option<String>,
/// The document's conformance level (if parsing succeeded).

#[serde(skip_serializing_if = "Option::is_none")]
pub conformance_level: Option<String>,
/// Whether the document has a proof.

pub has_proof: bool,
/// Validation errors (empty if valid).

pub errors: Vec<String>
}

Source line: 13.

validate_document::validate_document

Validates an OAS Identity Document from JSON.

Checks:

  • JSON deserialization
  • Required fields present
  • DID format valid
  • Conformance level field present

Arguments

  • document_json - The document as a JSON string.

Returns

A JSON string containing a [ValidateDocumentResult].

Examples

use oas_wasm::validate_document::validate_document;
use oas_crypto::keypair::OasKeyPair;
use oas_document::builder::DocumentBuilder;
use oas_document::conformance::ConformanceLevel;

let keypair = OasKeyPair::generate();
let doc = DocumentBuilder::new("did:oas:test:hmr:alice", "hmr")
    .conformance_level(ConformanceLevel::L0)
    .add_verification_method(&keypair)
    .build_and_sign(&keypair, "2026-01-15T00:00:00Z")
    .unwrap();

let json = serde_json::to_string(&doc).unwrap();
let result = validate_document(&json);
assert!(result.contains("\"ok\":true"));
#[cfg_attr(target_arch = "wasm32", wasm_bindgen::prelude::wasm_bindgen)]
pub fn validate_document(document_json: &str) -> String;

Source line: 67.

On this page