Class ValueComparisonRule

java.lang.Object
org.pipservices3.commons.validate.ValueComparisonRule
All Implemented Interfaces:
IValidationRule

public class ValueComparisonRule extends Object implements 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 Details

    • ValueComparisonRule

      public ValueComparisonRule(String operation, Object value)
      Creates a new validation rule and sets its values.
      Parameters:
      operation - a comparison operation.
      value - a constant value to compare to
  • Method Details

    • validate

      public void validate(String path, Schema schema, Object value, List<ValidationResult> results)
      Validates a given value against this rule.
      Specified by:
      validate in interface IValidationRule
      Parameters:
      path - a dot notation path to the value.
      schema - a schema this rule is called from
      value - a value to be validated.
      results - a list with validation results to add new results.