validate method

  1. @override
Future<ValidatorResult> validate(
  1. dynamic value
)
override

Called by the FormX to validate each field.

This should be overridden by each validator that extends this class.

Implementation

@override
Future<ValidatorResult> validate(value) {
  final errorResult = result(
    isValid: false,
    errorMessage: errorMessage,
  );

  if (value == null) return errorResult;
  if (value is String && value.trim().isEmpty) return errorResult;

  return result(
    isValid: true,
    errorMessage: null,
  );
}