title: fastify and ajv schema validation
body: <p>I am trying to validate the querystring parameter 'hccid' as shown below. Seems like the validation is not working for me. Can some one see what I am missing?</p>
  
  <pre><code>const fastify = require('fastify')({
    ajv: {
          removeAdditional: true,
          useDefaults:      true,
          coerceTypes:      true
      }
  });
  
  
  const schema = {
      querystring: {
         hccid: { type: 'string' }
      }
  };
  
  // Declare a route
   fastify.get('/hello', {schema}, function (request, reply) {
      const hccid = request.query.hccid;
      reply.send({ hello: 'world' })
  });
  
  // Run the server!
  fastify.listen(3000, function (err) {
  if (err) throw err
    console.log(`server listening on ${fastify.server.address().port}`)
  });
  </code></pre>
  
  <p>So with that code, I should get a schema validation exception when I call the service with a total new queryparam <code>abc</code> just like I shown below</p>
  
  <pre><code>http://localhost:3000/hello?abc=1
  </code></pre>
  
  <p>but there was no error. I got the response back <code>{"hello":"world"}</code></p>
  
  <p>I also tried removing the queryparam all together <code>http://localhost:3000/hello</code> </p>
  
  <p>and I still got <code>{"hello":"world"}</code></p>
  
  <p>so obviously the validation is not working. What is missing in my code? any help would be appreciated.</p>