Class NotRule

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

public class NotRule extends Object implements IValidationRule
Validation rule negate another rule. When embedded rule returns no errors, than this rule return an error. When embedded rule return errors, than the rule returns no errors.

### Example ###

 
 Schema schema = new Schema()
      .withRule(new NotRule(
          new ValueComparisonRule("EQ", 1)
      ));

 schema.validate(1);          // Result: error
 schema.validate(5);          // Result: no error
 
 
See Also:
  • Constructor Details

    • NotRule

      public NotRule(IValidationRule rule)
      Creates a new validation rule and sets its values
      Parameters:
      rule - a rule to be negated.
  • 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.