Created
June 30, 2021 06:27
-
-
Save naimurhasan/8c999899882ba6b6fc60a258cb8cf7a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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