validate method

  1. @override
void validate(
  1. String? path,
  2. Schema schema,
  3. dynamic value,
  4. 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 from
  • value 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';

  if (!ObjectComparator.compare(value, _operation, _value)) {
    results.add(ValidationResult(
        path,
        ValidationResultType.Error,
        'BAD_VALUE',
        name +
            ' must ' +
            _operation.toString() +
            ' ' +
            _value.toString() +
            ' but found ' +
            value.toString(),
        _operation.toString() + ' ' + _value.toString(),
        value));
  }
}