Skip to content

Feature Request: Add validators for LocalBusiness, Article, Event, FAQPage, and other common types, and child schema validation #56

@gsriram24

Description

@gsriram24

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 reported

Expected Behavior

The validator should report missing required fields per Google's structured data guidelines.

For example, LocalBusiness should validate:

Required:

  • name
  • address (PostalAddress object)

Recommended:

  • telephone
  • openingHoursSpecification
  • geo (GeoCoordinates)
  • image
  • priceRange

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions