From 39530fb7d63c310e442086b47702c3f48c200e7f Mon Sep 17 00:00:00 2001 From: Deniz Adalar Date: Thu, 12 May 2016 10:48:21 +0300 Subject: [PATCH] Remove duplicate (unnecessary) functions by using default values for optional parameters --- SwiftValidator/Core/ValidationError.swift | 12 ------------ SwiftValidator/Core/Validator.swift | 13 +------------ 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/SwiftValidator/Core/ValidationError.swift b/SwiftValidator/Core/ValidationError.swift index d01ef51..313c016 100644 --- a/SwiftValidator/Core/ValidationError.swift +++ b/SwiftValidator/Core/ValidationError.swift @@ -17,18 +17,6 @@ public class ValidationError: NSObject { /// the error message of the field public let errorMessage:String - /** - Initializes `ValidationError` object with a textField and error. - - - parameter textField: UITextField that holds textField. - - 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(textField:UITextField, error:String){ - self.textField = textField - self.errorMessage = error - } - /** Initializes `ValidationError` object with a textField, errorLabel, and errorMessage. diff --git a/SwiftValidator/Core/Validator.swift b/SwiftValidator/Core/Validator.swift index d095628..9af2f49 100644 --- a/SwiftValidator/Core/Validator.swift +++ b/SwiftValidator/Core/Validator.swift @@ -96,17 +96,6 @@ public class Validator { self.errorStyleTransform = error } - /** - This method is used to add a field to validator. - - - parameter textField: field that is to be validated. - - parameter Rule: An array which holds different rules to validate against textField. - - returns: No return value - */ - public func registerField(textField:UITextField, rules:[Rule]) { - validations[textField] = ValidationRule(textField: textField, rules: rules, errorLabel: nil) - } - /** This method is used to add a field to validator. @@ -115,7 +104,7 @@ public class Validator { - parameter rules: A Rule array that holds different rules that apply to said textField. - returns: No return value */ - public func registerField(textField:UITextField, errorLabel:UILabel, rules:[Rule]) { + public func registerField(textField:UITextField, errorLabel:UILabel? = nil, rules:[Rule]) { validations[textField] = ValidationRule(textField: textField, rules:rules, errorLabel:errorLabel) }