What does the example of query string validation look in the Fastify documentation? Like this:

const schema = {
  querystring: {
    name: { type: 'string' },
    excitement: { type: 'integer' }
  }
}

What is the problem? It is a lie!

The correct way of defining the schema of query parameters in this case (two values: “name” and “excitement”). Looks like this:

const querySchema = {
    schema: {
       querystring: {
         type: 'object',
           properties: {
             name: {
               type: 'string'
             },
             excitement: {
               type: 'integer'
             },
         }
     }
  }
}

Want to build AI systems that actually work?

Download my expert-crafted GenAI Transformation Guide for Data Teams and discover how to properly measure AI performance, set up guardrails, and continuously improve your AI solutions like the pros.

Additionally, if we want to make the name parameter mandatory, we add it to the array of required parameters:

const querySchema = {
    schema: {
       querystring: {
         type: 'object',
           properties: {
             name: {
               type: 'string'
             },
             excitement: {
               type: 'integer'
             },
         }
         required: ['name']
     }
  }
}

Want to build AI systems that actually work?

Download my expert-crafted GenAI Transformation Guide for Data Teams and discover how to properly measure AI performance, set up guardrails, and continuously improve your AI solutions like the pros.

Older post

Mental models: inversion

Solve the opposite problem to avoid stupidity.

Newer post

A comprehensive guide to putting a machine learning model in production using Flask, Docker, and Kubernetes

How to use Docker and Flask to put a Scikit model in production as a microservice.

Are you looking for an experienced AI consultant? Do you need assistance with your RAG or Agentic Workflow?
Book a Quick Consultation, send me a message on LinkedIn. Book a Quick Consultation or send me a message on LinkedIn

>