Class PropertiesComparisonRule
java.lang.Object
org.pipservices3.commons.validate.PropertiesComparisonRule
- All Implemented Interfaces:
IValidationRule
Validation rule that compares two object properties.
### Example ###
Schema schema = new ObjectSchema().withRule(new PropertiesComparisonRule("field1", "NE", "field2"));
schema.validate(Map.of("field1", 1, "field2", 2)); // Result: no errors
schema.validate(Map.of("field1", 1, "field2", 1)); // Result: field1 shall not be equal to field2
schema.validate(Map.of()); // Result: no errors
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPropertiesComparisonRule(String property1, String operation, String property2) Creates a new validation rule and sets its arguments. -
Method Summary
-
Constructor Details
-
PropertiesComparisonRule
Creates a new validation rule and sets its arguments.- Parameters:
property1- a name of the first property to compare.operation- a comparison operation.property2- a name of the second property to compare.- See Also:
-
-
Method Details
-
validate
Validates a given value against this rule.- Specified by:
validatein 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.
-