Is it possible to define an unsigned mapped Integer in Lift? I could not find anything about it.
class Project extends LongKeyedMapper[Project] with IdPK {
def getSingleton = Project
...
object budget extends MappedInt(this) // should be uns开发者_如何学编程igned!
...
}
Since there are not unsigned ints in scala or java, all you can do is write a runtime check. Something like this should do it: (haven't tested it)
object budget extends MappedInt(this) {
override def validations = {
((value:Int) =>
if (value < 0)
FieldError(fieldOwner, Text("Budget must not be negative"))::Nil
else
Nil)
:: super.validations
}
}
精彩评论