Package Exports
- @adobe/structured-data-validator
- @adobe/structured-data-validator/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@adobe/structured-data-validator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@adobe/structured-data-validator
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.
Features
- 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
Installation
npm install @adobe/structured-data-validatorUsage
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
Development
Prerequisites
- Node.js (latest LTS version recommended)
- npm
Setup
- Clone the repository
- Install dependencies:
npm install
Available Scripts
npm test- Run tests with coveragenpm run lint- Run ESLintnpm run format- Check code formattingnpm run format:fix- Fix code formatting issues
Dependencies
- @marbec/web-auto-extractor - For extracting structured data from web pages