# Structured data validates without critical errors

- **Pattern:** `ab-001768` (`marketing-local-seo.local-schema.schema-validation`)
- **Severity:** high
- **Lifecycle:** active
- **Last modified:** 2026-04-18
- **Canonical URL:** https://auditbuffet.com/patterns/ab-001768
- **License:** CC-BY-4.0 — attribute to AuditBuffet Pattern Catalog (https://auditbuffet.com/patterns/ab-001768)

## Why it matters

Malformed JSON-LD, wrong case on `@type`, or typo'd property names like `adress` cause schema.org parsers to silently discard the block, which strips local-pack rich results (stars, hours, address card) from Google and Bing SERPs. The reference-integrity taxon applies: a structurally broken block is indistinguishable from no structured data at all, costing click-through in geo queries where competitors with valid LocalBusiness markup win the visual real estate.

## Severity rationale

High because one syntax error nullifies the entire block and kills rich-result eligibility across every page that renders it.

## Remediation

Parse every JSON-LD payload at build time with `JSON.parse` and assert `@context === 'https://schema.org'` and a valid `@type` before injecting the `<script>` tag. Centralize this in `src/components/structured-data.tsx` so one validator covers every page, then confirm with Google's Rich Results Test.

```ts
const schema = JSON.parse(jsonLdString)
if (schema['@context'] !== 'https://schema.org') throw new Error('bad @context')
if (!schema['@type']) throw new Error('missing @type')
```

## Detection

- **ID:** `schema-validation`
- **Severity:** `high`
- **What to look for:** Examine all JSON-LD blocks statically for structural validity: properly formed JSON (no syntax errors), correct use of `@context` and `@type`, property names that match schema.org vocabulary (no typos like `"adress"` or `"telephon"`), and no use of invented types.
- **Pass criteria:** Count all JSON-LD blocks and validate each one. 100% of JSON-LD blocks must be syntactically valid JSON, use correct `@context: "https://schema.org"`, have a valid `@type` value, and use property names that match schema.org vocabulary without obvious typos.
- **Fail criteria:** Any JSON-LD block has invalid JSON syntax, a missing or incorrect `@context`, an invented or misspelled `@type`, or property names with obvious typos that would prevent schema parsers from recognizing them.
- **Skip (N/A) when:** No JSON-LD structured data exists anywhere in the project, or whole-audit N/A rule applies.
- **Detail on fail:** Describe the specific error. Example: `"JSON-LD in layout.tsx has malformed JSON — missing closing brace"` or `"@type is set to 'localBusiness' (lowercase) — schema.org types are case-sensitive, must be 'LocalBusiness'"` or `"Property 'adress' appears to be a typo of 'address' in the LocalBusiness schema"`
- **Remediation:** Fix the specific issue reported. Validate JSON with `JSON.parse()` or in `src/components/structured-data.tsx`:

  ```ts
  // Validate at build time
  const schema = JSON.parse(jsonLdString) // throws on syntax error
  if (!schema['@context'] || !schema['@type']) throw new Error('Missing required JSON-LD fields')
  ```

  After fixing, validate using Google's Rich Results Test.

Taxons: findability, reference-integrity

HTML version: https://auditbuffet.com/patterns/ab-001768
