[bv-dev] @Valid and group translation

Gunnar Morling gunnar at hibernate.org
Tue Dec 4 11:49:58 EST 2012


As no one else expressed an opinion on this, it seems like the final result
is 2:1 for specifying @ConvertGroup next to @Valid instead of within. I
guess I can live with that :)


2012/11/22 Hardy Ferentschik <hardy at hibernate.org>

> I agree with Emmanuel. I prefer the current syntax slightly more. Partly
> because we wanted to keep @Valid unchanged which I still like.
>
>
> --hardy
>
>
>
> On 22 Nov 2012, at 18:11, Emmanuel Bernard <emmanuel at hibernate.org> wrote:
>
> > I don't have any strong opinion. I slightly tend to like the existing
> > syntax which avoids some of the visual ugliness if one group rule is
> > defined but that's only a small advantage.
> >
> > Emmanuel
> >
> > On Thu 2012-11-22 16:45, Gunnar Morling wrote:
> >> Hi all,
> >>
> >> I'm looking for some input on an idea I got regarding group translation.
> >>
> >> When discussing the issue [1] we agreed that the groups to be converted
> >> should be specified with a new annotation instead of directly within
> >> @Valid. So that's what we have right now:
> >>
> >> public class User {
> >>
> >>  @Valid
> >>  @ConvertGroup(from = Default.class, to = BasicContact.class)
> >>  private final Contact contact = new Contact();
> >> }
> >>
> >> IIRC the primary reason was that this new annotation could be re-used in
> >> other places. IMO having a separate annotation is the right way, but
> WDYT
> >> about specifying this annotation within instead of next to @Valid:
> >>
> >>  @Valid(conversions=
> >>    @ConvertGroup(from = Default.class, to = BasicContact.class
> >>  )
> >>  private final Contact contact = new Contact();
> >>
> >> This would still allow to reuse the annotation, but avoids situations
> where
> >> @ConvertGroup is given without @Valid. It also makes very clear what's
> >> subject of the conversion (which might not be that obvious if the given
> >> element hosts some more annotations).
> >>
> >> On the down-side the "inner" annotation syntax is not that elegant,
> >> although it's actually shorter when specifying multiple conversions:
> >>
> >>  @Valid(conversions={
> >>    @ConvertGroup(from = Default.class, to = BasicContact.class),
> >>    @ConvertGroup(from = Full.class, to = FullContact.class)
> >>  })
> >>  private final Contact contact = new Contact();
> >>
> >> vs.
> >>
> >>  @Valid
> >>  @ConvertGroup.List({
> >>    @ConvertGroup(from = Default.class, to = BasicContact.class),
> >>    @ConvertGroup(from = Full.class, to = FullContact.class)
> >>  })
> >>  private final Contact contact = new Contact();
> >>
> >> This could be further mitigated by naming the attribute "value",
> although
> >> I'm a bit shy of allocating that default attribute.
> >>
> >> If we already discussed (and rejected) this particular approach, please
> >> ignore this mail, otherwise any feedback is appreciated :)
> >>
> >> --Gunnar
> >>
> >> [1] https://hibernate.onjira.com/browse/BVAL-208
> >
> >> _______________________________________________
> >> beanvalidation-dev mailing list
> >> beanvalidation-dev at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev
> >
> > _______________________________________________
> > beanvalidation-dev mailing list
> > beanvalidation-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/beanvalidation-dev
>
> _______________________________________________
> beanvalidation-dev mailing list
> beanvalidation-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/beanvalidation-dev/attachments/20121204/1cb3345a/attachment.html 


More information about the beanvalidation-dev mailing list