Class AndRule
java.lang.Object
org.pipservices3.commons.validate.AndRule
- All Implemented Interfaces:
IValidationRule
Validation rule to combine rules with AND logical operation.
When all rules returns no errors, than this rule also returns no errors.
When one of the rules return errors, than the rules returns all errors.
### Example ###
Schema schema = new Schema()
.withRule(new AndRule(
new ValueComparisonRule("GTE", 1),
new ValueComparisonRule("LTE", 10)
));
schema.validate(0); // Result: 0 must be greater or equal to 1
schema.validate(5); // Result: no error
schema.validate(20); // Result: 20 must be letter or equal 10
- See Also:
-
Constructor Summary
ConstructorDescriptionAndRule
(IValidationRule... rules) Creates a new validation rule and sets its values. -
Method Summary
-
Constructor Details
-
AndRule
Creates a new validation rule and sets its values.- Parameters:
rules
- a list of rules to join with AND operator
-
-
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.
-