A JavaScript library for validating and parsing structured data according to Schema.org specifications and Google Rich Results requirements. This library ensures your structured data meets both Schema.org standards and Google's specific requirements for rich results, helping to optimize your content for search engines and other platforms.
- Validates structured data against both Schema.org and Google Rich Results specifications
- Ensures compliance with Google's structured data guidelines
- Extensible validation system with custom type handlers
npm install @adobe/structured-data-validator
This library works in conjunction with @marbec/web-auto-extractor to validate structured data extracted from web pages.
import { Validator } from '@adobe/structured-data-validator';
import WebAutoExtractor from '@marbec/web-auto-extractor';
// First, extract structured data from HTML
const extractor = new WebAutoExtractor({ addLocation: true, embedSource: ['rdfa', 'microdata'] });
const extractedData = extractor.parse(sampleHTML);
// Create a validator instance
const validator = new Validator();
// Validate the extracted structured data
const results = await validator.validate(extractedData);
}
The validator expects the output format from @marbec/web-auto-extractor
, which includes:
- JSON-LD structured data
- Microdata
- RDFa
- Node.js (latest LTS version recommended)
- npm
- Clone the repository
- Install dependencies:
npm install
npm test
- Run tests with coveragenpm run lint
- Run ESLintnpm run format
- Check code formattingnpm run format:fix
- Fix code formatting issues
To enable debug logging and see detailed validation output, set the debug
property to true
on your Validator
instance:
const validator = new Validator(schemaOrgPath);
validator.debug = true; // Enable debug logging
This will print additional information to the console during validation, which is useful for development and troubleshooting.
- @marbec/web-auto-extractor - For extracting structured data from web pages