more fixes
This commit is contained in:
parent
c665f547a6
commit
4c96cdda15
@ -26,16 +26,13 @@ public class RuleAnyValueChangedModel: RulesProtocol {
|
||||
return formField.baseValue != formField.formFieldValue()
|
||||
}
|
||||
|
||||
public func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool {
|
||||
|
||||
public func validate(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool {
|
||||
for formKey in fields {
|
||||
guard let formField = fieldMolecules[formKey] else { continue }
|
||||
|
||||
if isValid(formField) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ public protocol RulesProtocol: ModelProtocol {
|
||||
// Returns if a given field is valid according to the rule
|
||||
func isValid(_ formField: FormFieldProtocol) -> Bool
|
||||
|
||||
// Returns if a the rule is valid
|
||||
// Validates the rule and returns the result.
|
||||
func validate(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@ public extension RulesProtocol {
|
||||
return "\(RulesProtocol.self)"
|
||||
}
|
||||
|
||||
// Indiviidual rule can override the function to validate based on the rule type.
|
||||
func validate(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool {
|
||||
var valid = true
|
||||
for formKey in fields {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user