Validation Annotation doesn't work in Constructor


#1
@Entity
class Product(
        @Id
        @GeneratedValue
        val id: Int? = null
){
        @Email
        lateinit var name: String
        .....
}

Now when i tried to insert an invalid entity:

This will works, but now if I put it into the primary constructor:

class Product(
        @Id
        @GeneratedValue
        val id: Int? = null,
        @Email val name: String
)

The entity just get inserted without any validation:
noerror

Other annotations work just fine in the constructor (@Id, @ManyToMany …) but not this.


#2

I’ve resolved it from this:


https://kotlinlang.org/docs/reference/annotations.html#annotation-use-site-targets