@@ -20,9 +20,9 @@ public class Validator {
2020 /// Dictionary to hold fields by their object identifiers
2121 private var fields = ValidatorDictionary < Validatable > ( )
2222 /// Variable that holds success closure to display positive status of field.
23- private var successStyleTransform : ( ( validationRule: ValidationRule ) -> Void ) ?
23+ private var successStyleTransform : ( ( _ validationRule: ValidationRule ) -> Void ) ?
2424 /// Variable that holds error closure to display negative status of field.
25- private var errorStyleTransform : ( ( validationError: ValidationError ) -> Void ) ?
25+ private var errorStyleTransform : ( ( _ validationError: ValidationError ) -> Void ) ?
2626 /// - returns: An initialized object, or nil if an object could not be created for some reason that would not result in an exception.
2727 public init ( ) { }
2828
@@ -44,13 +44,13 @@ public class Validator {
4444
4545 // let the user transform the field if they want
4646 if let transform = self . errorStyleTransform {
47- transform ( validationError : error)
47+ transform ( error)
4848 }
4949 } else {
5050 // No error
5151 // let the user transform the field if they want
5252 if let transform = self . successStyleTransform {
53- transform ( validationRule : rule)
53+ transform ( rule)
5454 }
5555 }
5656 }
@@ -65,22 +65,22 @@ public class Validator {
6565 - parameter field: Holds validator field data.
6666 - returns: No return value.
6767 */
68- public func validateField( field: ValidatableField , callback: ( error: ValidationError ? ) -> Void ) {
68+ public func validateField( _ field: ValidatableField , callback: ( _ error: ValidationError ? ) -> Void ) {
6969 if let fieldRule = validations [ field] {
7070 if let error = fieldRule. validateField ( ) {
7171 errors [ field] = error
7272 if let transform = self . errorStyleTransform {
73- transform ( validationError : error)
73+ transform ( error)
7474 }
75- callback ( error: error )
75+ callback ( error)
7676 } else {
7777 if let transform = self . successStyleTransform {
78- transform ( validationRule : fieldRule)
78+ transform ( fieldRule)
7979 }
80- callback ( error : nil )
80+ callback ( nil )
8181 }
8282 } else {
83- callback ( error : nil )
83+ callback ( nil )
8484 }
8585 }
8686
@@ -93,7 +93,7 @@ public class Validator {
9393 - parameter error: A closure which is called with validationError, an object that holds validation error data
9494 - returns: No return value
9595 */
96- public func styleTransformers( success success : ( ( validationRule: ValidationRule ) -> Void ) ? , error: ( ( validationError: ValidationError ) -> Void ) ? ) {
96+ public func styleTransformers( success: ( ( _ validationRule: ValidationRule ) -> Void ) ? , error: ( ( _ validationError: ValidationError ) -> Void ) ? ) {
9797 self . successStyleTransform = success
9898 self . errorStyleTransform = error
9999 }
@@ -106,7 +106,7 @@ public class Validator {
106106 - parameter rules: A Rule array that holds different rules that apply to said field.
107107 - returns: No return value
108108 */
109- public func registerField( field: ValidatableField , errorLabel: UILabel ? = nil , rules: [ Rule ] ) {
109+ public func registerField( _ field: ValidatableField , errorLabel: UILabel ? = nil , rules: [ Rule ] ) {
110110 validations [ field] = ValidationRule ( field: field, rules: rules, errorLabel: errorLabel)
111111 fields [ field] = field
112112 }
@@ -117,7 +117,7 @@ public class Validator {
117117 - parameter field: field used to locate and remove field from validator.
118118 - returns: No return value
119119 */
120- public func unregisterField( field: ValidatableField ) {
120+ public func unregisterField( _ field: ValidatableField ) {
121121 validations. removeValueForKey ( field)
122122 errors. removeValueForKey ( field)
123123 }
@@ -127,7 +127,7 @@ public class Validator {
127127
128128 - returns: No return value.
129129 */
130- public func validate( delegate: ValidationDelegate ) {
130+ public func validate( _ delegate: ValidationDelegate ) {
131131
132132 self . validateAllFields ( )
133133
@@ -145,10 +145,10 @@ public class Validator {
145145 - parameter callback: A closure which is called with errors, a dictionary of type Validatable:ValidationError.
146146 - returns: No return value.
147147 */
148- public func validate( callback: ( errors: [ ( Validatable , ValidationError ) ] ) -> Void ) -> Void {
148+ public func validate( _ callback: ( _ errors: [ ( Validatable , ValidationError ) ] ) -> Void ) -> Void {
149149
150150 self . validateAllFields ( )
151151
152- callback ( errors: errors . map { ( fields [ $1. field] !, $1) } )
152+ callback ( errors. map { ( fields [ $1. field] !, $1) } )
153153 }
154154}
0 commit comments