This commit is contained in:
Kevin G Christiano 2021-01-07 10:59:09 -05:00
parent 5c0e433193
commit c8d628da31
3 changed files with 7 additions and 5 deletions

View File

@ -320,7 +320,11 @@ import UIKit
model.updateUIDynamicError = { [weak self] in
MVMCoreDispatchUtility.performBlock(onMainThread: {
guard let self = self else { return }
self.updateValidation(model.isValid ?? false)
let validState = model.isValid ?? false
self.updateValidation(validState)
if !validState && model.shouldClearText {
self.text = ""
}
})
}

View File

@ -22,6 +22,7 @@ import Foundation
public var accessibilityIdentifier: String?
public var title: String?
public var feedback: String?
public var shouldClearText: Bool = false
public var dynamicErrorMessage: String? {
didSet {
isValid = dynamicErrorMessage?.isEmpty ?? true

View File

@ -449,10 +449,7 @@ import UIKit
let entryFieldModel = formValidator?.fields[fieldName] as? EntryFieldModel
else { continue }
if fieldError["clearText"] as? Bool ?? true {
entryFieldModel.text = ""
}
entryFieldModel.shouldClearText = fieldError["clearText"] as? Bool ?? true
entryFieldModel.dynamicErrorMessage = userError
}
}