2 years ago
#44340

Elliott Barinberg
Is there a way to validate @Column annotation constraints in Kotlin
Given an Entity with the following definition:
@Entity
class myObject (
@Column(name = colName, nullable = false, length = 20)
var myCol: String
) : AbstractJpaPersistableWithId<Int> {
companion object {
const val colName = "myCol"
}
}
Then I want to create a dummy object like so:
val myObj = myObject()
myObj.name = "This is a string which is longer than 20 characters"
Is it then possible to validate the object in some way and get constraint violation results? In this case it would say the name is too long.
Something like:
val violations = myObj.validate()
Thanks in advance.
spring
kotlin
validation
bean-validation
hibernate-validator
0 Answers
Your Answer