more fixes

This commit is contained in:
Suresh, Kamlesh 2020-04-10 17:56:08 -04:00
parent c665f547a6
commit 4c96cdda15
2 changed files with 4 additions and 6 deletions

View File

@ -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
}
}

View File

@ -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 {