Defining validation rules in a DMN model is essential to ensure that data is correctly formatted and meets business requirements before decision logic executes. If validation rules are not defined and a required field is missing, then you will get an exception during the model execution. To avoid such exceptions and ensure a consistent data structure in your DMN model, it is essential to define validation rules as part of your DMN model. The following sections explain how to define these validation rules within a DMN model.
Define Validation Rules(Constraints)
When modeling data for a DMN model, the Fact Concept in FlexRule allows you to define a wide range of validation rules(constraints) on each member of a Fact to maintain data standardization. You can specify whether a field is mandatory or optional, enforce that values are not null or empty, apply regular expression (RegEx) patterns for format validation, set data types, and define minimum or maximum lengths and value ranges. Additionally, custom expressions can be used for more complex validation logic. For each constraint, you have the option to provide a custom message that will be displayed as a notification if the input data does not meet the specified constraints.
The following example shows a Fact called tApplicantData, which has 5 members. One of the members is Age, and a validation rule(constraint) is defined for that member. The type of that constraint is NotNullorEmpty and it has a custom message “Age cannot be null or empty.” You can have as many constraints as you want based on the requirements. Then, you need to make sure you set Process All Constraints to True.

Summary
Defining validation rules in a DMN model ensures that data is standardized and meets business requirements before any decision logic is executed. 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. This step will be discussed in this article.

