Using javax.validation.constraints @Annotations in GOSU
185 views
Skip to first unread message
Will Hu
unread,
May 15, 2017, 6:05:13 AM5/15/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gosu-lang
Hi Guys...
I am trying to use some data validation annotations in gosu DTO model..
@Length(min=1, max=9) publicvar lastName:String
It looks like it does not support doing like @Length(min=1, max=9) or @Size(min=1).
Howver it works with:
@Max(9) publicvar size :int
@NotNull publicvar lastName :String
Wondering what I may do to use @Length, @Size, etc?
Thanks.
Kyle Moore
unread,
May 15, 2017, 10:02:36 AM5/15/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gosu-lang
Hi Will. When setting arguments to annotations you need to use named argument syntax, like this:
@Length(:min=1,:max=9) publicvar lastName :String
Also note that if an annotations wants an array of Strings or primitives, make sure to wrap the values with the list initializer {} and they'll be coerced to an array.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gosu-lang
Thanks Kyle, sorry our current version does not support named argument syntax for annotations.. (But it works for functions)..ANyway. I may rebuild a gosu version annotations to implement @Length functionality. Thanks very much!