validate method
Implementation
Future<Map<String, dynamic>> validate(dynamic value) async {
var res = <String, dynamic>{
'success': true,
'errors': <String>[],
'error': '',
'value': value,
'failed': false,
'options': initOptions != null ? await initOptions!(this) : [],
};
var errors = <String>[];
bool success = true;
if (_form?.isSubmitted() == true) {
for (var validator in validators) {
var result = await validator(value);
success &= result.success;
errors.addAll(result.errors);
}
}
res['errors'] = errors;
res['error'] = errors.isNotEmpty ? errors.first : '';
res['success'] = success;
res['failed'] = !success;
return res;
}