- 25 Jul 2024
- 2 Minutes to read
- Print
- DarkLight
Adding Validation Rules to Entities
- Updated on 25 Jul 2024
- 2 Minutes to read
- Print
- DarkLight
Overview
Validations may be applied to Folder Entities in the form of Rules or a Flow created via the Entity's Action Folder.
Setting up validation rules are particularly useful if the Action menu manually adds an Entity rather than a Flow creating the Entity. Only Data Structures with a Configuration Folder may create validations on Entities.
Validation Rules may emulate the Flow setup that creates the same Entity by implementing the Advanced Validation Rule, Validation Flow, and Validation Rule validation options.
- Advanced Validation Rule - By default set to data return rule. Returns data of type ValidationIssue. Supports more sophisticated validations; for example, using either Warn or Fatal error level to provide a custom error message.
- Validation Rule - By default set to a logical rule, this rule enforces a true/false evaluation when creating an Entity.
- Validation Flow - A Flow is used to enforce validation. For example, a database lookup to see if the vendor exists in the corporate "vendors" database before submitting a bid for a project.
Example
After creating the an applicable Data Structure, create a Folder to store the data records. A Designer Folder will not work for this use.
Advanced Validation Rule
- Navigate to the Configuration Folder of the Data Structure and click on the Advanced Rule Validation action. Give it a name and click 'CREATE'.
- In the Rule Designer, Select the 'Entity' input type, and select a property to evaluate it by. This example will evaluate if the Entity state contains started.
On the 'Result' Outcome Data, click 'Edit' and then 'ADD NEW' to create a validation outcome. The areas of configuration that will need to be configured are 'Details', 'Level', and 'Reason'. Then click 'OK' and save and close the Rule.
To test the Rule, create a Flow and navigate in the step tool box for the 'Create' step for the User Defined Type. Then declare a constant value that will trigger the Entity validation that was created.
Navigate to the normal Folder that is storing those records and click 'edit' on the Entity record.
After clicking 'edit', a Form will appear with the validation warning displayed on due to the Rule being triggered.
If the Advanced Validation Rule was set to Fatal, the Flow Designer will not create the Entity. It will throw an exception with the validation message in the error.
Validation Flow
The 'Validation Flow' uses the Flow Designer to craft the validation to evaluate the Entity by.
This type of Flow can only use synchronous steps. This means that Form steps like the 'Show Form' and the 'Add Task' steps because these steps are considered asynchronous because they pause the running Flow. The Flow will also have two endsteps, one for valid and the other invalid output. The invalid output step will be the one that triggers the warning or error message.
Validation Rule
The 'Validation Rule' creates a true/false to Rule to evaluate the Entity.
The difference between the 'Validation Rule' and the 'Advanced Validation Rule' is the output. Validation rules will only have the true/false outcome with no outcome data.