PasswordPolicy

public protocol PasswordPolicy

The object defining whether the password provided by a user during enrollment or when changing is valid.

  • 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 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 characters:

    func validatePasswordForEnrollment(_ password: String, onSuccess: @escaping () -> (), onError: @escaping (PasswordEnrollmentValidationError) -> ()) {
        if (isAtLeast8CharacterLong(password)) {
            return onError(.InvalidPassword(message: "The password has less than 8 characters."))
        }
    
        onSuccess()
    }
    

    Declaration

    Swift

    func validatePasswordForEnrollment(_ password: String, onSuccess: @escaping () -> (), onError: @escaping (PasswordEnrollmentValidationError) -> ())

    Parameters

    password

    the password 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 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 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:

    func validatePasswordForPasswordChange(_ password: String, onSuccess: @escaping () -> (), onError: @escaping (PasswordChangeValidationError) -> ()) {
        if (isAtLeast8CharacterLong(password)) {
            return onError(.InvalidPassword(message: "The password has less than 8 characters."))
        }
    
        onSuccess()
    }
    

    Declaration

    Swift

    func validatePasswordForPasswordChange(_ password: String, onSuccess: @escaping () -> (), onError: @escaping (PasswordChangeValidationError) -> ())

    Parameters

    password

    the password 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.