isValid method
Check if the form passes validation
Implementation
bool isValid() {
Map<String, dynamic> rules = getValidate;
Map<String, dynamic> ruleMap = {};
Map<String, dynamic> dataMap = {};
for (MapEntry rule in rules.entries) {
dynamic item = data(key: rule.key);
if (rule.value is FormValidator) {
if (rule.value.customRule != null) {
if (!rule.value.customRule!(item)) {
return false;
}
}
rule.value.setData(item);
dataMap[rule.key] = item is List ? item.join(", ") : item;
ruleMap[rule.key] = rule.value.toValidationRule();
} else {
dataMap[rule.key] = data(key: rule.key);
ruleMap[rule.key] = rule.value;
}
}
return NyValidator.isSuccessful(rules: ruleMap, data: dataMap);
}