Getting all errors for a result
See original GitHub issueCurrently a ValidationResult<T>
can be used to get errors for a specific field:
result[UserProfile::fullName]
Is there any way to get a map of all errors for a given validation (not a separate list for every field)?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
c# - How to return result with the list of errors from function
Show activity on this post. I have faced difficulties trying to return a result combined with the set of errors from function call....
Read more >Collecting All the Errors - Rust - tarquin-the-brave
Collecting All the Errors - Rust ... A common way to handle iterating over results, Result<T, E> , in Rust is to use...
Read more >How should I report multiple errors as a result of validation?
For such functions, it is important to report all errors at once, instead of stopping at the very first test at which validation...
Read more >Error handling: Exception or Result? - Enterprise Craftsmanship
In this post, we'll look at some practical examples of error handling. We will see whether it is better to use exceptions or...
Read more >Recoverable Errors with Result - The Rust Programming ...
To fix the error, you have two choices. One choice is to change the return type of your function to be compatible with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This to me is the single biggest blocker to making this useable in a nice way.
I use various methods of validation, and I encapsulate them in my own interfaces. I think validation is a core part of your logic and should not be embedded in your peripheral http/server frameworks.
For the same reason, I would never expose the data classes or exceptions of an internally used framework in my own API. I will always translate them to my own data types.
Right now, if I wanted to translate the error messages raised by this framework into my own errors, I would have to do some nasty iteration involving reflection on my own classes and their fields.
Please expose the collection of all errors (
Map<List<String>, List<String>>
).Not right now.
The main issue is, that I am unsure what the most useful representation would be. One Possibility would be the current internal representation which is
Map<List<String>, List<String>>
. E.g.Another would be a
Map<String, Any>
whereAny
might be anotherMap<String, Any>
or aList<String>
e.g.Yet another idea is to have
KProperty
instead ofString
as key and also anValidationError
class.