Validation Rules
Within the Affinda platform, validation rules can be configured to automatically check whether AI-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 UI, users can see which rules have passed (highlighting fields that were auto-validated) and which have failed, clearly indicating where human review is needed.
Creating validation rules
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 the code needed to enforce it, no manual coding required.
Steps to Create a Validation Rule
- Go to Field Configuration
In the document validation interface, click “Configure Fields” in the top right corner - Add a New Validation Rule
Select edit on the field you want to apply logic to and then select “Add Validation” - Describe the Rule in Natural Language
- The selected field will be pre-filled in the prompt
- To reference other fields, type @ and choose from the list
- Clearly describe the condition or constraint. Add detail for more complex logic.
- Click “Generate”
Affinda will produce the corresponding rule logic based on your description.
After generation, you can review the underlying code, tweak the prompt, and re-generate the rule as needed to refine the behavior.
Pass and fail messages
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.’”
Missing data handling
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.
Required fields
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
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.

Updated 10 days ago