Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for javax.validation.executable.ValidateOnExecution [SPR-10641] #15269

Closed
spring-projects-issues opened this issue Jun 8, 2013 · 3 comments
Labels
in: core status: bulk-closed

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Jun 8, 2013

Nick Williams opened SPR-10641 and commented

Bean Validation 1.1 added a @javax.validation.executable.ValidateOnExecution annotation meant to mark classes or methods whose method executions should be validated. This is in some ways quite synonymous with Spring's @Validated, but with broader implications.

@Validated is for classes and parameters only. @ValidateOnExecution applies to packages, classes, methods, and constructors (but not parameters). So, even if I configured the MethodValidationPostProcessor to look for @ValidateOnExecution by calling setValidatedAnnotationType it wouldn't match cases where the package or method was annotated.

Out of the box, if a MethodValidationPostProcessor is defined it seems like Spring should enable method validation if any of the following conditions are met:

  • The package is annotated @Validated or @ValidateOnExecution
  • The class is annotated @Validated or @ValidateOnExecution
  • The constructor is annotated @Validated or @ValidateOnExecution (assuming Spring is responsible for the instantiation of the bean)
  • The method is annotated @Validated or @ValidateOnExecution
  • The parameter is annotated @Validated (to preserve current functionality)

This will necessitate:

  • Expanding the @Target of @Validated to include packages, constructors, and methods
  • Changing MethodPostProcessor to look for both annotations on the package, class, or method instead of just @Validated on the class
  • Changing bean instantiation procedures to look for both annotations on the constructor

Affects: 4.0 M1

Issue Links:

  • #13812 @Validated should allow ElementType.METHOD target

1 votes, 4 watchers

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jun 10, 2013

Nick Williams commented

Note: In BV 1.1, this:

@ValidateOnExecute
@GroupSequence({Group1.class, Group2.class})
public class Whatever {

Is equivalent to this in Spring:

@Validate({Group1.class, Group2.class})
public class Whatever {

What I don't know is whether a BV implementation like Hibernate Validator picks this up and uses it when Validator#validate is called. I think probably not. It should be tested, but assuming I'm right this change should be made as well.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Dec 7, 2013

Nick Williams commented

Any chance to get this in Spring 4.0.0.Final to complete support for BV 1.1?

@spring-projects-issues spring-projects-issues added status: waiting-for-triage type: enhancement in: core labels Jan 11, 2019
@spring-projects-issues spring-projects-issues removed the type: enhancement label Jan 11, 2019
@rstoyanchev rstoyanchev added status: bulk-closed and removed status: waiting-for-triage labels Jan 11, 2019
@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 12, 2019

Bulk closing outdated, unresolved issues. Please, reopen if still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core status: bulk-closed
Projects
None yet
Development

No branches or pull requests

2 participants