Skip to main content

Business Rules

Business rules validate and normalize the values your project extracts. A validation rule checks a value and raises an error or warning in the Transaction Viewer; a normalization rule rewrites a value into a canonical form (dates, currencies, casing, codes). Rules are how you turn "the model extracted something" into "the data is correct, consistent, and enriched".

You can create rules three ways, from lowest to highest effort:

  1. Presets (low-code): pick a configurable template and fill in a short form or a visual builder. The code is generated for you and the rule stays editable in the Rule Editor.
  2. Catalog Lookup (structured): match extracted fields against a reference table (vendors, purchase orders, budget codes) without writing code. See Catalog Lookup Rule.
  3. Custom code: write JavaScript directly against the scripting API for logic the presets cannot express. See Custom (Script) Rules.

You do not have to build rules by hand at all: the Copilot can create rules for you. Describe what you want ("flag invoices whose line items don't sum to the total", "match each line item against the purchase-order catalog") and it configures the right preset or writes the code, saving it to your draft for review.

Rule levels

Every rule runs at one of three levels, which determines what data it sees:

LevelSeesTypical use
FieldOne field valueFormat checks, value normalization
DocumentAll fields in one documentCross-field checks (line items sum to total), catalog lookups
TransactionAll documents in a transactionCross-document checks (passport matches application)

Rule types

TypeWhen it runsPurpose
NormalizationDuring the Extract step, and on field edits in the Transaction ViewerRewrite values to a canonical form
ValidationAt the Validate step, and on field edits in the Transaction ViewerCheck values and raise errors or warnings

Field edits in the Viewer re-run only the affected rules (incremental validation), so a reviewer sees results update as they type without a full re-run.

Rule properties

These are set in the rule dialog and handled by the engine, not embedded in the rule's code:

PropertyDefaultDescription
EnabledOnWhen off, the rule is skipped entirely.
SeverityErrorWhen set to Warning, every error the rule raises is downgraded to a warning after it runs.
Confirm fields on successOnWhen on, the fields a passing validation rule engaged are auto-confirmed (treated as reviewed).
WeightNoneDisplay ordering only: higher-weight results appear first in the validation panel.

The severity override is one-directional and applied after the rule runs: Warning turns this rule's errors into warnings, but it never turns warnings into errors. If a rule intentionally mixes errors and warnings, setting it to Warning collapses that distinction (both become warnings); leave it at Error and choose per-condition in code instead.

Preset reference

Presets are grouped by the level they run at. Names below are the labels shown in the "Add Rule" dialog. Anything a preset generates is plain JavaScript you can switch to custom code later.

Field-level presets

PresetTypeWhat it does
Can't Be EmptyValidationRequires a non-empty value (whitespace counts as empty).
Conditionally Can't Be EmptyValidationRequires a field only when another field holds a given value.
Choice Field ValidationValidationChecks Choice selections; can require a selection and disallow multiples.
Format Validation by RegexValidationValidates the value against a regular expression.
Allowed Values ListValidationRequires the value to be one of a predefined list.
Number RangeValidationRequires a number within a min/max range.
Date RangeValidationRequires a date within a relative window from today.
Default ValueNormalizationFills a default when the field is empty.
Case NormalizationNormalizationConverts to lower, upper, or title case.
Code NormalizationNormalizationCleans alphanumeric codes (Tax ID, VAT, IBAN, BIC/SWIFT, card numbers).
Auto-ReplaceNormalizationApplies an ordered list of text replacements.
Date NormalizationNormalizationReformats dates to a chosen component order and separator.
Number NormalizationNormalizationStandardizes thousands/decimal separators and decimal places.
Currency Code NormalizationNormalizationMaps currency values to ISO 4217 codes (USD, EUR, GBP).
Country Code NormalizationNormalizationMaps country names to ISO 3166-1 codes.
Populate Field From MetadataNormalizationSets the field from a transaction/document metadata key.
Validate Field Against MetadataValidationCompares the field to a metadata key (exact or fuzzy).

Document-level presets

PresetTypeWhat it does
Catalog LookupValidationMatches extracted fields against a reference catalog; can run per line item and pull data back.
Compare FieldsValidationRequires fields, table columns, and constants to match within a document.
Cross-Field Date ValidationValidationRequires one date on or before another, with swap suggestions.
Arithmetic ValidationValidationChecks arithmetic relationships (sum fields, aggregate table columns).
Validate Fields Against MetadataValidationCompares several fields to metadata keys, each with its own mode.
Populate Fields From MetadataNormalizationFills many fields from metadata in one rule.
Conditional Auto-ReplaceNormalizationText replacements on a field, gated by a run condition.

Transaction-level presets

PresetTypeWhat it does
Compare FieldsValidationRequires fields and table columns to match across document types.
Transaction Integrity CheckValidationChecks document types, counts, page counts, and conditional requirements.

The metadata-driven presets (Populate/Validate Field(s) From/Against Metadata) compare extracted values against reference data you carry on transaction.metadata or document.metadata. They are the no-code path to the metadata helpers documented in Custom (Script) Rules. Submit reference values (expected vendor, policy flags) alongside the document at upload time, and the rule compares against them.

Wherever a rule asks for a metadata key, the box suggests the keys your project actually uses: those your recent transactions carry, and those your import connectors write (an email connector contributes Subject, From, Received and the rest). You can still type any key by hand. The same suggestions appear in classification conditions and in workflow If/Switch conditions that test a metadata value, and when adding a metadata column.

Where to go next

  • Catalog Lookup Rule: match documents against reference tables (vendors, purchase orders), including per line item.
  • Custom (Script) Rules: the full JavaScript scripting API, examples for every level, and the sandbox/security model.