PasswordRules
A Swift library for defining strong password generator rules.
This functionality is discussed in the NSHipster article
Password Rules / UITextInputPasswordRules.
Requirements
- Swift 4.0+
Installation
Swift Package Manager
Add the PasswordRules package to your target dependencies in Package.swift
:
Then run the swift build
command to build your project.
Carthage
To use PasswordRules in your Xcode project using Carthage,
specify it in Cartfile
:
github "NSHipster/PasswordRules" ~> 1.0.0
Then run the carthage update
command to build the framework,
and drag the built PasswordRules.framework into your Xcode project.
Usage
Define an array of PasswordRules
cases
and use the descriptor(for:)
method to create a string representation:
Initialize a UITextInputPasswordRules
object using the descriptor
and pass that to the passwordRules
property of a secure text field: