NMAPinPolicy
@objc
public protocol NMAPinPolicy
The object defining the minimum and maximum length of the PIN.
-
The minimum length of the PIN.
Declaration
Swift
var minLength: Int { get }
-
The maximum length of the PIN.
Declaration
Swift
var maxLength: Int { get }
-
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
onError
with the error. The error will be the one returned by thelastRecoverableError
property.The implementation must guarantee that, one (and only one) of
onSuccess
andonError
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:
- (void)validatePinForEnrollment:(NSString *)pin onSuccess:(void (^)(void))onSuccess onError:(void (^)(NMAPinEnrollmentValidationError *))onError { if ([self hasLessThan4DifferentDigits:pin]) { return onError([[NMAPinEnrollmentValidationError alloc] initWithErrorType:PinEnrollmentValidationErrorTypeInvalidPin errorDescription:@"The PIN has less than 4 consecutive digits." cause:NULL];); } onSuccess(); }
Declaration
Swift
func validatePinForEnrollment(_ pin: String, onSuccess: @escaping () -> (), onError: @escaping (NMAPinEnrollmentValidationError) -> ())
Parameters
pin
the PIN to be validated.
onSuccess
the block to execute if the validation is successful.
onError
the block to execute with the error if the validation fails.
-
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 thelastRecoverableError
property.The implementation must guarantee that, one (and only one) of
onSuccess
andonError
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:
- (void)validatePinForPinChange:(NSString *)pin onSuccess:(void (^)(void))onSuccess onError:(void (^)(NMAPinChangeValidationError *))onError { if ([self isDifferentThanConfirmationPIN:pin]) { return onError([[NMAPinChangeValidationError alloc] initWithErrorType:PinChangeValidationErrorTypeInvalidPin errorDescription:@"The provided PINs do not match." cause:NULL];); } onSuccess(); }
Declaration
Swift
func validatePinForPinChange(_ pin: String, onSuccess: @escaping () -> (), onError: @escaping (NMAPinChangeValidationError) -> ())
Parameters
pin
the PIN to be validated.
onSuccess
the block to execute if the validation is successful.
onError
the block to execute with the error if the validation fails.