chkal / mvc-spec-migration-test

0 stars 0 forks source link

Discuss the need of @ValidateOnExecution #57

Open chkal opened 9 years ago

chkal commented 9 years ago

Original issue MVC_SPEC-54 created by lefloh:

Currently it's necessary to disable bean validation to ensure MVC can validate and call a controller method if validation fails. This can be done globally in the validation.xml or per @ValidateOnExecution annotation on every method.

Disabling BV globally has the disadvantage that you disable it also for non MVC controllers. Using the annotation is not very self explanatory:

@ValidateOnExecution(type = ExecutableType.NONE) 
public Response formPost(@Valid @BeanParam FormDataBean form) {} 

It's hard to guess why something must be valid but should not be validated. Not everybody will understand the background or read the spec.

Would a custom annotation like @MvcValidated make sense? It would at least make it clear that something MVC related happens independent of the BV settings.

chkal commented 9 years ago

Comment by Christian Kaltepoth:

I basically agree that having to use @ValidateOnExecution isn't very nice. And the reason why users have to add this annotation is hard to understand.

However, I currently see no way to fix this on the MVC side. :(