Kotlin and @Valid Spring Annotation
To apply the validation before entering the domain level. I added the validation to my code in a similar way as in Java/Spring. However, the test kept failing since it doesn't validate the values. When I searched for how it works in Kotlin/Spring. I have realised I should tell Kotlin explicitly about the annotation target using @Field like below It is because properties in Kotlin are constructed in many various ways unlike Java such as, field, getter & setter method, and constructor parameter. That's why when the validation annotation like @Email or @Size are just used Kotlin compiler gets confused. Is it for getter or for field or for parameter? So we need to clarify by using @field: @get: @param:, etc. Link: https://www.baeldung.com/kotlin/valid-spring-annotation