File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ public class Validator {
33
33
34
34
public func unregisterField( textField: UITextField ) {
35
35
validations. removeValueForKey ( textField)
36
+ errors. removeValueForKey ( textField)
36
37
}
37
38
38
39
public func validate( delegate: ValidationDelegate ) {
Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ class ValidatorTests: XCTestCase {
39
39
let UNREGISTER_VALIDATOR = Validator ( )
40
40
let UNREGISTER_RULES = [ Rule] ( )
41
41
42
+ let UNREGISTER_ERRORS_TXT_FIELD = UITextField ( )
43
+ let UNREGISTER_ERRORS_VALIDATOR = Validator ( )
44
+
42
45
override func setUp( ) {
43
46
super. setUp ( )
44
47
// Put setup code here. This method is called before the invocation of each test method in the class.
@@ -165,6 +168,18 @@ class ValidatorTests: XCTestCase {
165
168
XCTAssert ( UNREGISTER_VALIDATOR . validations [ UNREGISTER_TXT_FIELD] == nil , " Textfield should unregister " )
166
169
}
167
170
171
+ func testUnregisterError( ) {
172
+ UNREGISTER_ERRORS_VALIDATOR . registerField ( UNREGISTER_ERRORS_TXT_FIELD, rules: [ EmailRule ( ) ] )
173
+ UNREGISTER_ERRORS_TXT_FIELD . text = INVALID_EMAIL
174
+ UNREGISTER_ERRORS_VALIDATOR . validate { ( errors) -> Void in
175
+ XCTAssert ( errors. count == 1 , " Should come back with errors " )
176
+ }
177
+ UNREGISTER_ERRORS_VALIDATOR . unregisterField ( UNREGISTER_ERRORS_TXT_FIELD)
178
+ UNREGISTER_ERRORS_VALIDATOR . validate { ( errors) -> Void in
179
+ XCTAssert ( errors. count == 0 , " Should not come back with errors " )
180
+ }
181
+ }
182
+
168
183
// MARK: Validate Functions
169
184
170
185
func testValidateWithCallback( ) {
You can’t perform that action at this time.
0 commit comments