Closed silversoul93 closed 4 years ago
@silversoul93 Thanks for your contribution.
I've just released version 0.2.0 with an implementation I had done a while back but haven't been able to publish due to the recent changes around kotlin MPP setup.
There is now a public errors
property on the ValidationResult
which gives you access to the ValidationErrors
. You can convert that to the map that you have in mind by declaring your own extension on ValidationResult:
fun ValidationResult<*>.errorMap(): Map<String, List<String>> {
return errors.groupBy({ it.dataPath.removePrefix(".") }) { it.message }
}
note the key transform using it.dataPath.removePrefix(".")
because the dataPath typically starts with a .
.