-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Summary
The library currently returns zero validation errors for several commonly-used schema.org types that Google Rich Results actively supports, including LocalBusiness, Article, Event, FAQPage, HowTo, WebSite, and WebPage.
Reproduction
const testData = {
jsonld: {
LocalBusiness: [{
'@type': 'LocalBusiness'
// Missing required fields: name, address, etc.
}]
},
microdata: {},
rdfa: {},
errors: []
};
const issues = await validator.validate(testData);
console.log(issues.length); // 0 — No errors reportedExpected Behavior
The validator should report missing required fields per Google's structured data guidelines.
For example, LocalBusiness should validate:
Required:
nameaddress(PostalAddress object)
Recommended:
telephoneopeningHoursSpecificationgeo(GeoCoordinates)imagepriceRange
Schema Types Affected
| Type | Google Rich Results Page |
|---|---|
| LocalBusiness | docs |
| Article | docs |
| Event | docs |
| FAQPage | docs |
| HowTo | docs |
| WebSite | docs |
| WebPage | Part of various structured data types |
Impact
Users may believe their structured data is valid when critical fields are missing, leading to:
- Failed rich result eligibility in Google Search
- Poor SEO outcomes
- Confusion when Google Search Console reports errors that this validator missed
Proposed Solution
Add validator classes for the missing types following the existing pattern. Example:
// src/types/LocalBusiness.js
import BaseValidator from './base.js';
export default class LocalBusinessValidator extends BaseValidator {
getConditions() {
return [
this.required('name'),
this.required('address', 'object'),
this.recommended('telephone'),
this.recommended('openingHoursSpecification', 'array'),
this.recommended('geo', 'object'),
this.recommended('image', 'url'),
this.recommended('priceRange'),
].map((c) => c.bind(this));
}
}Then register in src/Validator.js:
this.registeredHandlers = {
// ... existing handlers
LocalBusiness: [() => import('./types/LocalBusiness.js')],
};Problem: Subtypes are not validated
Currently, if a schema uses a subtype like Restaurant, NewsArticle, or MusicEvent, the validator returns zero errors even when required fields are missing.
Example:
const data = {
jsonld: {
Restaurant: [{
'@type': 'Restaurant'
// Missing name, address - but no errors reported!
}]
},
microdata: {},
rdfa: {},
errors: []
};
const issues = await validator.validate(data);
console.log(issues.length); // 0 — No validation!