Class IncludedRule
java.lang.Object
org.pipservices3.commons.validate.IncludedRule
- All Implemented Interfaces:
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 Summary
ConstructorDescriptionIncludedRule
(Object... values) Creates a new validation rule and sets its values. -
Method Summary
-
Constructor Details
-
IncludedRule
Creates a new validation rule and sets its values.- Parameters:
values
- a list of constants that value must be included to
-
-
Method Details
-
validate
Validates a given value against this rule.- Specified by:
validate
in 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.
-