Skip to content

RAW - NEGATIVE

Description

The NEGATIVE validator checks if an item is not negative (positive or zero), and if so, it throws a violation. It is designed to ensure that numeric data points do not contain negative values. This validator is particularly useful for scenarios where only positive or zero values are acceptable.


Supported Data Types

The NEGATIVE validator supports all numeric data types, including:

  • Integer
  • Decimal
  • Double

Config Location

The configuration for the NEGATIVE validator is defined within the <rawDPValidator> element of 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

For the NEGATIVE validator, the <config> element is not required. This means that the validator can be applied directly to numeric data types without the need for additional configuration parameters.


Example Config

Below is an example of a NEGATIVE raw validator configuration. This validator checks if the current item is not negative, and throws a violation if the condition is not met.

1
2
3
4
5
<dataPoint name="PRICE" dataType="DECIMAL">
    <rawDPValidators>
        <rawDPValidator name="CHECK_NEGATIVE" execPriority="10" entity="NEGATIVE"/>
    </rawDPValidators>
</dataPoint>

Example Results

Consider a scenario where the NEGATIVE validator is applied to a data item named "PRICE" with a value of 10. Since the value is positive, the validator will pass successfully without throwing a violation.

On the other hand, if the value of "PRICE" were -5, the validator would throw a violation because the value is negative, which is not acceptable according to the validation criteria.


Common Mistakes

  • Ensure that the data type of the data item being validated is numeric. The NEGATIVE validator is designed to work with numeric data types only.
  • Remember that the NEGATIVE validator does not require a <config> element, so ensure that the validator is correctly applied to the data item without additional configuration.
  • Verify that the entity attribute of the <rawDPValidator> element is correctly set to "NEGATIVE" to apply the NEGATIVE validation logic.