RAW - GEN EXPRESS
Description
The GEN EXPRESS validator executes a general scriptable expression. It accepts all datatypes, making it versatile for various validation scenarios. This validator is particularly useful for implementing complex validation rules that cannot be easily expressed through standard data type validators.
Supported Data Types
- Json
- String
- Boolean
- BLOB
- Decimal
- Double
- Integer
Config Location
The configuration for the GEN EXPRESS validator is defined within the <config>
element of the <rawDPValidator>
within a schema data point. This section is crucial for specifying the logic that the validator will execute to determine if the data item meets the specified criteria.
Config Requirements
The <config>
element is required for the GEN EXPRESS validator. If no configuration is provided, or if the configuration is improperly formatted, a block violation will be thrown. This ensures that the validator has the necessary logic to perform its validation task.
Example Config
Below is an example of a GEN_EXPRESS raw validator configuration. This validator checks if the current item equals either "y" or "n", and throws a violation if the condition is not met.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Example Results
Consider a scenario where the GEN EXPRESS validator is applied to a data item named "CONTAINS_DATE" with a value of "y". According to the example configuration provided, the validator checks if the value of "CONTAINS_DATE" is either "y" or "n". Since the value is "y", which is one of the allowed values, the validator will return true
, indicating that the validation passed successfully.
On the other hand, if the value of "CONTAINS_DATE" were "yes", the validator would return false
because "yes" is not one of the allowed values ("y" or "n"). In this case, a violation would be thrown, indicating that the data item did not meet the validation criteria.
Parameters
name | supported values | comment |
---|---|---|
CTX["."] |
Any value that matches the data type of the data item being validated. | The context reference to the current data item being validated. |
["y","n"] |
An array containing the allowed values for the data item. | The list of values that the data item is allowed to have. |
Common Mistakes
- Ensure that the groovy script within the
<config>
element is correctly formatted and does not contain syntax errors. - Verify that the
CTX["."]
reference correctly points to the data item being validated. - Remember that the GEN EXPRESS validator is powerful but requires careful configuration to avoid unintended validation outcomes.