title: Validate Variable Parameters In URL Path and Query Parameters using Webargs Flaskparser
body: <p>I'm trying to validate all data being sent to my api. My url structure contains a variable within it, <code>/api/v2/users/&lt;string:username&gt;/collections/</code>, as well as actual query string parameters, all of which need to be passed through validation.</p>
  
  <p>The full url looks like this: 
  <code>https://127.0.0.1:5000/api/v2/users/&lt;string:username&gt;/collections/?page=5&amp;per_page=10</code></p>
  
  <p>The two variables that need to be validated are: <code>username</code> <code>page</code>, and <code>per_page</code>. The easy solution would be to change my url structure, but I'm wondering if it's possible to accomplish what I need and keep the simplicity that I currently have without adding additional validation within my resource class. If it's possible, how do you do it?</p>
  
  <pre><code>class UserCollections(Resource):
      @use_args({
          'username': fields.Str(
              required=True,
              validate=username_length,
              error_messages=dict(
                  required='Username is required.',
                  validator_failed='Username can be between 3 and 25 characters.',
              )
          ),
          'page': fields.Int(
              #required=True,
              missing=1,
              validate=feed_minmax_pages,
              error_messages=dict(
                  validator_failed='Maximum number of pages reached.',
              )
          ),
          'per_page': fields.Int(
              #required=True,
              missing=5,
              validate=validate.Range(min=5,max=25),
              error_messages=dict(
                  validator_failed='Test number of pages reached.',
              )
          ),
      }, locations=('query',))
  
      def get(self, args, username):
          print(args)
          print(username)
  
          return default_schema(
              data={},
              http_status=200
          )
  </code></pre>
  
  <p>When I run the code, I get a validation error for <code>username</code> because it doesn't exist in the args.</p>