Skip to main content

validate_jsonld

Function validate_jsonld 

Source
pub fn validate_jsonld(html: &str) -> Vec<JsonLdValidationError>
Expand description

Walks an HTML string, extracts every <script type="application/ld+json"> block, parses it as JSON, and validates required fields per schema.org @type.

Supported types (with their required-field guards):

  • Articleheadline, datePublished, author, image
  • WebPagename (Google rich-results requirement; url and inLanguage are Recommended only and not flagged here)
  • BreadcrumbListitemListElement (non-empty array)
  • FAQPagemainEntity (non-empty array of Question)
  • LocalBusinessname, address
  • Organizationname, url

Returns the empty vector if every block parses and passes its required-field check. Unknown @type values are treated as pass-through (no required fields enforced) so user-extended schemas don’t trigger false negatives.