bean validation not working with kotlin (JSR 380)

后端 未结 2 1779
庸人自扰
庸人自扰 2021-02-07 02:41

so first of all i could not think of a better title for this question so i\'m open for changes.

I am trying to validate a bean using the bean validation mechanism (JSR-3

2条回答
  •  梦谈多话
    2021-02-07 03:01

    Try adding ? like this:

    data class User(
        @field:Valid
        @field:NotEmpty
        var roles: MutableSet<@NotNull Role?> = HashSet()
    )
    

    Then the kotlin compiler should realise roles could be null, and it might honor the validation, I know little about JSR380 so i'm just guessing though.

提交回复
热议问题