Does scala suport JSR-303 validation? -
does scala supports jsr-303 validation?
if does - please write example?
if not - there workarounds run jsr-303 validation on scala classes?
there news , bad news.
the news can utilize jsr-303 annotations in scala code no problems.
here illustration previous project of mine, of annotations jsr-303 annotations, of them out of box, of them custom.
@messagesvalid class messages { @notempty @valid private var msgs: java.util.list[deliveredmessage] = _ def messages = msgs.asscala @channelvalid var channel: string = _ var emailfrom: string = _ var emailreplyto: string = _ @publishatvalid var publishat: string = _ } note how msgs collection java.util.list. needs java collection @notempty , @valid work. it's easy plenty expose field scala collection using javaconverters.
the bad news cannot create jsr-303 annotation using scala. must write annotations using java. need have mixed scala/java project if want write custom jsr-303 annotations.
there old bug (bug #32!) in scala bug tracker back upwards these types of annotations closed won't fix. please vote anyway.
scala bean-validation
No comments:
Post a Comment