adobe / adobe/structured-data-validator

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

Offen
#56 0 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
15
Forks
3
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

## 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

```javascript
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](https://developers.google.com/search/docs/appearance/structured-data).

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](https://developers.google.com/search/docs/appearance/structured-data/local-business) |
| Article | [docs](https://developers.google.com/search/docs/appearance/structured-data/article) |
| Event | [docs](https://developers.google.com/search/docs/appearance/structured-data/event) |
| FAQPage | [docs](https://developers.google.com/search/docs/appearance/structured-data/faqpage) |
| HowTo | [docs](https://developers.google.com/search/docs/appearance/structured-data/how-to) |
| WebSite | [docs](https://developers.google.com/search/docs/appearance/structured-data/sitelinks-searchbox) |
| 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:

```javascript
// 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`:

```javascript
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!

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Prüfe die vorhandenen Validator-Klassen und das Registrierungsmuster in src/Validator.js und vergleiche anschließend die aufgeführten Anforderungen für strukturierte Google-Daten mit den betroffenen Typen. Verwende das Beispiel LocalBusiness als Ausgangspunkt und verifiziere, dass Subtyp-Eingaben wie Restaurant, NewsArticle und MusicEvent nicht mehr ohne Validierung durchgehen. Als erledigt gilt die Aufgabe, wenn unterstützte Typen fehlende Pflichtfelder melden und empfohlene Felder wie angefordert darstellen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript
Bereich
tooling
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.