SimplyParseDocs

Validation rules

Check every entry against your business rules, so your code knows which data it can trust.

Extraction answers "what does the document say?" Validation answers "can my system trust this value?" Rules run on every entry, and the result travels with the data:

{
  "is_valid": false,
  "validation_errors": [
    { "field": "total_amount", "value": -120, "rule": "min_value", "message": "Must be at least 0" }
  ]
}

is_valid is true only when every rule passes. Each failing field contributes one error: the first rule it failed. See Responses for the full error format.

How integrations use it

Validation turns a stream of documents into two lanes:

  • Valid entries flow straight into your system with no human in the loop.
  • Invalid entries go to a person, with validation_errors pointing at exactly which values to check. After review, write corrections back with Correct parsed values.

To keep invalid entries out of a webhook-fed system entirely, turn on the parser's Block Invalid Documents setting. Invalid entries then aren't sent to webhooks and stay in the dashboard for review. See Build a review queue.

Add rules

  1. Open the parser and go to Validation Rules.
  2. Pick a field and add one or more rules.
  3. Optionally set a custom error message. It's returned as message in validation_errors, so write it for the person who will fix the value.
  4. Save, then run Test Parser again to see the effect.

Mark a field Required in Configure Fields to reject empty values.

Rule reference

Rule (rule in errors)ChecksApplies toDefault message
requiredThe value is present and not emptyAll typesThis field is required
min_length / max_lengthText lengthTextMust be at least / no more than N characters
patternMatches a regular expressionText, ID, addressDoes not match the required pattern
allowed_charsOnly uses permitted charactersTextContains characters that are not allowed
min_value / max_valueNumeric rangeNumber, integer, currencyMust be at least / no more than N
precisionNumber of decimal placesNumber, currency
date_rangeDate between two boundsDate, date-timeDate must be on or after / on or before D
date_formatDate written in a given formatDate, date-timeDate must be in format F
min_items / max_itemsNumber of rows in a listList of ItemsMust have at least / no more than N items
unique_itemsNo duplicate rows in a listList of ItemsAll items must be unique
is_true / is_falseA flag's valueTrue / FalseValue must be true / false
lookupThe value exists in one of your lookup tablesText, number, ID

A practical strategy

  1. Get extraction right first. Rules on a schema that's still changing just create noise.
  2. Protect what your code depends on. Start with the fields your integration reads: document number, date, party, totals, currency.
  3. Add ranges and formats where real values are predictable, such as total_amount >= 0 or an ID pattern like ^INV-\d+$.
  4. Watch real failures for a week, then tighten or relax rules based on what you see.

When an entry fails, ask: is the extraction wrong, is the rule too strict, or is the document genuinely unusual? The fix isn't always in the parser.

Validation is a policy check, not proof

A valid entry passed your rules. It doesn't guarantee every extracted value matches the source document. For high-stakes fields, combine validation with spot checks or review.

Plan availability

Access to validation features can depend on your plan. If the Validation Rules tab isn't available, check your plan in the dashboard.

On this page