[bv-dev] Tightly coupled validation

Matt Benson mbenson at apache.org
Fri May 25 10:28:37 EDT 2012


Hi Cemo,
  The XML deployment descriptors can be used to add bind new
ConstraintValidator implementations to a given constraint type.  See
section 7.1.2 of the bean validation spec v1.0.

HTH,
Matt

On Fri, May 25, 2012 at 9:06 AM, Cemo <cemalettin.koc at gmail.com> wrote:
> 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
>



More information about the beanvalidation-dev mailing list