OOCommonRules.swift 900 B

123456789101112131415161718192021222324252627
  1. //
  2. // OOCommonRules.swift
  3. // o2app
  4. //
  5. // Created by 刘振兴 on 2017/9/11.
  6. // Copyright © 2017年 zone. All rights reserved.
  7. //
  8. import Foundation
  9. import SwiftValidator
  10. public class OOPhoneNumberRule: RegexRule {
  11. // let PHONE_REGEX = "^\\d{3}-\\d{3}-\\d{4}$"
  12. /// Phone number regular express string to be used in validation.
  13. static let regex = "^\\d{11}$"
  14. /**
  15. Initializes a `PhoneNumberRule` object. Used to validate that a field has a valid phone number.
  16. - parameter message: Error message that is displayed if validation fails.
  17. - returns: An initialized `PasswordRule` object, or nil if an object could not be created for some reason that would not result in an exception.
  18. */
  19. public convenience init(message : String = "请输入11位手机号码") {
  20. self.init(regex: OOPhoneNumberRule.regex, message : message)
  21. }
  22. }