Class IncludedRule

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

public class IncludedRule extends Object implements IValidationRule
Validation rule to check that value is included into the list of constants.

### Example ###

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

    • IncludedRule

      public IncludedRule(Object... values)
      Creates a new validation rule and sets its values.
      Parameters:
      values - a list of constants that value must be included 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.