Created
September 26, 2024 04:37
-
-
Save PhantomKnight287/71d9d2c4f14d92cef79ea71d87e341d5 to your computer and use it in GitHub Desktop.
Helper to get error message from a class validator error
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 getErrorMessage(dynamic error, [String? message]) { | |
| if (error is String) { | |
| return error; | |
| } else if (error is Map) { | |
| if (error['message'] is List) { | |
| return error['message'][0]; | |
| } else { | |
| return error['message']; | |
| } | |
| } else { | |
| return message ?? 'Something went wrong'; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment