https://kotlinlang.org logo
Title
m

muliyul

04/28/2020, 8:20 AM
Hey guys I'm using javax bean validations in dropwizard and I'm getting badly formatted error messages. Anyone bumped into this or have a clue what (and if) I'm doing something wrong?
{
  "errors": [
    "updateAddress.arg1.county must not be empty"
  ]
}
d

David Eriksson

04/28/2020, 8:45 AM
Please provide more context
m

muliyul

04/28/2020, 8:46 AM
What would you like to know?
Here's my bean:
data class MyBean(
@field:NotEmpty val county: String? = null,
...
)
d

David Eriksson

04/28/2020, 8:49 AM
And your resource class?
m

muliyul

04/28/2020, 8:50 AM
My resource implements an interface that contains the
@Valid
annotation on the body parameter.
Concrete implmentation does not specify the annotation
Examples:
interface MyApi {
  fun update(@Valid updateAddress: MyBean): SomeResponse
}

class Resource: MyApi {
  override fun update(updateAddress: MyBean): SomeResponse { ... }
}
d

David Eriksson

04/28/2020, 8:59 AM
So is it the "arg1" in the error that you don't want?
m

muliyul

04/28/2020, 9:05 AM
Yes
d

David Eriksson

04/28/2020, 9:05 AM
What JVM version are you on?
m

muliyul

04/28/2020, 9:05 AM
Not sure what you mean? JDK 1.8
d

David Eriksson

04/28/2020, 9:06 AM
Yeah. I found this that might interest you: http://www.hackerav.com/?post=22460
m

muliyul

04/28/2020, 10:47 AM
Thanks but it's not what I was looking for
I was looking for something like ExceptionMapper. Thanks for the help!
d

David Eriksson

04/28/2020, 10:48 AM
Alright 😉