Is validation with JSR380 (or Spring validation) supported? #843
-
I can't seem to find any examples or docs about this but it seems elementary so I'm probably missing something 😅 I have, for example, the following setup: @Component
class MyAwesomeMutation : Mutation {
fun myAwesomeMutation(widget: Widget) = widget
}
@Validated
data class Widget(@get:Min(3) val id: Int) (also tried it with When I make a request for this mutation, it doesn't matter what I put in for the I'm not tied to JSR380 perse, it just seemed like an obvious choice but if a Spring validation component works just as well, that's fine too. I just need validation to happen 😄 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Solved! Turned out I needed to shift the annotations around a bit. This is the working solution: @Component
@Validated
class MyAwesomeMutation : Mutation {
fun myAwesomeMutation(@Valid widget: Widget) = widget
}
data class Widget(@get:Min(3) val id: Int) |
Beta Was this translation helpful? Give feedback.
-
FYI if you are using SpringBoot 2.3.x+ web starters no longer bring in the validation starter as a dependency - you will have to add it explicitly, e.g. in Gradle add following dependency
|
Beta Was this translation helpful? Give feedback.
Solved! Turned out I needed to shift the annotations around a bit. This is the working solution: