Apply business logic to validate extracted data accuracy.
Within the Affinda platform, validation rules can be configured to automatically check whether extracted data meets predefined business logic. When these rules pass, the data is considered valid and does not require user review, enabling straight-through processing for compliant documents.
Validation rules not only support model accuracy but also help identify documents that fail to meet business requirements.
In the validation interface, users can see which rules have passed (auto-validated fields are marked with the bolt icon) and which have failed, clearly indicating where human review is needed.
Affinda allows you to create powerful, flexible validation rules using natural language prompts. Simply describe the business logic you want to apply, and Affinda will automatically generate th e code needed to enforce it, no manual coding required.
In the document validation interface, click “Configure Fields” in the top right corner
2
Add a New Validation Rule
Either select the pencil icon on the field you want to apply logic to or click the Validation tab, then select “Add Validation Rule”.
3
Describe the Rule in Natural Language
To reference specific fields, type @ and choose from the list. Validation rules can be created with just one or multiple fields.Clearly describe the condition or constraint. Add detail for more complex logic.Rules are created with the annotated field in the opened document as an example.As a best practice, create validation rules on documents that accurately reflect how the fields usually appear.
4
Click "Generate"
Affinda will produce the corresponding rule logic based on your description.
5
Review and Refine
After generation, you can review the underlying code, tweak the prompt, and re-generate the rule as needed to refine the behavior.
When you generate a rule, Affinda also creates default messages to display when the rule passes or fails. These messages are shown to users in the validation UI and help explain the outcome of the rule.You can customize these messages by including guidance in your natural language prompt—for example, specify what the pass/fail messages should say to make them clearer or more specific for end users.
Example: “Ensure the invoice date is before the due date. If not, show: ‘Due date cannot be earlier than invoice date.”
In the Advanced Settings, users can define how a validation rule should behave if one or more of the referenced fields are not predicted. This is especially useful for rules involving multiple fields, where some fields may be optional or not consistently extracted.Available Options:
Skip
The rule is skipped entirely—no pass or fail outcome is recorded.
Fail
The rule automatically fails if any required field is missing.
Pass
The rule is marked as passed, regardless of missing fields.
Ignore
The rule runs by treating missing fields as neutral, attempting to return a valid result based on available data.
For example, useful in cases like subtotal + freight + tax = total, where freight is occasionally absent.
A common validation use case is ensuring that certain fields are always present and extracted from a document. To streamline this process, Affinda automatically generates a “required field” rule for every new field created. This rule can then be quickly enabled with a single click.
Validation rule results are surfaced to users in the validation UI, showing users which rules have passed (and therefore which fields have been auto-validated) and any failed rules that need user attention.For more information, see User Validation.