implemented new protocol

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-07-12 14:48:48 -05:00
parent 716550bf23
commit c925323347

View File

@ -6,7 +6,7 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
// Form fields are items can be interacted with. They have value, and may need to be validated.
import VDS
public protocol FormFieldProtocol: FormItemProtocol {
@ -36,6 +36,21 @@ public extension FormFieldProtocol {
}
}
public protocol FormFieldInternalValidatableProtocol: FormFieldProtocol {
associatedtype ValueType
var rules: [AnyRule<ValueType>]? { get set }
var internalRules: [RuleAnyModelProtocol]? { get }
}
extension FormFieldInternalValidatableProtocol {
public var internalRules: [RuleAnyModelProtocol]? {
guard let fieldKey else { return nil }
return rules?.compactMap{ rule in
return RuleVDSModel(field: fieldKey, rule: rule)
}
}
}
public class FormFieldValidity{
public var fieldKey: String
public var valid: Bool = true