|
9 | 9 | import Foundation |
10 | 10 | import UIKit |
11 | 11 |
|
12 | | -@objc protocol ValidationDelegate { |
| 12 | +@objc public protocol ValidationDelegate { |
13 | 13 | func validationWasSuccessful() |
14 | 14 | func validationFailed(errors:[UITextField:ValidationError]) |
15 | 15 | } |
16 | 16 |
|
17 | | -class Validator { |
| 17 | +public class Validator { |
18 | 18 | // dictionary to handle complex view hierarchies like dynamic tableview cells |
19 | | - var errors:[UITextField:ValidationError] = [:] |
20 | | - var validations:[UITextField:ValidationRule] = [:] |
| 19 | + public var errors:[UITextField:ValidationError] = [:] |
| 20 | + public var validations:[UITextField:ValidationRule] = [:] |
21 | 21 |
|
22 | | - init(){} |
| 22 | + public init(){} |
23 | 23 |
|
24 | 24 | // MARK: Using Keys |
25 | 25 |
|
26 | | - func registerField(textField:UITextField, rules:[Rule]) { |
| 26 | + public func registerField(textField:UITextField, rules:[Rule]) { |
27 | 27 | validations[textField] = ValidationRule(textField: textField, rules: rules, errorLabel: nil) |
28 | 28 | } |
29 | 29 |
|
30 | | - func registerField(textField:UITextField, errorLabel:UILabel, rules:[Rule]) { |
| 30 | + public func registerField(textField:UITextField, errorLabel:UILabel, rules:[Rule]) { |
31 | 31 | validations[textField] = ValidationRule(textField: textField, rules:rules, errorLabel:errorLabel) |
32 | 32 | } |
33 | 33 |
|
34 | | - func validateAll(delegate:ValidationDelegate) { |
| 34 | + public func validateAll(delegate:ValidationDelegate) { |
35 | 35 |
|
36 | 36 | for field in validations.keys { |
37 | 37 | if let currentRule:ValidationRule = validations[field] { |
|
0 commit comments