
Recently I found myself needing to validate fields in a Spring Boot controller written in Kotlin. Here's the code I ended up with:
The key is the @field in the data class. Without that, Kotlin will apply validation to the constructor parameters by default. This makes sense when you see it, but is less obvious when you're wading through your 10th Java based tutorial on Spring validation.
Hope this helps!
/Contact Us

Modernize your legacy with Focused
Get in touch