Update README.md (#3) Fixed a typo
Update README.md (#3)
Fixed a typo
A Swift library for defining strong password generator rules.
This functionality is discussed in the NSHipster article Password Rules / UITextInputPasswordRules.
Add the PasswordRules package to your target dependencies in Package.swift:
Package.swift
import PackageDescription let package = Package( name: "YourProject", dependencies: [ .package( url: "https://github.com/NSHipster/PasswordRules", from: "1.0.0" ), ] )
Then run the swift build command to build your project.
swift build
To use PasswordRules in your Xcode project using Carthage, specify it in Cartfile:
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.
carthage update
Define an array of PasswordRules cases and use the descriptor(for:) method to create a string representation:
PasswordRules
descriptor(for:)
import PasswordRules let rules: [PasswordRule] = [ .required(.upper), .required(.lower), .required(.special), .minLength(20) ] let descriptor = PasswordRule.descriptor(for: rules) // "required: upper; required: lower; required: special; minlength: 20;"
Initialize a UITextInputPasswordRules object using the descriptor and pass that to the passwordRules property of a secure text field:
UITextInputPasswordRules
passwordRules
import UIKit guard #available(iOS 12, *) else { fatalError() } self.passwordTextField.passwordRules = UITextInputPasswordRules(descriptor: descriptor)
MIT
NSHipster (@NSHipster)
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
PasswordRules
A Swift library for defining strong password generator rules.
This functionality is discussed in the NSHipster article Password Rules / UITextInputPasswordRules.
Requirements
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
: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 thedescriptor(for:)
method to create a string representation:Initialize a
UITextInputPasswordRules
object using the descriptor and pass that to thepasswordRules
property of a secure text field:License
MIT
Contact
NSHipster (@NSHipster)