Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save naimurhasan/8c999899882ba6b6fc60a258cb8cf7a9 to your computer and use it in GitHub Desktop.
Save naimurhasan/8c999899882ba6b6fc60a258cb8cf7a9 to your computer and use it in GitHub Desktop.
String simplifiedResponse(res){
String message = "";
res.forEach((k,v){
if(k == 'app_name' || k == 'success'){
return;
}
print(k);
String key = k == 'non_field_errors' ? '': k.replaceAll('_', ' ').toString();
if ( key == 'username') key = 'Phone';
message += 'Error for: '+key;
res[k].forEach((element){
message += '\n- '+element?.toString()?.replaceAll("username", "phone");
});
message += '\n\n';
});
return message;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment