Creates a new validation rule and sets its arguments.
a name of the first property to compare.
a comparison operation: "==" ("=", "EQ"), "!= " ("<>", "NE"); "<"/">" ("LT"/"GT"), "<="/">=" ("LE"/"GE"); "LIKE".
a name of the second property to compare.
Validates a given value against this rule.
a dot notation path to the value.
a schema this rule is called from
a value to be validated.
a list with validation results to add new results.
Generated using TypeDoc
Validation rule that compares two object properties.
IValidationRule
Example
let schema = new ObjectSchema() .withRule(new PropertyComparisonRule("field1", "NE", "field2")); schema.validate({ field1: 1, field2: 2 }); // Result: no errors schema.validate({ field1: 1, field2: 1 }); // Result: field1 shall not be equal to field2 schema.validate({}); // Result: no errors