Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-6380

Support for javax.validation annotations on @PathVariable, @RequestHeader, @RequestParam

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.0 RC2, 4.0.5
    • Fix Version/s: 5.1 Backlog
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      I thought this was already done, because support for controller method-parameter validation should be available for all parameters.

      I there a reason to exclude annotated (@RequestParam, etc.) method parameters? Is it not possible to validate primitive values?

      Simple example:
      For Paging-Support i need two request parameters: "start" & "size". "start" must have a positive value or 0 and "size" must have a positive value and also a maximum set.

        Issue Links

          Activity

          Hide
          benneq Benjamin M added a comment -

          +1

          Show
          benneq Benjamin M added a comment - +1
          Hide
          rstoya05-aop Rossen Stoyanchev added a comment -

          The underlying implementation for this, i.e. the ability to validate method parameters, has run into unexpected challenges. For a proper resolution unfortunately we'll have to revisit in 4.2, after SPR-11900 is resolved (see comments there for further detail).

          Show
          rstoya05-aop Rossen Stoyanchev added a comment - The underlying implementation for this, i.e. the ability to validate method parameters, has run into unexpected challenges. For a proper resolution unfortunately we'll have to revisit in 4.2, after SPR-11900 is resolved (see comments there for further detail).
          Hide
          rolltide roll tide added a comment -

          Is this still on roadmap?

          Show
          rolltide roll tide added a comment - Is this still on roadmap?
          Hide
          prattm@gmail.com Michael Pratt added a comment -

          +1, would love to see this as well.

          Show
          prattm@gmail.com Michael Pratt added a comment - +1, would love to see this as well.
          Hide
          rutvijr Rutvij Ravi added a comment - - edited

          In Spring 4.3, constraint annotations work on @PathVariable, @RequestHeader, and @RequestParam parameters when the Controller class is annotated with @Validated and a MethodValidationPostProcessor is registered as a Spring bean in the DispatcherServlet's application context.

          Is this issue for achieving this functionality without @Validated and MethodValidationPostProcessor?

          Since this functionality is usually needed in most projects, i think it makes sense for any constraints on these parameters to be validated by default.

          Show
          rutvijr Rutvij Ravi added a comment - - edited In Spring 4.3, constraint annotations work on @PathVariable, @RequestHeader, and @RequestParam parameters when the Controller class is annotated with @Validated and a MethodValidationPostProcessor is registered as a Spring bean in the DispatcherServlet's application context. Is this issue for achieving this functionality without @Validated and MethodValidationPostProcessor? Since this functionality is usually needed in most projects, i think it makes sense for any constraints on these parameters to be validated by default.

            People

            • Assignee:
              rstoya05-aop Rossen Stoyanchev
              Reporter:
              gbrehmer Gerrit Brehmer
              Last updater:
              Juergen Hoeller
            • Votes:
              55 Vote for this issue
              Watchers:
              56 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                7 weeks, 6 days ago