validatePasswordForPasswordChange abstract method

void validatePasswordForPasswordChange(
  1. {required String password,
  2. required Function onSuccess,
  3. required dynamic onError(
    1. PasswordChangeRecoverableCustomValidationError
    )}
)

Performs validation of the password during a PasswordChange operation.

If validation fails, the implementation must invoke the provided onError with the error. The error will be the one returned by the PasswordChangeContext.lastRecoverableError property.

The implementation must guarantee that, one (and only one) of onSuccess and onError is invoked, and that the one invoked is invoked only once.

This method will be invoked in the main/UI thread.

Synchronous implementation example that requires the password to have at least 8 characters:

  @override
  void validatePasswordForPasswordChange({
    required String password,
    required Function onSuccess,
    required Function(PasswordChangeRecoverableCustomValidationError) onError
  }) {
    if (!isAtLeast8CharacterLong(password)) {
      final error = PasswordChangeRecoverableCustomValidationError.create(
        "The password has less than 8 characters.",
      );
      onError(error)
    } else {
      onSuccess();
    }
  }

Params:

  • password: the password to be validated.
  • onSuccess: the Function to invoke if the validation is successful.
  • onError: the Function to invoke with error if the validation fails.

Implementation

void validatePasswordForPasswordChange({
  required String password,
  required Function onSuccess,
  required Function(PasswordChangeRecoverableCustomValidationError) onError,
});