RAW - IN SET
Description
The IN SET validator checks if the content of a data point is within a specified set. If the data point's value does not match any of the values in the set, a violation is thrown. This validator is particularly useful for ensuring that data points conform to a predefined list of acceptable values.
Supported Data Types
The IN SET validator supports the following data types:
- String
- Integer
Config Location
The configuration for the IN SET 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 IN SET 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 an IN_SET raw validator configuration. This validator checks if the current item is within the set of values "A", "B", or "C", 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 IN_SET validator is applied to a data item named "TYPE" with a value of "A". According to the example configuration provided, the validator checks if the value of "TYPE" is within the set of values "A", "B", or "C". Since the value is "A", which is one of the allowed values, the validator will pass successfully without throwing a violation.
On the other hand, if the value of "TYPE" were "D", the validator would throw a violation because "D" is not one of the allowed values ("A", "B", or "C").
Config Parameters
name | supported values | comment |
---|---|---|
ignoreCase |
true or false |
Determines if the validation should ignore case sensitivity. This is a boolean property. |
options |
An array of strings or integers. | The list of values that the data item is allowed to have. |
Common Mistakes
- Ensure that the
ignoreCase
value is correctly set to either"true"
or"false"
based on whether you want the validation to be case-sensitive or not. - The ignoreCase property is a boolean. If you encluse it in quotation marks and specify it as a string, it will fail execution
- Verify that the
options
array contains the correct values that you want to validate against. - Remember that the IN SET validator is powerful but requires careful configuration to avoid unintended validation outcomes.