Last active
August 29, 2015 14:10
-
-
Save jpotts18/aaa5ed98d0789ec75899 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SunilValidation : Validation { | |
// 8 characters. one uppercase, one lowercase, one number | |
var SUNIL_REGEX = "^(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[a-z]).{8,}$" | |
// No length. one uppercase, one lowercase, one number | |
var NO_LENGTH_SUNIL_REGEX = "^(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[a-z]).*$" | |
func validate(value: String) -> (Bool, ValidationErrorType) { | |
if let sunilTest = NSPredicate(format: "SELF MATCHES %@", SUNIL_REGEX) { | |
if sunilTest.evaluateWithObject(value) { | |
return (true, .NoError) | |
} | |
return (false, .Password) // You will need to add a ValidationRuleType and ValidationErrorType | |
} | |
return (false, .Password) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment