Use this when enforcing quality in a source of truth.
Data Validation
Data validation in a source of truth enforces rules on entries — required fields, naming conventions, valid ranges, no duplicates — so automation reading it does not act on bad data.
1. Validate SoT data: schemas, required fields, uniqueness, references.
2. On entry and in CI.
3. Report gaps.
4. Block invalid data.
5. Measure quality.
data → validation → accepted/rejected
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
jq empty <input.json>Primary Commands
Configuration and operational commands for this Topic.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verify deterministic validation and downstream plan identity Verify boundary
Run Data Validation twice against the same versioned source and expect the same pass/fail set, ordering-independent record identities and rule versions. Inspect rejected records with their field paths and confirm valid foreign references resolve to the intended canonical objects. Then feed the validated snapshot into a dry-run, plan or render stage and verify that its input revision/hash matches the accepted source. A green schema validator shows the declared constraints only, but it does not show the data is current, the references are semantically correct or the eventual target state is safe.
Step 2 Command read-back and what it shows Verify boundary
Verification for Source of Truth → Data Validation must distinguish state, not merely report that a command ran. With jq empty <input.json>, known-good means the dataset parses, satisfies the intended schema plus identity/reference/freshness invariants for the selected scope, and a deterministic dry render resolves all referenced objects; known-broken/suspicious means parse/schema errors, duplicate identities, broken references, stale authoritative fields or downstream rendering that cannot resolve an apparently valid record. python -m json.tool <file> shows JSON syntax is parseable, but it does not show schema compliance, referential integrity, freshness or business correctness.
Step 3 Separate parse, schema, semantic and freshness failures Narrow the fault
If Data Validation cannot parse the source, stop at encoding or serialization syntax. If parsing succeeds but schema fails, report the exact field path, expected type/constraint and source record without attempting deployment. A schema-valid record that references a nonexistent or duplicate canonical object is a semantic integrity failure; a valid but old snapshot is a freshness/version boundary. When only some records fail, do not silently drop them if downstream completeness matters. Preserve accepted and rejected counts plus stable record keys so the corrected dataset can be compared deterministically.
Step 4 Common mistakes Narrow the fault
- Data without validation rules.
Step 5 Observation-driven branch and next-check logic Narrow the fault
When Source of Truth → Data Validation fails, reproduce the smallest original case and capture jq empty <input.json> before mutation. Use the observation to choose the next check: if JSON cannot parse, fix serialization first; if parse succeeds but required/type/range rules fail, correct schema-level data; if schema passes but identity/reference/freshness checks fail, resolve semantic ownership before allowing downstream generation.
- Enforce required fields, naming and ranges.
- Prevent duplicates.
- Block bad data at entry.
check-jsonschema --schemafile device.schema.json data/*.yml— schema validation- NetBox custom validators — entry validation
- Data quality reports (missing fields) — gaps
ReferenceWhy it matters1 section · depth on demand
Source-of-truth validation protects identity and referential meaning
Source of Truth Data Validation should happen before rendering or deployment and must cover more than JSON/YAML syntax. Schema/type checks show shape, while semantic checks show identifiers are unique, references resolve, required relationships exist, enumerated values are allowed and canonical formats are used for addresses, names or platform fields. Validation should operate on a versioned snapshot so the accepted dataset can be reproduced. A record that passes local field rules can still be invalid if it points to a missing site, device, interface, tenant or policy object.
ReferenceHow it works1 section · depth on demand
How it works
Source of Truth → Data Validation should be reasoned about as a state pipeline, not as one command outcome. The responsible state is schema-constrained source records, identity/uniqueness rules, referential relationships and freshness needed before source-of-truth data is safe to drive automation. Source-of-truth validation separates syntax/schema validation from semantic checks such as unique identifiers, valid references, allowed ranges and cross-object consistency; downstream renderers assume these invariants unless they revalidate them; meanwhile API freshness, concurrent edits, secrets, external authoritative systems and environment-specific policy are independent things to check. This distinction is especially important because valid JSON only shows parseability and can still contain semantically impossible or stale data, while schema-valid objects can conflict with each other.
ReferenceImportant terms & boundaries1 section · depth on demand
Method
Data validation in a source of truth keeps the data that drives automation correct, because every error in it becomes a configuration error on devices.
1. Enforce field-level rules on entry (required fields, formats, choices, custom validators).
2. Run scheduled consistency checks: every interface with an IP has a VLAN, no overlapping prefixes, every active device has a primary IP.
3. Compare with discovered state and flag differences.
4. Report violations to data owners; block automation for objects with errors.
5. Track the error count over time.
# Nautobot/NetBox-style check
for dev in nb.dcim.devices.filter(status="active"):
if not dev.primary_ip:
problems.append(f"{dev.name}: no primary IP")
NetBox custom validators and Nautobot's Data Validation app can enforce many rules at save time.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Source of Truth > Data Validation. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://netbox.readthedocs.io/en/stable/introduction/ · confidence 94%