← Back to Notes
AI IntegrationJuly 2, 2026

How to Add a Validation Step So Your AI Pipeline Doesn't Save Garbage

Use this after an AI-parsing pipeline is already working on good input, as the next thing to check before trusting it in production.

Steps

  1. Send the pipeline something intentionally irrelevant, a greeting, a random sentence, anything that isn't the kind of structured input it was designed to parse.
  2. Check what actually got saved downstream. If a prompt only instructs the model to "always return this JSON shape," it will often force a plausible-looking but meaningless object into that shape rather than flag that the input didn't apply.
  3. Add an explicit validity signal to the prompt's expected output, a boolean field like is_valid, or is_expense for a specific domain.
  4. Add a branching step downstream that checks that field before saving anything, routing invalid input to a different path (a polite reply, a no-op) instead of the database write.

Gotcha

This gap is easy to miss because the pipeline appears to work perfectly on every test you'd naturally think to try, since you're testing with realistic input. The bug only shows up when someone asks the deliberately unhelpful question: "what happens if I send it nonsense?" Building that question into the actual test plan, not just an afterthought, is what catches this before real users do.

Quick reference

Test checklist for any AI-parsing pipeline before considering it done:

  • Valid input → correct result
  • Ambiguous input → sensible fallback, not silent garbage
  • Completely irrelevant input → explicitly rejected, not force-parsed