Interface PinPolicy


public interface PinPolicy
The object defining the minimum and maximum length of the PIN.
See Also:
  • Method Details

    • builder

      static PinPolicy.Builder builder()
      Returns an object that can be used to build a PinPolicy.
      Returns:
      a PinPolicy builder
    • minLength

      int minLength()
      The minimum length of the PIN.
      Returns:
      the minimum length of the PIN
    • maxLength

      int maxLength()
      The maximum length of the PIN.
      Returns:
      the maximum length of the PIN
    • validatePinForEnrollment

      default void validatePinForEnrollment(char[] pin, Runnable onSuccess, Consumer<PinEnrollmentError.CustomValidationError> errorConsumer)
      Performs validation other than the minimum and maximum PIN length during PIN enrollment.

      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 enrollment.

      If validation fails, the implementation must invoke the provided Consumer<PinEnrollmentError.CustomValidationError> with the error. The error will be the one returned by the PinEnrollmentContext.lastRecoverableError() method.

      The implementation must guarantee that, one (and only one) of onSuccess and errorConsumer 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 PIN to have at least 4 different digits:

       @Override
       public void validatePinForEnrollment(char[] pin, Runnable onSuccess, Consumer<PinEnrollmentError.CustomValidationError> errorConsumer) {
           if (hasLessThan4DifferentDigits(pin)) {
               errorConsumer.accept(PinEnrollmentError.CustomValidationError.builder()
                        .description("The PIN has less than 4 consecutive digits.")
                        .build());
            }
            else {
                onSuccess.run();
            }
       }
       
      Parameters:
      pin - the PIN to be validated
      onSuccess - the object to be invoked if the validation is successful
      errorConsumer - the object to be invoked with the error if the validation fails
    • validatePinForPinChange

      default void validatePinForPinChange(char[] pin, Runnable onSuccess, Consumer<PinChangeRecoverableError.CustomValidationError> errorConsumer)
      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 Consumer<PinChangeRecoverableError.CustomValidationError> with the error. The error will be the one returned by the PinChangeContext.lastRecoverableError() method.

      The implementation must guarantee that, one (and only one) of onSuccess and errorConsumer 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
       public void validatePinForPinChange(char[] pin, Runnable onSuccess, Consumer<PinChangeRecoverableError.CustomValidationError> errorConsumer) {
           if (isDifferentThanConfirmationPIN(pin)) {
               errorConsumer.accept(PinChangeRecoverableError.CustomValidationError.builder()
                        .description("The provided PINs do not match.")
                        .build());
            }
            else {
                onSuccess.run();
            }
       }
       
      Parameters:
      pin - the PIN to be validated
      onSuccess - the object to be invoked if the validation is successful
      errorConsumer - the object to be invoked with the error if the validation fails