Reputation: 139
I'm struggling with validation in String Boot.
I have the following class in Kotlin:
class ListBlock(
@field:Size(max = 5)
val style: String,
@field:Valid
@field:Size(max = 10)
val items: List<@Size(max = 50) String>
)
@field:Size(max = 5)
on style works fine by having size > 5
@field:Size(max = 10)
on items works fine by having more than 10 strings in the list
I don't get any errors if one of the strings in the list has a size larger than 50 characters.
Upvotes: 5
Views: 2055
Reputation: 5105
You have to compile to Java 1.8 or higher (for bytecode to support type annotations), and use Kotlin 1.3.70 or higher with the option -Xemit-jvm-type-annotations
for it to work...
See https://youtrack.jetbrains.com/issue/KT-13228
Upvotes: 6