equal rules
This commit is contained in:
parent
2ce25e340c
commit
21f38af0c3
@ -17,4 +17,24 @@ public class RuleEqualsModel: RulesProtocol {
|
|||||||
public func isValid(_ formField: FormFieldProtocol) -> Bool {
|
public func isValid(_ formField: FormFieldProtocol) -> Bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func isValid(_ formValidator: FormValidator) -> Bool {
|
||||||
|
var valid = true
|
||||||
|
var compareValue: AnyHashable?
|
||||||
|
for formKey in fields {
|
||||||
|
guard let formField = formValidator.formField(for: formKey) else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if compareValue == nil {
|
||||||
|
compareValue = formField.formFieldValue()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if compareValue != formField.formFieldValue(){
|
||||||
|
valid = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return valid
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user