Skip to content

Commit

Permalink
class, methods and vars/lets made open/public
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayush Awasthi committed Jan 9, 2019
1 parent 58a4648 commit 80e95c7
Showing 1 changed file with 18 additions and 35 deletions.
53 changes: 18 additions & 35 deletions KiwiPods/ValidationsUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -22,59 +22,59 @@ 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)
}
//-----------------------------------------------
// 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)
}
//-----------------------------------------------
// 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)
}
//-----------------------------------------------
// 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)
}
//-----------------------------------------------
// 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)
Expand All @@ -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 = ""
Expand Down

0 comments on commit 80e95c7

Please sign in to comment.