Validations allow you to enforce rules on extracted data to ensure quality and consistency. TableFlow supports various validation types that can be applied to both template fields and table columns.
Any data that fails validation will be flagged in the review interface, allowing for manual correction before further processing.
How Validations Work
Validations are defined as an array on template fields or table columns:
"validations": [
{
"validate": "not_blank",
"message": "This field is required",
"severity": "error"
},
{
"validate": "regex",
"options": "^INV-\\d{4}$",
"message": "Invoice number must follow format INV-XXXX",
"severity": "error"
}
]
Each validation has the following properties:
- validate (required): The type of validation rule
- options: Additional configuration for the validation rule (varies by type)
- message: Custom error message to display on validation failure
- severity: The severity level of the validation failure (“error”, “warning”, or “info”)
Validation Types
Universal Validations
These validations can be applied to any data type.
Not Blank
Ensures that the field or cell contains a non-blank value.
{
"validate": "not_blank",
"message": "This field is required"
}
String Validations
These validations can only be applied to string data types.
List
Ensures the value matches one of the items in a predefined list. Comparisons are case-insensitive.
{
"validate": "list",
"options": ["Small", "Medium", "Large"],
"message": "Size must be one of the standard options"
}
Email
Ensures the value is a valid email address.
{
"validate": "email",
"message": "Please enter a valid email address"
}
Phone
Ensures the value is a valid phone number.
{
"validate": "phone",
"message": "Please enter a valid phone number"
}
Length
Validates the length of text content.
{
"validate": "length",
"options": {
"min": 4,
"max": 16
},
"message": "Value must be between 4 and 16 characters"
}
You can specify only min or max:
{
"validate": "length",
"options": {
"min": 8
},
"message": "Value must be at least 8 characters"
}
Regex
Ensures the value matches a specific regular expression pattern.
{
"validate": "regex",
"options": "^[A-Za-z0-9-]+$",
"message": "Only alphanumeric characters and hyphens are allowed"
}
Number Validations
These validations can only be applied to number data types.
Range
Validates that the number falls within a specific range.
{
"validate": "range",
"options": {
"min": 0,
"max": 100
},
"message": "Value must be between 0 and 100"
}
You can specify only min or max:
{
"validate": "range",
"options": {
"min": 0
},
"message": "Value must be greater than or equal to 0"
}
Decimal
Validates the number of decimal places.
{
"validate": "decimal",
"options": {
"places": 2
},
"message": "Value must have exactly 2 decimal places"
}
Date Validations
These validations can only be applied to date data types.
Date Range
Validates that a date falls within a specific range.
{
"validate": "date_range",
"options": {
"min": "2023-01-01",
"max": "2023-12-31"
},
"message": "Date must be in 2023"
}
Validation Severity Levels
TableFlow supports three severity levels for validations:
- error: Prevents extraction data from being used until fixed
- warning: Allows data to be used but indicates potential issues
- info: Provides informational feedback without blocking
{
"validate": "not_blank",
"message": "This field is required",
"severity": "error"
}
Combining Multiple Validations
You can apply multiple validation rules to the same field or column. All validations must pass for the data to be considered valid.
"validations": [
{
"validate": "not_blank",
"message": "This field is required"
},
{
"validate": "regex",
"options": "^[A-Z]\\d{5}$",
"message": "Product code must start with a capital letter followed by 5 digits"
}
]
During the document extraction process:
- Data is extracted from the document based on the template
- Each extracted value is checked against applicable validations
- Values that fail validation are flagged for review
- The review interface highlights validation errors with their messages
- Users can correct the data before finalizing the extraction
Example Validation Scenarios
Invoice Number Validation
{
"name": "Invoice Number",
"key": "invoice_number",
"data_type": "string",
"validations": [
{
"validate": "not_blank",
"message": "Invoice number is required"
},
{
"validate": "regex",
"options": "^INV-\\d{4}$",
"message": "Invoice number must follow format INV-XXXX"
}
]
}
Amount Validation
{
"name": "Total Amount",
"key": "total_amount",
"data_type": "number",
"validations": [
{
"validate": "not_blank",
"message": "Total amount is required"
},
{
"validate": "range",
"options": {
"min": 0
},
"message": "Total amount must be positive"
},
{
"validate": "decimal",
"options": {
"places": 2
},
"message": "Total amount must have exactly 2 decimal places"
}
]
}
Best Practices
For optimal validation results:
- Start Simple - Begin with basic validations and add complexity as needed
- Use Clear Messages - Write clear, descriptive validation messages
- Combine Validations - Use multiple validation types for complex rules
- Set Appropriate Severity - Use error for critical validations, warnings for less critical issues
- Test Thoroughly - Verify validations work with real-world documents
Next Steps
Learn how to use webhooks to integrate extracted data with your application.