Skip to content

Conditional Field Validations

Overview

Conditional Field Validations is an application concept where field validation rules are dynamically applied based on the values of other fields within a record or its context. This allows for more flexible and context-aware validation logic, enabling different sets of validation rules to be activated or deactivated depending on certain conditions.

Concept

Conditional Field Validations involve multiple validation rules that can be enabled or disabled based on the state of other fields. Each rule is evaluated only if its associated condition is met. The process includes:

  1. Conditional Activation: Rules are conditionally activated based on predefined criteria.
  2. Evaluation: Active rules are evaluated sequentially. Validation continues until a rule fails or all rules pass.
  3. Feedback: If any rule fails, the corresponding validation message is shown to the user.

How It Works

  1. Condition Check: When a field's value changes, the system checks the conditions specified for each validation rule.
  2. Rule Activation: Only those validation rules whose conditions are met are considered active.
  3. Sequential Validation: The active validations are processed in order. The first rule that fails provides the validation error message, stopping further checks.
  4. Error Messaging: Users receive feedback based on the first failed validation rule, or confirmation of success if all validations pass.

Re-evaluation of Other Fields: In addition to validating the field that was directly changed, the system also re-evaluates the validation rules for all other fields on the record. This is crucial because a change in one field might impact the conditions that enable or disable validation rules for other fields. For example, altering a "Loan Amount" field might activate or deactivate validations on a "Credit Score" or "Interest Rate" field, depending on the defined conditions.

Validation Hierarchy

The Validation Hierarchy is the structured set of validation rules that determines how validations are applied based on specific conditions and in which order. Each rule in the hierarchy is known as a "Validation Case Item."

Note: "Validations" are not a required attribute for a field. Therefore, you may need to enable optional attributes to view and access validations before adding them for the first time. To toggle optional attributes, click the (...) icon at the bottom of the field attributes.

Attributes of Validation Case Items

Property Description
Case Defines the condition under which the validation rule is enabled or disabled. The validation rule only applies if this condition is met. For details about the condition syntax, see Condition Syntax
Enabled A static flag used to activate or deactivate a validation case item manually. This attribute allows administrators to temporarily disable specific validations without altering or deleting them. It facilitates easier management and merging of validation configurations during updates.
Validate The expression that determines if the field's value meets the validation criteria. If the expression evaluates to true, the validation is considered to have passed. For details about the expression syntax, see Condition Syntax.
Message The message displayed to users when a validation fails. This message explains why the field's value is considered invalid. Messages can be translated according to standard localization practices.

Example Usage

Scenario: You have a form with a "Credit Score" field that requires validation only if the "Loan Amount" field exceeds a certain threshold.

Validation Hierarchy Setup:

  1. Navigate to the form and open the Page Designer
  2. Locate the "Credit Score" field
  3. Toggle "Optional Attributes" by clicking the (...) button at the bottom of the field attributes.
  4. On the "Validation" node click (+) to add a new validation case item and set attributes
  5. Case: LoanAmount > 10000
  6. Validate: CreditScore >= 650
  7. Message: "Credit score must be at least 650 for loan amounts over 10,000."
  8. Confirm and close the dialog
  9. Save and then publish the configuration.

In this example, the validation for the "Credit Score" field is only applied if the "Loan Amount" exceeds 10,000. If the condition is met and the credit score is below 650, the user receives a message indicating the issue.