validatePinForPinChange abstract method

void validatePinForPinChange(
  1. {required String pin,
  2. required Function onSuccess,
  3. required dynamic onError(
    1. PinChangeRecoverableCustomValidationError
    )}
)

Performs validation other than the minimum and maximum PIN length during PIN change.

This must be implemented in the case you require additional criteria for a PIN to be valid: the PIN must contain a minimum number of distinct digits, sequences of consecutive digits are disallowed, etc.

If this method is not implemented, only the PIN minimum and maximum length will be validated during PIN change.

If validation fails, the implementation must invoke the provided onError with the error. The error will be the one returned by the PinChangeContext.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 PIN to be the same as a confirmation PIN provided in another field:

  @override
  void validatePinForPinChange({
    required String pin,
    required Function onSuccess,
    required Function(PinChangeRecoverableCustomValidationError) onError
  }) {
    if (isDifferentThanConfirmationPIN(pin)) {
      final error = PinChangeRecoverableCustomValidationError.create(
        "The provided PINs do not match.",
      );
      onError(error)
    } else {
      onSuccess();
    }
  }

Params:

  • pin: the PIN 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 validatePinForPinChange({
  required String pin,
  required Function onSuccess,
  required Function(PinChangeRecoverableCustomValidationError) onError,
});