Commit f5ea7a80 by Orkhan Alikhanov

Changed `autoValidateOnlyIfErrorIsShownOnce` flag to AutoValidationType case

parent e34e5031
......@@ -15,7 +15,6 @@ open class ErrorTextFieldValidator {
open weak var textField: ErrorTextField?
open var autoValidationType: AutoValidationType = .default
open var autoValidateOnlyIfErrorIsShownOnce = true
open var isErrorShownOnce = false
public init(textField: ErrorTextField) {
......@@ -30,14 +29,16 @@ open class ErrorTextFieldValidator {
@objc
private func checkIfErrorHasGone() {
guard let textField = textField else { return }
if autoValidateOnlyIfErrorIsShownOnce && !isErrorShownOnce { return }
switch autoValidationType {
case .none: break
case .custom(let closure):
closure(textField)
case .default:
textField.isValid()
guard isErrorShownOnce else { return }
textField.isValid()
case .always:
textField.isValid()
}
}
......@@ -67,6 +68,7 @@ open class ErrorTextFieldValidator {
public enum AutoValidationType {
case none
case `default`
case always
case custom((ErrorTextField) -> Void)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment