validate method
void
validate(
- String? path,
- Schema schema,
- dynamic value,
- List<
ValidationResult> results,
override
Validates a given value against this rule.
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.
Implementation
@override
void validate(String? path, Schema schema, dynamic value,
List<ValidationResult> results) {
var name = path ?? 'value';
var value1 = ObjectReader.getProperty(value, _property1);
var value2 = ObjectReader.getProperty(value, _property2);
if (!ObjectComparator.compare(value1, _operation, value2)) {
results.add(ValidationResult(
path,
ValidationResultType.Error,
'PROPERTIES_NOT_MATCH',
name +
' must have ' +
_property1.toString() +
' ' +
_operation.toString() +
' ' +
_property2.toString(),
value2,
value1));
}
}