DocView Capture by DocView.AI3 Nov 2026 09:43

Validation rules

Good data capture is not only about reading values; it is about knowing they are right. The Validation tab of a Batch Setup holds three kinds of checks:

  • Formatters tidy a value before it is checked, for example upper case or removing spaces.
  • Validators check one value, for example a pattern, a range or a check digit.
  • Rules check several fields, whole documents or the whole batch, for example Net + VAT = Total.

You define formatters and validators once, and each field picks the ones it needs. Rules apply on their own. You can try everything on sample values before saving.

Work with the Validation tab

  1. Open the Batch Setup and go to the Validation tab. Create a draft first if the version is released.
  2. Choose the tab Formatters, Validators or Rules on the left (each shows how many there are) and click Add.
  3. Give it a Name and choose its Type.
  4. Fill in the settings.
  5. Try it under Try it and click Try.
  6. Click Save validation.

Find what you need

Long lists are easy to search. Above the list:

  • Search finds items by name, type, message, or the name of a field that uses them.
  • All types shows only one type, with how many of each there are.
  • For formatters and validators, Used or not shows the ones fields use, or the ones Not used (the count of unused ones is also a link above the list).
  • For rules, filter by what they check (Several fields, Whole document, Whole batch) and by result (Errors, Warnings, Switched off).
  • Clear filters shows everything again.

Each item shows its type and main settings, and a badge with how many fields use it (unused when none). The item you choose opens on the right, which stays in view while you scroll the list. The tab you were on is remembered.

Use the small arrows to change the order in each list (they show when no search or filter is active). For formatters and validators, the order a field lists them is the order they run.

Then open each field (see Fields and extraction) and add the formatters and validators it should use with Add…. The field's lists show only the chosen items, in the order they run; use the arrows to change the order. Where a rule's settings take a list of fields, you build it the same way.

Formatters

Formatters run before validation, so calculations and checks see the tidied value.

Type What it does Settings
Trim spaces Removes spaces at the start and end. None
Single spaces Trims and turns runs of spaces into one space. None
UPPER CASE, lower case, Title Case Changes the case. None
Remove characters Removes every listed character, e.g. spaces and dashes from a VAT number. Characters to remove (a space by default)
Digits only Keeps only 0–9. None
Letters and digits only Removes spaces and punctuation. None
Find and replace Replaces text matching a pattern. Find (regular expression), Replace with ($1 for the first group), Ignore upper/lower case
Add prefix Adds text in front unless it is already there, e.g. GB for VAT numbers. Prefix
Add suffix Adds text at the end unless it is already there. Suffix
Pad to a length For example 42 → 000042. Length, Fill character, Fill on the left or right
Round amount Writes amounts with a fixed number of decimals. Decimals (default 2)
Translate with a dictionary Replaces the value with the dictionary entry's value, for example a title in another language with the English title. Values not in the dictionary stay as they are. Dictionary
Script JavaScript. value is the current value, fields holds the other fields. Return the new value. Script

Validators

A field passes only if all its validators pass. Empty values are only checked by Not empty and Script.

Type What it checks Settings
Not empty A value is required. None
Pattern The value matches a regular expression, e.g. ^INV-\d{6}$. Pattern, Ignore upper/lower case
Length Number of characters. At least, At most
Number range The value is a number within limits. Minimum, Maximum
One of a list The value is one of the listed values. Allowed values, Ignore upper/lower case
In a dictionary The value is an entry of a dictionary, for example known titles or towns. Dictionary, Also accept the dictionary's values
Date check The value is a date, optionally not in the future, not in the past or not too old. Not in the future, Not in the past (e.g. expiry dates) — rejects expired passports and permits, At most this many days ago (e.g. 365)
Check digit The check digit of a common identifier. Identifier: UK VAT number, IBAN, Luhn (card and account numbers), EAN-13 barcode, US bank routing number (ABA), NHS number or US provider number (NPI)
Script Anything else. value and fields are available. Return true (valid), false or a message (not valid). Script

Every validator can have a Message shown when it fails. Leave it empty for an automatic message that shows the value.

Tip: Combine a formatter and a validator for VAT numbers: Remove characters (space, dash, dot), then Check digit with UK VAT number. The check accepts numbers with or without the GB prefix.

A script validator:

return value.startsWith('PO') || 'Order numbers start with PO';

Dictionaries in checks

A dictionary is a list of allowed values, optionally each with a value of its own (a translation). Dictionaries are listed under Administration › Batch Settings › Dictionaries. They usually come from an import from another product, which can also replace a dictionary's entries with a new version.

  • The In a dictionary validator (type dictionary) checks that the value is an entry, for example { "dictionary": "Titles" }. Tick Also accept the dictionary's values (acceptValues) to accept the entry's value too, not only the entry itself.
  • The Translate with a dictionary formatter (type translate) replaces a value by its entry's value, for example { "dictionary": "OtherLanguageTitles" }. Unknown values are kept.

For example, a "Title" field read from tick boxes can be checked against a Titles dictionary with the entries Mr, Mrs, Miss and Ms.

DocView keeps dictionaries in memory and reloads one as soon as a new version is imported.

Rules

Rules look at more than one value. For each rule you choose:

Setting Meaning
Checks Several fields of a document, A whole document or The whole batch.
Document class One class, or All classes.
When it fails Error — must be fixed or Warning — show only.
Enabled Tick box next to When it fails.
Message Leave empty for an automatic message that shows the values.

Rules across fields

Type Example Settings
Fields add up Net + VAT = Total These fields, Add up to, Allowed difference (default 0.01)
Compare two fields Invoice date at most Due date; Total more than 0 Field, Must be (equal to, not equal to, less than, at most, more than, at least), Other field or a value
Required if PO number required when Supplier is "ACME" This field is required, When, Has the value (empty: "is filled in")
At least one of Phone or e-mail Fields
Script Anything else Script, Show the result on

Compare two fields compares numbers as numbers and dates as dates; otherwise it compares text.

Rules for whole documents

Type Settings
Number of pages At least (default 1), At most
Script Script using fields, document.number, document.className, document.pages; Show the result on

Rules for the whole batch

Type Example Settings
Documents add up to a batch field The invoices' totals add up to the batch control total. Document field, Batch field with the total, Allowed difference
Number of documents Exactly the number the operator entered in a batch field. At least, At most, Or exactly the number in
No duplicates The invoice number differs on every document. Field
Script Mixed currencies not allowed. Script using batch.fields, batch.documentCount and documents; Show the result on batch fields

Batch rules run on real batches: after extraction, whenever fields are saved in indexing, and when the batch is released. Batch rule errors stop the release.

Scripts that correct values

Script rules return true to pass, false or a message to fail, or an object with set to correct values. Values an operator typed are not overwritten. For example, work out VAT at 20 %:

return { set: { Vat: round(num(fields.Net) * 0.2, 2) } };

fields holds the values by name and tables holds line items, for example tables.LineItems[0].Amount. num() reads amounts such as £1,250.00 and round() rounds them. A batch script example:

return documents.every(d => d.fields.Currency === documents[0].fields.Currency) || 'Mixed currencies';

Scripts run in a sandbox. The editor offers suggestions for fields and helpers as you type.

Script helpers

Helper What it does
num(text) Reads an amount such as £1,250.00 as a number.
round(x, decimals) Rounds a number.
inDictionary(name, value) true when the value is an entry of the dictionary, otherwise false.
translate(name, value) The entry's value from the dictionary, or null when the value is not in it.

The same helpers work in server event scripts. For example, a rule that accepts a title from either of two dictionaries:

return inDictionary('Titles', fields.Title) || translate('OtherLanguageTitles', fields.Title) !== null
    || 'Unknown title';

Where operators see the results

Failed validators and rules are shown on the fields they concern in Correction and Index / Validate. Errors must be fixed before a document can be completed; warnings are shown only. Documents that fail validation also stop straight-through processing, so they reach an operator.

Server Validate event scripts count as rules too. See Events and scripts.

Checks on the field itself

Simple checks such as a pattern, length, range, date formats or allowed values can also be set directly on a field, without a named validator. Named validators are better when several fields share the same check.

Still stuck? support@docview.ai · +44 7886 864921

Made with DocView Capture by DocView.AI · www.docview.ai