Skip to main content

Module validation

Module validation 

Source
Expand description

Schema.org vocabulary validation engine.

Validates a StructuredDataGraph against the official Schema.org vocabulary definitions. Produces a ValidationResult containing typed diagnostics with severity levels, machine-readable codes, and human-readable messages.

§Architecture

StructuredDataGraph
    +---- for each SchemaNode:
        +---- Type checker:     unknown, deprecated, pending
        +---- Property checker: unknown, wrong domain, superseded
        +---- Value checker:    type mismatch, coercion, enum validation

All Schema.org knowledge is compiled into static lookup functions at build time – see vocabulary for details.

§Examples

use schemaorg_rs::{extract_all, validation};

let html = r#"<script type="application/ld+json">{
  "@context": "https://schema.org",
  "@type": "Product",
  "name": "Widget"
}</script>"#;

let graph = extract_all(html).unwrap();
let result = validation::validate(&graph);

if result.has_errors() {
    for diag in result.errors() {
        eprintln!("{}: {}", diag.path, diag.message);
    }
}

Re-exports§

pub use diagnostics::DiagnosticCode;
pub use diagnostics::Severity;
pub use diagnostics::ValidationDiagnostic;

Modules§

diagnostics
Diagnostic types for Schema.org validation.

Structs§

ValidationResult
Result of validating a StructuredDataGraph against Schema.org.

Functions§

validate
Validates a StructuredDataGraph against the Schema.org vocabulary.