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 {
3333
3434 public func unregisterField( textField: UITextField ) {
3535 validations. removeValueForKey ( textField)
36+ errors. removeValueForKey ( textField)
3637 }
3738
3839 public func validate( delegate: ValidationDelegate ) {
Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ class ValidatorTests: XCTestCase {
3939 let UNREGISTER_VALIDATOR = Validator ( )
4040 let UNREGISTER_RULES = [ Rule] ( )
4141
42+ let UNREGISTER_ERRORS_TXT_FIELD = UITextField ( )
43+ let UNREGISTER_ERRORS_VALIDATOR = Validator ( )
44+
4245 override func setUp( ) {
4346 super. setUp ( )
4447 // 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 {
165168 XCTAssert ( UNREGISTER_VALIDATOR . validations [ UNREGISTER_TXT_FIELD] == nil , " Textfield should unregister " )
166169 }
167170
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+
168183 // MARK: Validate Functions
169184
170185 func testValidateWithCallback( ) {
You can’t perform that action at this time.
0 commit comments