refactored validation again
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
06d56fd70e
commit
c0b59694f2
@ -205,7 +205,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
|
|
||||||
open var defaultValue: AnyHashable? { didSet { setNeedsUpdate() } }
|
open var defaultValue: AnyHashable? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
open var required: Bool = false { didSet { setNeedsUpdate() } }
|
open var required: Bool = false { didSet { validate() } }
|
||||||
|
|
||||||
open var readOnly: Bool = false { didSet { setNeedsUpdate() } }
|
open var readOnly: Bool = false { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
@ -306,17 +306,17 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
/// Used to make changes to the View based off a change events or from local properties.
|
/// Used to make changes to the View based off a change events or from local properties.
|
||||||
open override func updateView() {
|
open override func updateView() {
|
||||||
super.updateView()
|
super.updateView()
|
||||||
updateRules()
|
|
||||||
validator = FormFieldValidator<EntryFieldBase>(field: self, rules: rules)
|
|
||||||
validator?.validate()
|
|
||||||
|
|
||||||
updateContainerView()
|
updateContainerView()
|
||||||
updateTitleLabel()
|
updateTitleLabel()
|
||||||
updateErrorLabel()
|
updateErrorLabel()
|
||||||
updateHelperLabel()
|
updateHelperLabel()
|
||||||
|
}
|
||||||
backgroundColor = surface.color
|
|
||||||
|
open func validate(){
|
||||||
|
updateRules()
|
||||||
|
validator = FormFieldValidator<EntryFieldBase>(field: self, rules: rules)
|
||||||
|
validator?.validate()
|
||||||
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -172,6 +172,7 @@ open class InputField: EntryFieldBase {
|
|||||||
.sink { [weak self] newText in
|
.sink { [weak self] newText in
|
||||||
print("textPublisher newText: \(newText)")
|
print("textPublisher newText: \(newText)")
|
||||||
self?.text = newText
|
self?.text = newText
|
||||||
|
self?.validate()
|
||||||
self?.sendActions(for: .valueChanged)
|
self?.sendActions(for: .valueChanged)
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
|
|||||||
@ -141,7 +141,7 @@ open class TextArea: EntryFieldBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
didSet {
|
didSet {
|
||||||
setNeedsUpdate()
|
validate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,5 +349,6 @@ extension TextArea: UITextViewDelegate {
|
|||||||
text = textView.text
|
text = textView.text
|
||||||
sendActions(for: .valueChanged)
|
sendActions(for: .valueChanged)
|
||||||
}
|
}
|
||||||
}
|
validate()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user