Skip to content

A simple library to validate any kind of user input like Email, Name, Phone, OTP or anything else.

Notifications You must be signed in to change notification settings

sayeedhussain/iOS_UserInputValidator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Validators

A simple library to validate user inputs like Email, Name, Phone, OTP etc.

Credits

To give credit where it's due, this library is based on ideas mentioned here http://hotcocoatouch.com/2016/11/16/composite-validators

Installation

Download zip and copy the /Validators folder into your project.

Usage

let emailValidator = CompositeValidator(validators: [
    StringNonEmptyValidator(fieldName: "email"),//shouldn't be empty
    StringNonSpaceValidator(fieldName: "email"),//shouldn't have spaces
    RegexValidator(fieldName: "email", regex: "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}")//should satisfy this regex
]
        
let result = emailValidator.validate("abc@gmail")
                
if !result.success {
  print(result.error)//prints "Email is invalid."
}

About

A simple library to validate any kind of user input like Email, Name, Phone, OTP or anything else.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages