Validation rules and conditional formats are configured on taxons in a data definition. At runtime Kodexa applies those rules to the matching data objects and data attributes in each document. Use validation rules when the document data must satisfy a business rule. Use conditional formatting when reviewers need a visual cue while reviewing data. Both use the same formula language.Documentation Index
Fetch the complete documentation index at: https://developer.kodexa.ai/llms.txt
Use this file to discover all available pages before exploring further.
Where Rules Live
Rules can be attached at two levels:| Level | Attach to | Use for |
|---|---|---|
| Data attribute | A field taxon such as invoice_number, due_date, or total_amount | Required fields, field-level ranges, confidence checks, and conditional formatting on a form control |
| Data object | A group taxon such as invoice, vendor, or line_items | Cross-field checks where the rule describes the whole object |
invoice object can validate that subtotal + tax_amount matches total_amount.
Attribute-level rule
Object-level rule
Validation Rules
Validation rules are stored in thevalidationRules array on a taxon. Each rule evaluates a formula. If the formula returns truthy, the data passes. If it returns falsy or errors, Kodexa treats the rule as failed.
Rule Fields
| Field | Type | Required | Behavior |
|---|---|---|---|
id | string | No | Stable rule identifier in metadata. Use one when configuration is managed in Git. |
name | string | Recommended | Human-readable rule name shown in tooling and useful for derived exception keys. |
description | string | No | Explains why the rule exists. |
disabled | boolean | No | When true, Kodexa skips the rule. |
conditional | boolean | No | When true, Kodexa evaluates conditionalFormula before the rule. |
conditionalFormula | formula string | Required when conditional is true | If the formula is falsy or errors, Kodexa skips ruleFormula. |
ruleFormula | formula string | Yes | Must evaluate truthy for the data to pass. Empty formulas are skipped. |
messageFormula | formula string | Recommended | Builds the message for the exception when the rule fails. |
detailFormula | formula string | No | Builds additional details for the exception. |
exceptionId | string | Recommended | Stable exception type. If omitted, Kodexa derives a key from the taxon path and rule name. |
supportArticleId | string | No | Help article ID attached to the resulting exception. |
overridable | boolean | No | Controls whether a reviewer can override the exception. Defaults to not overridable when omitted. |
Evaluation Flow
- Kodexa finds the taxon for the changed data object or data attribute.
- Disabled rules are skipped.
- If
conditionalistrueandconditionalFormulais present, Kodexa evaluates the condition. - If the condition is truthy, Kodexa evaluates
ruleFormula. - Truthy results pass. Falsy results fail.
- Formula errors are treated as failed validation and marked as evaluation errors so authors can diagnose bad rules.
- Failing rules create or reopen data exceptions. Passing rules close matching open exceptions.
Validation formulas are reactive. When a formula references
{subtotal}, {tax_amount}, or another attribute, Kodexa tracks that dependency and re-evaluates the affected rule when the referenced value changes.Required Fields
Useisblank for required field checks. Missing references resolve to null, so isblank handles missing, null, empty-string, and empty-list values.
Conditional Rules
Setconditional: true when a rule should apply only for some records.
conditional is omitted or false, Kodexa evaluates ruleFormula regardless of conditionalFormula.
Cross-Field Rules
Attach cross-field rules to the field that should receive the exception, or to the group taxon when the rule describes the full object.Repeating Groups
When a formula references a child path that has multiple data objects, Kodexa returns an array of values. Math functions such assum, average, min, and max can work across those arrays.
Formula Errors
Formula errors are configuration problems. For example, an unknown function, invalid syntax, or unsupported comparison can cause the rule to fail withevaluationErrored.
Avoid
Use
Conditional Formatting
Conditional formats are stored in theconditionalFormats array on a taxon. Each format has:
| Field | Type | Required | Behavior |
|---|---|---|---|
type | string | Yes | Formatter type consumed by the review UI. |
condition | formula string | Yes | Formula that activates the format when truthy. |
properties | object | No | Formatter-specific properties, usually color or icon. |
Supported Formatter Types
| Type | Properties | Result |
|---|---|---|
backgroundColor | color | Applies a background color to the attribute control. |
textColor | color | Applies a text color to the attribute control. |
outlineColor | color | Applies a colored outline around the attribute control. |
icon | icon, color | Displays a review icon for the attribute. |
conditionalFormats to the field taxon whose control should be styled.
Attribute styling
Older examples may use
formula, backgroundColor, textColor, or icon at the top level of a conditional format. The current Kodexa document runtime evaluates condition and returns active { type, properties } records, so new configuration should use the canonical shape shown above.How Conditional Formats Recalculate
Kodexa builds a dependency graph from everycondition. When any referenced value changes, the affected conditional formats are evaluated for that data object.
- A truthy condition activates the format.
- A falsy condition deactivates the format.
- An empty
conditionis skipped. - A condition that errors is treated as inactive.
- Kodexa caches active/inactive state and emits conditional format change events only when the state changes.
Formula Language
Validation rules and conditional formats use Kodexa’s KEXL formula language. The same syntax is used by formula taxons and other data-definition features.Literals
\", \', \n, and \t, or double the quote character inside the same quote style.
Attribute References
Use curly braces to read values from the current data object or related data objects.externalName mappings, so generated data can use external names without changing the underlying taxon names.
Operators
| Operator | Use | ||
|---|---|---|---|
+, -, *, / | Arithmetic | ||
^ | Power | ||
& | String concatenation | ||
= | Equality | ||
!= | Inequality | ||
<, <=, >, >= | Ordered comparison | ||
&& | Logical and, short-circuits | ||
| ` | ` | Logical or, short-circuits | |
! | Logical not | ||
[] | Array index access | ||
() | Grouping |
Truthy and Falsy Values
Kodexa uses truthiness when deciding whether a validation passes or a conditional format is active.| Value | Truthiness |
|---|---|
true | truthy |
false | falsy |
| Non-zero number | truthy |
| Zero | falsy |
| Non-empty string | truthy |
| Empty string | falsy |
| Non-empty array | truthy |
| Empty array | falsy |
null | falsy |
Function Reference
Function names are case-insensitive, but examples should use lower-case names for consistency.| Function | Example | Notes |
|---|---|---|
sum | sum({line_items/line_total}) | Adds numeric values. Arrays are summed. |
average | average({scores/value}) | Mean of numeric values. Returns zero when there are no numeric values. |
min | min({line_items/amount}) | Lowest numeric value. |
max | max({line_items/amount}) | Highest numeric value. |
abs | abs({expected} - {actual}) | Absolute value. Arrays are summed first. |
ceil | ceil({amount}) | Round toward positive infinity. |
floor | floor({amount}) | Round toward negative infinity. |
round | round({amount}) | Round to nearest integer. |
stddeviation | stddeviation(1, 2, 3) | Standard deviation. |
decimalplaces | decimalplaces({amount}, 2, "round_half_up") | Decimal rounding. Default mode is floor. |
concat | concat("PO ", {purchase_order_number}) | Converts arguments to strings and joins them. |
substring | substring({code}, 0, 3) | String slice using start and end indexes. |
lowercase | lowercase({vendor_name}) | Returns lower-case string values. |
uppercase | uppercase({vendor_name}) | Returns upper-case string values. |
trim | trim({vendor_name}) | Trims whitespace. |
replace | replace({phone}, "-", "") | Replaces all occurrences. |
split | split({csv_value}, ",") | Returns an array. |
strlen | strlen({invoice_number}) | Length of string value. |
length | length({line_items/line_total}) | Length of string, array, map, or object representation. |
len | len({line_items/line_total}) | Alias for length. |
if | if({amount} > 0, "debit", "credit") | Conditional result. Arguments are evaluated before the function runs. |
ifnull | ifnull({tax_amount}, 0) | Returns fallback for null or empty arrays. |
sumifs | sumifs({amounts}, {types}, "freight") | Sums values where criteria match. |
countifs | countifs({statuses}, {statuses}, "open") | Counts values where criteria match. |
isnull | isnull({field}) | True for null or empty arrays. |
isblank | isblank({field}) | True for null, empty arrays, or whitespace-only strings. |
contains | contains({description}, "freight") | Substring check. |
startswith | startswith({code}, "INV") | Prefix check. |
endswith | endswith({code}, "-US") | Suffix check. |
datemath | datemath({invoice_date}, "days", 30) | Adds days, weeks, months, or years. datemath("today") returns today’s date. |
isdate | isdate({invoice_date}) | True when the value can be parsed as a date. |
isbeforedate | isbeforedate({invoice_date}, {due_date}) | Date comparison, ignoring time. |
isafterdate | isafterdate({due_date}, {invoice_date}) | Date comparison, ignoring time. |
daysbetween | daysbetween({invoice_date}, {due_date}) | Full days between two dates. |
weeksbetween | weeksbetween({start_date}, {end_date}) | Full weeks between two dates. |
monthsbetween | monthsbetween({start_date}, {end_date}) | Month difference between two dates. |
validatedate | validatedate({invoice_date}) | True when the date parses. |
formatdate | formatdate({invoice_date}, "yyyy-MM-dd") | Formats a date using Java date-pattern syntax. |
regex | regex({invoice_number}, "^[A-Z0-9-]+$") | Go regular expression match. |
matches | matches({invoice_number}, "^[A-Z0-9-]+$") | Alias for regex. |
confidence | confidence("invoice_number") | Reads confidence for an attribute on the current data object. |
count | count(1, 2, 3) | Counts function arguments. |
selectioncontains | selectioncontains({available_codes}, {code}) | Checks string values or { label, value } option objects. |
getvalue | getvalue("../invoice_number") | Resolves a path supplied as a string. |
servicebridgecall | servicebridgecall("VendorLookup", "lookup", "name", {vendor_name}) | Calls a configured Service Bridge when available in the runtime. |
Eager and Short-Circuit Evaluation
Function arguments are evaluated before the function runs. That meansif does not protect an invalid branch from being evaluated.
Avoid
Use
Common Formula Patterns
Required value
Optional date ordering
Numeric tolerance
Date window
Selection-like text
Dynamic path
Recommended Authoring Pattern
- Put field-level validation and formatting on the field taxon.
- Put object-level validation on the group taxon.
- Use stable
exceptionIdvalues for customer-facing exceptions. - Use
conditional: trueonly when the rule has a real gating condition. - Write formulas with explicit braces around every data reference.
- Prefer
isblank,ifnull,abs,datemath, and date comparison functions over hand-rolled string checks. - Keep conditional formatting visual and non-blocking; use validation rules for business conditions that must be resolved.
Related
Data Definitions Guide
Start with the overall data definition model.
Event-Based Scripting
Use scripts when a rule needs side effects or procedural logic.
Selection Option Formulas
Compute dropdown options dynamically from document context.
Formula Reference
See the broader formula guide and examples.
