This commit is contained in:
Suresh, Kamlesh 2021-08-05 17:16:51 -04:00
parent 2493ef51cc
commit 43bb9cde80
2 changed files with 10 additions and 2 deletions

View File

@ -50,7 +50,11 @@ public class RuleAnyRequiredModel: RulesProtocol {
if fieldValidity {
return (fieldValidity, previousValidity)
}
}
}
// if the rule breaks all fields should be set to false
fields.forEach { (formKey) in
previousValidity[formKey] = false
}
return (valid: false, fieldValidity: previousValidity)

View File

@ -32,7 +32,7 @@ public class RuleAnyValueChangedModel: RulesProtocol {
for formKey in fields {
guard let formField = fieldMolecules[formKey] else { continue }
var fieldValidity = isValid(formField)
// If past rule is invalid forr a field, the current rule should not flip the validity of a field
// If past rule is invalid for a field, the current rule should not flip the validity of a field
if let validity = previousFieldValidity[formKey], !validity, fieldValidity {
fieldValidity = false
}
@ -40,6 +40,10 @@ public class RuleAnyValueChangedModel: RulesProtocol {
if fieldValidity {
return (true, previousValidity)
}
}
// if the rule breaks all fields should be set to false
fields.forEach { (formKey) in
previousValidity[formKey] = false
}
return (valid: false, fieldValidity: previousValidity)