4

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.

lepsch
  • 8,927
  • 5
  • 24
  • 44
Aslak
  • 109
  • 8

1 Answers1

3

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

Per Huss
  • 4,755
  • 12
  • 29