revised for validatiod

This commit is contained in:
Kevin G Christiano 2021-01-06 16:58:51 -05:00
parent 515384fdd6
commit 0f9e6d4dae
3 changed files with 16 additions and 9 deletions

View File

@ -317,6 +317,13 @@ import UIKit
})
}
model.updateUIDynamicError = { [weak self] in
MVMCoreDispatchUtility.performBlock(onMainThread: {
guard let self = self else { return }
self.updateValidation(model.isValid ?? false)
})
}
title = model.title
feedback = model.feedback
isEnabled = model.enabled

View File

@ -22,7 +22,12 @@ import Foundation
public var accessibilityIdentifier: String?
public var title: String?
public var feedback: String?
public var dynamicErrorMessage: String?
public var dynamicErrorMessage: String? {
didSet {
isValid = false
updateUIDynamicError?()
}
}
public var errorMessage: String?
public var errorTextColor: Color?
public var enabled: Bool = true
@ -43,6 +48,8 @@ import Foundation
/// Temporary binding mechanism for the view to update on enable changes.
public var updateUI: ActionBlock?
public var updateUIDynamicError: ActionBlock?
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------

View File

@ -449,18 +449,11 @@ import UIKit
let entryFieldModel = formValidator?.fields[fieldName] as? EntryFieldModel
else { continue }
entryFieldModel.dynamicErrorMessage = userError
entryFieldModel.isValid = false
if fieldError["clearText"] as? Bool ?? true {
entryFieldModel.text = ""
}
DispatchQueue.main.async { [self] in
if let view = UIView.findByAccessibility(identifier: fieldName), let moleculeView = view as? MoleculeViewProtocol {
moleculeView.set(with: entryFieldModel, delegateObjectIVar, nil)
}
}
entryFieldModel.dynamicErrorMessage = userError
}
}