Merge branch 'feature/vds-form-controls' into feature/atomic-vds-textArea
This commit is contained in:
commit
8ec3f01e2c
@ -56,6 +56,12 @@ import MVMCore
|
|||||||
|
|
||||||
//find the group
|
//find the group
|
||||||
if let formGroup = formRules?.first(where: {$0.groupName == field.groupName}) {
|
if let formGroup = formRules?.first(where: {$0.groupName == field.groupName}) {
|
||||||
|
var appendingRules = [RulesProtocol]()
|
||||||
|
internalRules.forEach { internalRule in
|
||||||
|
if !formGroup.rules.contains(where: { internalRule.type == $0.type && internalRule.fields == $0.fields } ) {
|
||||||
|
appendingRules.append(internalRule)
|
||||||
|
}
|
||||||
|
}
|
||||||
formGroup.rules.append(contentsOf: internalRules)
|
formGroup.rules.append(contentsOf: internalRules)
|
||||||
} else {
|
} else {
|
||||||
//create the new group
|
//create the new group
|
||||||
|
|||||||
@ -9,12 +9,15 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import VDS
|
import VDS
|
||||||
|
|
||||||
open class VDSRuleBase: RuleAnyModelProtocol {
|
open class VDSRuleBase: RuleAnyModelProtocol {
|
||||||
open var ruleId: String?
|
open var ruleId: String?
|
||||||
|
open var ruleType: String
|
||||||
open var errorMessage: [String : String]?
|
open var errorMessage: [String : String]?
|
||||||
open var fields = [String]()
|
open var fields = [String]()
|
||||||
public init(){}
|
public init(){
|
||||||
|
ruleType = Self.identifier
|
||||||
|
}
|
||||||
|
public var type: String { ruleType }
|
||||||
open func isValid(_ formField: any FormFieldProtocol) -> Bool {
|
open func isValid(_ formField: any FormFieldProtocol) -> Bool {
|
||||||
fatalError()
|
fatalError()
|
||||||
}
|
}
|
||||||
@ -26,7 +29,7 @@ public class RuleVDSModel<ValueType>: VDSRuleBase {
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
public var rule: AnyRule<ValueType>
|
public var rule: AnyRule<ValueType>
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializer
|
// MARK: - Initializer
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -34,8 +37,8 @@ public class RuleVDSModel<ValueType>: VDSRuleBase {
|
|||||||
public init(field: String, rule: AnyRule<ValueType>) {
|
public init(field: String, rule: AnyRule<ValueType>) {
|
||||||
self.rule = rule
|
self.rule = rule
|
||||||
super.init()
|
super.init()
|
||||||
|
self.ruleType = rule.ruleType
|
||||||
self.fields = [field]
|
self.fields = [field]
|
||||||
self.ruleId = "\(rule.self)-\(Int.random(in: 1...1000))"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
required init(from decoder: any Decoder) throws {
|
required init(from decoder: any Decoder) throws {
|
||||||
@ -57,3 +60,4 @@ public class RuleVDSModel<ValueType>: VDSRuleBase {
|
|||||||
return valid
|
return valid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user