validate method

  1. @override
String? validate(
  1. BuildContext context,
  2. String fieldName,
  3. String? value
)
override

Function to validate the form input. It takes a string and returns an String error message if the input is invalid or null if the input is valid.

Implementation

@override
String? validate(
  BuildContext context,
  String fieldName,
  String? value,
) {
  if (value != null && value.isNotEmpty) {
    _isValid = value == this.value;
  } else {
    _isValid = true;
  }
  if (!_isValid) {
    final l10n = context.l10n;
    _shortErrorMessage = l10n.confirmPasswordShortErrorMessage;
    _longErrorMessage = l10n.confirmPasswordLongErrorMessage;
  } else {
    _shortErrorMessage = null;
    _longErrorMessage = null;
  }
  return _shortErrorMessage;
}