I'm using squeryl with playframework, and defined some entifies:
case class User(name:String, age:Int, ...) extends KeyedEntity[Long] {
val id = 0
}
The length of name
field defined as varchar(50)
in database.
Since we need to validate the values such as name
before saving to database, I have to validate them manually:
checkLengthOf(user.name, 50);
If there are a lot of more fields, I need to do a lot of validation manually:
checkLengthOf(user.field1, ???);
checkLengthOf(user.field2, ???);
checkLengthOf(user.field3, ???);
checkLengthOf(user.field3, ???);
checkLengthOf(user.field4, ???);
I want to know is there any simple way to do this?
When I was in Java, there are some orm frameworks provide some annotations to do the validation automatically, can I do the same with squeryl?