From 1b391272c51e83ac31c132e0e4f21be78a63b57c Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 12 Jul 2024 14:45:20 -0500 Subject: [PATCH] updated model Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift index ca6f1e52..c96a8266 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift @@ -25,6 +25,7 @@ import VDS public var readOnly: Bool = false public var showError: Bool? public var errorMessage: String? + public var initialErrorMessage: String? public var fieldKey: String? public var groupName: String = FormValidator.defaultGroupName @@ -89,9 +90,11 @@ import VDS if let ruleErrorMessage = errorMessage, fieldKey != nil { self.errorMessage = ruleErrorMessage + } else { + self.errorMessage = initialErrorMessage } - self.isValid = valid + isValid = valid updateUI?() } @@ -103,6 +106,7 @@ import VDS id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) errorMessage = try typeContainer.decodeIfPresent(String.self, forKey: .errorMessage) + initialErrorMessage = errorMessage enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) ?? true required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required) ?? true readOnly = try typeContainer.decodeIfPresent(Bool.self, forKey: .readOnly) ?? false