add to validator
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
c925323347
commit
05e2967131
@ -44,6 +44,29 @@ import MVMCore
|
||||
if let fieldKey = field.fieldKey {
|
||||
fields[fieldKey] = field
|
||||
}
|
||||
// add internal validators if needed
|
||||
if let field = field as? any FormFieldInternalValidatableProtocol {
|
||||
addInternalRules(field)
|
||||
}
|
||||
}
|
||||
|
||||
/// Adds additional Rules that are from another source
|
||||
private func addInternalRules(_ field: any FormFieldInternalValidatableProtocol) {
|
||||
if let internalRules = field.internalRules, !internalRules.isEmpty {
|
||||
|
||||
//find the group
|
||||
if let formGroup = formRules?.first(where: {$0.groupName == field.groupName}) {
|
||||
formGroup.rules.append(contentsOf: internalRules)
|
||||
} else {
|
||||
//create the new group
|
||||
let formGroup = FormGroupRule(field.groupName, internalRules, [])
|
||||
if var formRules {
|
||||
formRules.append(formGroup)
|
||||
} else {
|
||||
formRules = [formGroup]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Adds the form action to the validator.
|
||||
@ -72,7 +95,6 @@ import MVMCore
|
||||
if let validator = delegate?.formValidator {
|
||||
validator.delegate = delegate
|
||||
validator.insert(item)
|
||||
|
||||
// TODO: Temporary hacks, rewrite architecture to support this.
|
||||
_ = validator.validate()
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user