kotlin and @Valid Spring annotation

Seems Spring needs these annotations to be applied to a field. But Kotlin will apply these annotations to the constructor parameter. Use field: specifier when applying an annotation to make it apply to a field. The following code should work fine for you.

class SomeInfo(
    @field:NotNull
    @field:Pattern(regexp = Constraints.EMAIL_REGEX)
    var value: String
) {
    var id: Long? = null
}

Leave a Comment

404 Not Found

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.