Skip to main content
Validation rules and conditional formats are configured on data elements in a Data Definition. In configuration, those elements are stored under taxons. 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.
You do not add validationRules or conditionalFormats directly to a stored data object or data attribute. You add them to the Data Definition element that models that object or attribute. Kodexa evaluates the rule wherever that element appears in document data.

Where Rules Live

Rules can be attached at two levels: Attribute-level rules are the most common. They bind cleanly to a field in the review UI and can create exceptions against a specific data attribute. Object-level rules are useful when the business rule is about the row or section rather than a single field. For example, an invoice object can validate that subtotal + tax_amount matches total_amount.
Attribute-level rule
Object-level rule

Validation Rules

Validation rules are stored in the validationRules 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

Evaluation Flow

  1. Kodexa finds the taxon for the changed data object or data attribute.
  2. Disabled rules are skipped.
  3. If conditional is true and conditionalFormula is present, Kodexa evaluates the condition.
  4. If the condition is truthy, Kodexa evaluates ruleFormula.
  5. Truthy results pass. Falsy results fail.
  6. Formula errors are treated as failed validation and marked as evaluation errors so authors can diagnose bad rules.
  7. 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

Use isblank for required field checks. Missing references resolve to null, so isblank handles missing, null, empty-string, and empty-list values.

Conditional Rules

Set conditional: true when a rule should apply only for some records.
If 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 data element 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 as sum, 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 with evaluationErrored.
Avoid
Use
The formula language is not SQL, JavaScript, or Excel. Use && and || for logic, = for equality, ! for not, and built-in functions such as isblank, ifnull, datemath, and contains.

Conditional Formatting

Conditional formats are stored in the conditionalFormats array on a taxon. Each format has:

Supported Formatter Types

Conditional formatting is attribute-oriented. Add 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 every condition. 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 condition is 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 data elements and other Data Definition features.

Literals

Strings can be single-quoted or double-quoted. Use backslash escapes such as \", \', \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.
References are case-insensitive when matching existing attributes. The formula service also understands data element externalName mappings, so generated data can use external names without changing the underlying element names.

Operators

Use = for equality. Do not use ==. Use && and ||; uppercase AND and OR are not formula operators.

Truthy and Falsy Values

Kodexa uses truthiness when deciding whether a validation passes or a conditional format is active.

Function Reference

Function names are case-insensitive, but examples should use lower-case names for consistency.

Eager and Short-Circuit Evaluation

Function arguments are evaluated before the function runs. That means if does not protect an invalid branch from being evaluated.
Avoid
Use logical operators when you need short-circuit behavior.
Use

Common Formula Patterns

Required value
Optional date ordering
Numeric tolerance
Date window
Selection-like text
Dynamic path
  1. Put field-level validation and formatting on the field taxon.
  2. Put object-level validation on the group data element.
  3. Use stable exceptionId values for customer-facing exceptions.
  4. Use conditional: true only when the rule has a real gating condition.
  5. Write formulas with explicit braces around every data reference.
  6. Prefer isblank, ifnull, abs, datemath, and date comparison functions over hand-rolled string checks.
  7. Keep conditional formatting visual and non-blocking; use validation rules for business conditions that must be resolved.

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.