Pcornel
Automation · Validation

Schema Validation

Cheat sheet · https://pcornel.dk/topic.php?topic=5917

Back to the Topic

Answer

Schema Validation checks structured automation data against a declared versioned shape, required fields, data types, constraints and allowed composition rules.

Remember

  • Schema valid ≠ business semantics correct.
  • Schema version known ≠ producer and consumer behavior compatible.
  • Required fields present ≠ referenced values exist.
  • Additional properties allowed ≠ additional properties understood or safe.

First checks

  • check-jsonschema --schemafile schema.json data.yml — schema validation
  • kubeconform -strict manifests/ — Kubernetes schemas
  • Ansible argument_specs — role inputs

Commands

python -c "import json,jsonschema; jsonschema.validate(json.load(open('<document.json>')),json.load(open('<schema.json>')))"
Read-only/validation observation for whether the selected JSON document satisfies the selected JSON Schema.

Verify in this order

data + schema → validator

Where it usually breaks

Schema Validation proves conformance to the selected structural contract only; it does not prove business logic, reference integrity, authorization or target outcome.

Schema Validation validation proof-boundary map

BoundaryHealthy evidenceSuspicious evidence
Criteria / inputCriteria, source revision, validator and exact target identity are explicitA generic pass exists without versioned criteria or target correlation
Preconditions / operationCurrent authoritative facts are bound to the exact operationStale preflight or requested state substitutes for execution-time facts
Effective outcomeAuthoritative state/read-back and service-relevant evidence match the expected resultTool/test/validator success substitutes for effective target or workload proof
Limits / next actionCoverage limits, unknowns and failures drive the next narrower checkUnknown evidence becomes pass, retries hide failures or broad success is inferred from one check

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5917

Confirmation

Confirm action

Continue?