Giter Site home page Giter Site logo

alinradut / passwordrules Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nshipster/passwordrules

0.0 0.0 0.0 9 KB

A Swift library for defining strong password generation rules

Home Page: https://nshipster.com/uitextinputpasswordrules/

License: MIT License

Swift 83.09% Ruby 16.91%

passwordrules's Introduction

PasswordRules

A Swift library for defining strong password generator rules.

This functionality is discussed in the NSHipster article Password Rules / UIText​Input​Password​Rules.


Requirements

  • Swift 4.0+

Installation

Swift Package Manager

Add the PasswordRules package to your target dependencies in 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.

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:

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:

import UIKit

guard #available(iOS 12, *) else {
    fatalError()
}

self.passwordTextField.passwordRules =
    UITextInputPasswordRules(descriptor: descriptor)

License

MIT

Contact

NSHipster (@NSHipster)

passwordrules's People

Contributors

alinradut avatar mattt avatar sam-spencer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.