diff --git a/KiwiPods/ValidationsUtils.swift b/KiwiPods/ValidationsUtils.swift index eaea42d..a0505de 100644 --- a/KiwiPods/ValidationsUtils.swift +++ b/KiwiPods/ValidationsUtils.swift @@ -8,11 +8,11 @@ import UIKit -class ValidationsUtils: NSObject { +open class ValidationsUtils: NSObject { //----------------------------------------------- // Mark Email validation //----------------------------------------------- - class func validateEmail(emailID: String) -> Bool { + class public func validateEmail(emailID: String) -> Bool { let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}" // NSString *emailRegEx = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; let emailTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", emailRegEx) @@ -22,7 +22,7 @@ class ValidationsUtils: NSObject { //----------------------------------------------- // Alpha - Numeric validation //----------------------------------------------- - class func alphanumericValidation(validation: String) -> Bool { + class public func alphanumericValidation(validation: String) -> Bool { let alphanumericRegEx = "^[a-zA-Z0-9]+$" let alphanumericTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", alphanumericRegEx) return alphanumericTest.evaluate(with: validation) @@ -30,7 +30,7 @@ class ValidationsUtils: NSObject { //----------------------------------------------- // Mark number validation //----------------------------------------------- - class func onlyNumberValidation(number: String) -> Bool { + class public func onlyNumberValidation(number: String) -> Bool { let nameRegex: String = "^[0-9]+$" let nameTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", nameRegex) return nameTest.evaluate(with: number) @@ -38,7 +38,7 @@ class ValidationsUtils: NSObject { //----------------------------------------------- // Mark number validation //----------------------------------------------- - class func onlyNumberValidationWithDash(number: String) -> Bool { + class public func onlyNumberValidationWithDash(number: String) -> Bool { let nameRegex: String = "^[0-9 '-]+$" let nameTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", nameRegex) return nameTest.evaluate(with: number) @@ -46,19 +46,19 @@ class ValidationsUtils: NSObject { //----------------------------------------------- // Mark enter only alphabets //----------------------------------------------- - class func onlyAlphabetsValidation(alphabet: String) -> Bool { + class public func onlyAlphabetsValidation(alphabet: String) -> Bool { let nameRegex: String = "^[a-zA-Z '-]+$" ///^[a-zA-Z ]*$/ let nameTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", nameRegex) return nameTest.evaluate(with: alphabet) // return true } - class func onlyAlphabetsWithSpaceValidation(alphabet: String) -> Bool { + class public func onlyAlphabetsWithSpaceValidation(alphabet: String) -> Bool { let nameRegex: String = "^[a-zA-Z ]+$" let nameTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", nameRegex) return nameTest.evaluate(with: alphabet) } - class func onlyAlphaNumericWithSpaceValidation(alphabet: String) -> Bool { + class public func onlyAlphaNumericWithSpaceValidation(alphabet: String) -> Bool { let nameRegex: String = "^[a-zA-Z0-9 ]+$" let nameTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", nameRegex) return nameTest.evaluate(with: alphabet) @@ -66,15 +66,15 @@ class ValidationsUtils: NSObject { //----------------------------------------------- // Mark mathch password //----------------------------------------------- - class func confirmationPasswordValidation(password: String, confirmationPassword: String) -> Bool { + class public func confirmationPasswordValidation(password: String, confirmationPassword: String) -> Bool { if password == confirmationPassword { return true } else { return false } } - var tableSourceList: [[String]] = [[Int](0..<20).map({ "section 0, cell \($0)" })] - class func contentView(text: String) -> UIView { + public var tableSourceList: [[String]] = [[Int](0..<20).map({ "section 0, cell \($0)" })] + class public func contentView(text: String) -> UIView { let view = UIView(frame: CGRect(x: 0, y: 0, width: 375, height: 64)) view.autoresizingMask = [.flexibleWidth, .flexibleHeight] let label = UILabel(frame: view.bounds) @@ -89,58 +89,41 @@ class ValidationsUtils: NSObject { view.addSubview(label) return view } - class func isEmpty(text: String) -> Bool { + class public func isEmpty(text: String) -> Bool { if text.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { return true } return false } - class func trimeedCount(text: String) -> Int { + class public func trimeedCount(text: String) -> Int { return text.trimmingCharacters(in: CharacterSet.whitespaces).count } - class func isValidCountPassword(passwordString: String) -> Bool { + class public func isValidCountPassword(passwordString: String) -> Bool { if passwordString.count >= 4 { return true } return false } - class func isValidPassword(passwordString: String) -> Bool { - if passwordString.count < 4 || passwordString.count > 24 { - return false - } - return true - } - class func isValidUsername(usernameString: String) -> Bool { - let stricterFilterString = "^([\\w&-]+)$" - let usernameTest = NSPredicate(format: "SELF MATCHES %@", stricterFilterString) - return usernameTest.evaluate(with: usernameString) - } - class func hasCharacterInString(string: String) -> Bool { + class public func hasCharacterInString(string: String) -> Bool { let stricterFilterString = ".*[a-zA-Z]+.*" let stringTest = NSPredicate(format: "SELF MATCHES %@", stricterFilterString) return stringTest.evaluate(with: string) } - class func isValidCountCharacterLimit(textString: String) -> Bool { - if textString.count > 0 && textString.count <= 30 { - return true - } - return false - } - class func isValidCountOfMobile(textString: String) -> Bool { + class public func isValidCountOfMobile(textString: String) -> Bool { if textString.count != 10 { return false } return true } - class func isValidZipCode(textString: String) -> Bool { + class public func isValidZipCode(textString: String) -> Bool { if textString.count != 5 { return false } return true } - class func formatPhoneNumber(contactStr: String) -> String { + class public func formatPhoneNumber(contactStr: String) -> String { let range = contactStr.range(of: contactStr) let strippedValue = contactStr.replacingOccurrences(of: "[^0-9]", with: "", options: .regularExpression, range: range) var formattedString = ""