Skip to main content
All CollectionsWorkspaces
Using Validations
Using Validations

Learn how you can use validations to check your data

Updated over 2 weeks ago

Kodexa allows users to define and configure validations within their workspace using formulas. These validations ensure that extracted data meets specific rules or requirements. This article will guide you through creating a validation and using formulas to dynamically include information in the Message and Detail fields.


Creating a Validation

1. Navigate to the Validations tab.

2. Click on Add Validation.

3. Fill in the details for your validation:

Name: Provide a descriptive name for the validation (e.g., “Charge amount required”).

Rule: Define the rule using formulas. Use available elements to build your logic dynamically.

Message: Customize the error message and use formulas to dynamically include relevant data.

Detail: Provide additional context or details for the validation, also using formulas for dynamic information.


Using Formulas in Message and Detail

The Message and Detail fields allow you to embed dynamic information based on the extracted data. This makes it easier for users to understand the exact issue and take corrective action.

Embedding Information Dynamically

To include dynamic information in the Message or Detail, use attributes enclosed in curly brackets {}. These attributes will be replaced with their actual values when the validation rule is triggered.

Example

Validation Configuration

Rule: {ChargeAmount} > 0

Message: "Charge amount is invalid: {ChargeAmount}"

Detail: "The entered charge amount of {ChargeAmount} must be greater than 0."

Result

If the validation fails because the charge amount is -10:

Message: "Charge amount is invalid: -10"

Detail: "The entered charge amount of -10 must be greater than 0."


Understanding Formulas

Kodexa’s formula functionality allows you to define rules dynamically using available attributes and operations. You can also use these formulas to build customized messages and details.

1. Formula Structure

Numbers: 123

Strings: "example"

Attributes: {attributeName}

Arrays: [1, 2, 3]

2. Supported Operators

• Arithmetic: +, -, *, /, ^

• Comparison: <, <=, =, >, >=, !=

• Logical: AND (&&), OR (||), NOT (!)

• Grouping: & (Concatenate), () (Group expressions)

3. Functions

Kodexa provides a range of built-in functions to perform advanced operations:

Mathematical

• sum([1, 2, 3]) → 6

• average([2, 4, 6]) → 4

• round([2.556, 2]) → 2.56

Text

• concat(["hello", " ", "world"]) → "hello world"

• uppercase(["text"]) → "TEXT"

• lowercase(["TEXT"]) → "text"

Logical

• if({age} >= 18, "Eligible", "Not Eligible")

• ifnull({value}, "Default", "Value exists")

Date

• datemath(["2023-04-01", "days", 5]) → "2023-04-06"


Tips for Building Messages and Details

• Use attributes like {ChargeAmount} directly in the Message or Detail field to provide dynamic context.

• Combine attributes with static text using concatenation (&) for clear and actionable messages.

• Preview the Extracted Data to ensure your formulas work as expected.


Complex Example

Validation Name: Charge amount required

Rule: {ChargeAmount} <= 0

Message: "Invalid charge amount: {ChargeAmount}. It should be greater than zero."

Detail: "The charge amount entered is {ChargeAmount}. Please review and update it to a positive value."

Result (if {ChargeAmount} is -50):

Message: "Invalid charge amount: -50. It should be greater than zero."

Detail: "The charge amount entered is -50. Please review and update it to a positive value."


Make sure you read up on

Did this answer your question?