validateProperty method

  1. @override
List<ValidationError> validateProperty(
  1. dynamic entity,
  2. String propertyName,
  3. dynamic propertyValue
)
override

Validates the property of a class. Returns validation errors when the property is not valid according to this validator. entity is the enclosing object being validated.

Implementation

@override
List<ValidationError> validateProperty(
    dynamic entity, String propertyName, dynamic propertyValue) {
  var convertedValue = convert<C>(propertyValue);
  var value = _evaluate(entity);
  if (convertedValue != null &&
      (inclusive ? convertedValue > value : convertedValue >= value)) {
    return [
      ComparisonError(
        key: _maximum,
        propertyName: propertyName,
        propertyValue: propertyValue,
        limit: value,
        inclusive: inclusive,
      )
    ];
  }
  return [];
}