Merge pull request #114 from dadalar/OptionalFunctionParameters
Remove duplicate functions by using default values
This commit is contained in:
commit
9749d9d670
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue