Class ValueComparisonRule
java.lang.Object
org.pipservices3.commons.validate.ValueComparisonRule
- All Implemented Interfaces:
IValidationRule
Validation rule that compares value to a constant.
### Example ###
Schema schema = new Schema()
.withRule(new ValueComparisonRule("EQ", 1));
schema.validate(1); // Result: no errors
schema.validate(2); // Result: 2 is not equal to 1
- See Also:
-
Constructor Summary
ConstructorDescriptionValueComparisonRule
(String operation, Object value) Creates a new validation rule and sets its values. -
Method Summary
-
Constructor Details
-
ValueComparisonRule
Creates a new validation rule and sets its values.- Parameters:
operation
- a comparison operation.value
- a constant value to compare to
-
-
Method Details
-
validate
Validates a given value against this rule.- Specified by:
validate
in interfaceIValidationRule
- Parameters:
path
- a dot notation path to the value.schema
- a schema this rule is called fromvalue
- a value to be validated.results
- a list with validation results to add new results.
-