Class NotRule
java.lang.Object
org.pipservices3.commons.validate.NotRule
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionNotRule
(IValidationRule rule) Creates a new validation rule and sets its values -
Method Summary
-
Constructor Details
-
NotRule
Creates a new validation rule and sets its values- Parameters:
rule
- a rule to be negated.
-
-
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.
-