diff --git a/README.md b/README.md index f76c986..edf389d 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,10 @@ source 'https://github.com/CocoaPods/Specs.git' platform :ios, "8.1" use_frameworks! -pod 'SwiftValidator', '3.0.3' +# For SwiftValidator tag 3.0.3 +pod 'SwiftValidator', '3.0.3' +# Recommended: For the most recent version of SwiftValidator (master branch) +pod 'SwiftValidator', :git => 'https://github.com/jpotts18/SwiftValidator.git', :branch => 'master' ``` Install into your project: @@ -161,3 +164,4 @@ Swift Validator is written and maintained by Jeff Potter [@jpotts18](http://twit 3. Commit your changes `git commit -am 'Add some feature'` 4. Push to the branch `git push origin my-new-feature` 5. Create a new Pull Request +6. Make sure code coverage is at least 70% diff --git a/SwiftValidator/Core/ValidationError.swift b/SwiftValidator/Core/ValidationError.swift index a325a15..98ab4de 100644 --- a/SwiftValidator/Core/ValidationError.swift +++ b/SwiftValidator/Core/ValidationError.swift @@ -17,21 +17,9 @@ public class ValidationError: NSObject { /// the error message of the field public let errorMessage:String - /** - Initializes `ValidationError` object with a field and error. - - - parameter field: Validatable field that holds field. - - parameter errorMessage: String that holds error message. - - returns: An initialized object, or nil if an object could not be created for some reason that would not result in an exception. - */ - public init(field:ValidatableField, error:String){ - self.field = field - self.errorMessage = error - } - /** Initializes `ValidationError` object with a field, errorLabel, and errorMessage. - + - parameter field: Validatable field that holds field. - parameter errorLabel: UILabel that holds error label. - parameter errorMessage: String that holds error message. diff --git a/SwiftValidator/Core/Validator.swift b/SwiftValidator/Core/Validator.swift index f768d10..411316f 100644 --- a/SwiftValidator/Core/Validator.swift +++ b/SwiftValidator/Core/Validator.swift @@ -97,19 +97,7 @@ public class Validator { self.successStyleTransform = success self.errorStyleTransform = error } - - /** - This method is used to add a field to validator. - - - parameter field: field that is to be validated. - - parameter Rule: An array which holds different rules to validate against field. - - returns: No return value - */ - public func registerField(field:ValidatableField, rules:[Rule]) { - validations[field] = ValidationRule(field: field, rules: rules, errorLabel: nil) - fields[field] = field - } - + /** This method is used to add a field to validator. @@ -118,7 +106,7 @@ public class Validator { - parameter rules: A Rule array that holds different rules that apply to said field. - returns: No return value */ - public func registerField(field: ValidatableField, errorLabel:UILabel, rules:[Rule]) { + public func registerField(field: ValidatableField, errorLabel:UILabel? = nil, rules:[Rule]) { validations[field] = ValidationRule(field: field, rules:rules, errorLabel:errorLabel) fields[field] = field } diff --git a/SwiftValidator/Rules/EmailRule.swift b/SwiftValidator/Rules/EmailRule.swift index 152de99..e2609b1 100644 --- a/SwiftValidator/Rules/EmailRule.swift +++ b/SwiftValidator/Rules/EmailRule.swift @@ -13,7 +13,7 @@ import Foundation public class EmailRule: RegexRule { /// Regular express string to be used in validation. - static let regex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}" + static let regex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}" /** Initializes an `EmailRule` object to validate an email field.