Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/NSHipster/PasswordRules
A Swift library for defining strong password generation rules
https://github.com/NSHipster/PasswordRules
autofill passwordrules safari swift uikit
Last synced: about 1 month ago
JSON representation
A Swift library for defining strong password generation rules
- Host: GitHub
- URL: https://github.com/NSHipster/PasswordRules
- Owner: NSHipster
- License: mit
- Archived: true
- Created: 2018-07-30T10:05:47.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-24T04:13:18.000Z (almost 6 years ago)
- Last Synced: 2024-07-28T21:47:15.015Z (about 2 months ago)
- Topics: autofill, passwordrules, safari, swift, uikit
- Language: Swift
- Homepage: https://nshipster.com/uitextinputpasswordrules/
- Size: 8.79 KB
- Stars: 278
- Watchers: 11
- Forks: 16
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PasswordRules
A Swift library for defining strong password generator rules.
This functionality is discussed in the NSHipster article
[Password Rules / UITextInputPasswordRules](https://nshipster.com/uitextinputpasswordrules/).---
## Requirements
- Swift 4.0+
## Installation
### Swift Package Manager
Add the PasswordRules package to your target dependencies in `Package.swift`:
```swift
import PackageDescriptionlet 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.
### 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:```swift
import PasswordRuleslet 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:```swift
import UIKitguard #available(iOS 12, *) else {
fatalError()
}self.passwordTextField.passwordRules =
UITextInputPasswordRules(descriptor: descriptor)
```## License
MIT
## Contact
NSHipster ([@NSHipster](https://twitter.com/NSHipster))