-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathString+Validation.swift
40 lines (30 loc) · 1.03 KB
/
String+Validation.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import Foundation
public extension String {
public func isEmail() -> Bool {
return match(Regex.email.pattern)
}
public func isNumber() -> Bool {
return match(Regex.number.pattern)
}
public func isFullName() -> Bool {
return match(Regex.fullNames.pattern)
}
public func isPasswordValid() -> Bool {
return match(Regex.validPassword.pattern)
}
public func haveAtleaseOneSpecialSymbol() -> Bool {
return match(Regex.haveAtleaseOneSpecialSymbol.pattern)
}
func haveAtleaseOneUppercase() -> Bool {
return NSPredicate(format:"SELF MATCHES %@", ".*[A-Z]+.*").evaluate(with: self)
}
func containsEightDigits() -> Bool {
return match(Regex.containsEightDigits.pattern)
}
func haveAtleaseOneLowercase() -> Bool {
return NSPredicate(format:"SELF MATCHES %@", "(.*[a-z].*)").evaluate(with: self)
}
public func haveAtleaseOneDigit() -> Bool {
return match(Regex.atleaseOneNumber.pattern)
}
}