[bv-dev] Tightly coupled validation

Cemo cemalettin.koc at gmail.com
Fri May 25 10:06:29 EDT 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/beanvalidation-dev/attachments/20120525/c9eb58c9/attachment.html 


More information about the beanvalidation-dev mailing list