Here’s an updated version of your article to match the screenshot:
Configuring Validations in Kodexa
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, using conditions, and dynamically including 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”).
• Description: Optionally, include a brief explanation of the validation rule.
• Is Conditional (Optional):
• Enable this checkbox if the validation should only apply under specific conditions.
• Conditional Formula: Define a formula that determines when the rule should be applied.
• Rule: Define the main validation rule using formulas. If this rule evaluates to false, an exception will be triggered.
• Message: Customize the error message using formulas to dynamically include relevant data.
• Detail: Provide additional context or details for the validation, also using formulas for dynamic information.
Using Conditional Validations
When “Is Conditional” is checked, the rule will only be applied if the conditional formula evaluates to true. This allows for more flexible validation logic.
• Conditional Formula: If this formula is true, the rule will be enforced.
• Rule Formula: If this formula is false, an exception will be triggered.
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
• Conditional Formula: {TransactionType} == "Charge"
• 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."
By configuring validations this way, you can ensure that data integrity is maintained while providing users with clear and actionable feedback.
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