Class ExcludedRule

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

public class ExcludedRule extends Object implements IValidationRule
Validation rule to check that value is excluded from the list of constants.

### Example ###

 
 Schema schema = new Schema()
      .withRule(new ExcludedRule(1, 2, 3));
 
 schema.validate(2);      // Result: 2 must not be one of 1, 2, 3
 schema.validate(10);     // Result: no errors
 
 
See Also:
  • Constructor Details

    • ExcludedRule

      public ExcludedRule(Object... values)
      Creates a new validation rule and sets its values.
      Parameters:
      values - a list of constants that value must be excluded from
  • Method Details

    • validate

      public void validate(String path, Schema schema, Object value, List<ValidationResult> results)
      Validates the given value. None of the values set in this ExcludedRule object must exist in the value that is given for validation to pass.
      Specified by:
      validate in interface IValidationRule
      Parameters:
      path - the dot notation path to the value that is to be validated.
      schema - (not used in this implementation).
      value - the value that is to be validated.
      results - the results of the validation.