Learn

Schema-First Validation

Why Cuddler validates data before rendering and validates templates separately.

Guardrail

Why validation comes before rendering

Cuddler separates the question of whether input is acceptable from the question of how acceptable input should be rendered.

Data boundaryValidate data first

Prove the input facts match the Data Schema before anything else happens.

Template boundaryValidate template second

Check the render contract on its own terms instead of letting it excuse bad data.

Output boundaryRender only after both pass

Rendering becomes a controlled final step instead of a discovery mechanism.

That order keeps failures fixable and keeps the renderer honest.

Schema-first validation is the guardrail that keeps the rendering step honest. Cuddler does not treat rendering as the place to discover whether the input is acceptable. It treats validation as the place where the input either proves itself or fails clearly.

The rule

  • Validate the data against the correct Data Schema first.
  • Validate the template against the correct Template Schema second.
  • Render only after both validations succeed.

Why this is the right order

  • The data contract has to be trustworthy before the renderer sees it.
  • The template contract has to be checked on its own terms.
  • A failed validation should produce a fixable problem, not a partially rendered surprise.

What this protects

This order reduces ambiguity, prevents hidden drift, and makes the final output easier to trust. It also keeps the data and template responsibilities separated, which matters when you need to debug a result or explain it to another person.