Are there any general suggestions on how to employ validations with Scala representation classes? I had hopes that this sort of this would work, but it seems to be completely ignored:
case class GiftCertificate(
@Range(min=1,max=2000) amount: Int,
@NotEmpty senderName: String,
@NotEmpty recipientName: String,
@NotEmpty recipientEmail: String,
...
)
and in the resource:
@PUT
def create(@Valid giftCertificate: GiftCertificate): Response = ...
From doing some reading about Hibernate, it appears like it will only work if you have a no-args constructor and getter/setters with annotations, which seems a little gross in Scala. I've also tried the approach of adding require()s to the constructor, but that produces a 500 error rather than 422. Right now I've defined a isValid method and I'm calling that as the first line of the create() method in the resource.
Does anyone have advice or recommendations on the best way to do this?
Thanks,
-kevin