validatePasswordForEnrollment abstract method

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

Performs validation of the password for enrollment during a registration.

If validation fails, the implementation must invoke the provided onError with the error. The error will be the one returned by the PasswordEnrollmentContext.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 password to have at least 8 different characters:

  @override
  void validatePasswordForEnrollment({
    required String password,
    required Function onSuccess,
    required Function(PasswordEnrollmentCustomValidationError) onError
  }) {
    if (!isAtLeast8CharacterLong(password)) {
      final error = PasswordEnrollmentCustomValidationError.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 validatePasswordForEnrollment({
  required String password,
  required Function onSuccess,
  required Function(PasswordEnrollmentCustomValidationError) onError,
});