Input data validation is essential in any Decision Model and Notation (DMN) model because it ensures all required data inputs are given in the correct format before the decision logic runs. If you didn't validate and enforce input data, and your DMN model requires a specific field in the execution that is missing from the input, then it will throw an exception during execution. To avoid these exceptions, validating and enforcing input data is crucial before implementing the rest of the DMN logic. The following sections explain how to implement input data validation within a DMN model.

Define Constraints

When modeling input data for a DMN model, the Fact Concept in FlexRule allows you to define a wide range of constraints on each Fact member. In this article, we explain how to define those validation rules using the FlexRule Fact Concept document.

Constraints

It’s important to note that while these constraints are defined within the Fact Concept, they are not automatically enforced. This allows you to adapt validation rules to different scenarios as needed. To enforce the constraints, you need to use a step called Validator as part of a flow.

Input Data Validator

To enforce the constraints defined in your Fact Concepts, add a Validator step (the green node) to your Activity Flow. Simply drag and drop the Concept model from the Project Explorer into your Activity Flow. Then, connect the Start node to the Validator node, and from there to the rest of your logic implementation. Also, connecting the Validator node to a Terminate node allows you to control under which conditions the process should end.

Activity Flow with Validator

Configuring the Validator

You’ll need to create a Local Parameter (IsValid) to store the Validator’s result; in the Validator node properties, set the “Copy Result To” to this parameter. Also, in the Facts Check, you need to define the connection between the members of the Fact Concept document and the input parameters of your Activity Flow.

Fact Checks

Handling Validation Results and Notifications

The Validator will check your input data against the Fact member constraints you previously defined, collecting any validation notifications and setting a Boolean value. If the input data is invalid, the Validator returns a false value for IsValid, triggering the termination of the flow. Any error messages you configured in your Fact member constraints will be displayed in the notification window, providing details on validation failures.

Fact Checks notification

Summary

Input data validation in DMN models ensures that the required data matches the defined standard before the model is executed. Using Fact Concepts to define constraints and the Validator node to enforce them helps to avoid exceptions during execution.