[bv-dev] Tightly coupled validation

Cemo cemalettin.koc at gmail.com
Sun May 27 16:11:29 EDT 2012


Thanks guys. Especially the already discussed topic really helped me the
see points. I am glad that at least I have one working solution but maybe
finalizing discussed topics would be great. We rely on more and more Bean
Validation by utilizing extensive database connections. Alternatives to XML
binding -  personally believe that it is a little bid error prone - will
be inevitable after the wide adaption of the bean validation among
frameworks such as Spring, Guice etc. Definitely having a simpler way for
seperating constraint annotation and constraint validation into the modules
will be mandatory. Despite of a great summary for possible solutions by
Emmanuel, It can be great to revisit this topic.

Thanks



On 27 May 2012 13:44, Gunnar Morling <gunnar at hibernate.org> wrote:

> Hi,
>
> If I understand you correctly, your question is related to the cyclic
> dependency between constraint annotations and constraint validators.
>
> As of BV 1.0 I don't see another way than using an XML constraint
> mapping as already suggested by Matt and Hardy.
>
> There was a discussion on the subject within the EG a while ago [1],
> but we didn't really come to a conclusion back then. One idea was to
> employ the service loader mechanism to contribute validator
> implementations [2]. I still think that's quite promising.
>
> --Gunnar
>
> [1]
> http://lists.jboss.org/pipermail/beanvalidation-dev/2011-October/000064.html
> [2]
> http://lists.jboss.org/pipermail/beanvalidation-dev/2011-October/000075.html
>
>
>
> 2012/5/25 Cemo <cemalettin.koc at gmail.com>:
> > Hi,
> >
> > I am not sure is this already discussed or not but currently I believe
> that
> > validation spec is very strict about coupling.
> >
> > For example at interface level validator is declared by Interface.
> >
> > @Constraint(validatedBy = EmailValidator.class)
> > @Retention(RUNTIME)
> > public @interface Email
> >
> >
> > And for the part EmailValidation part, we are referring again our Email
> > Interface
> >
> > public class EmailValidator implements ConstraintValidator<Email, String>
> >
> > What I think is this contract is little tight. And because of the strict
> > contract, splitting validation by its interface is not possible.
> >
> > And let me to clarify my use case too.
> >
> > I have splitted my domain, validation and web projects (Web1, Web2, Web3)
> > and using spring extensively.
> >
> > Domain (Has no dependency)
> > Validation (Has dependency to validation spec and optionally Spring
> > Framework. For example, It can validate an uniqueEmail field by checking
> > database. )
> > Web's (Has dependency to validation and domain)
> >
> > My domain needs dependency to validation for validating it but it means
> also
> > depending spring and all other stuffs regarding Database validations.
> What I
> > want to split Validation contract to interfaces and implementations.
> > Interfaces could be declared at domain and implementations reside at
> > validation module. Validation module has a dependency to domain
> perfectly.
> >
> > I have checked builtin constraints implementations but it seems there is
> not
> > any extensible points for it.
> >
> > What are your suggestions for this situation?
> >
> > Thanks
> >
> >
> > _______________________________________________
> > 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/20120527/7ee16350/attachment.html 


More information about the beanvalidation-dev mailing list