> For the complete documentation index, see [llms.txt](https://blueprint.onehilltech.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://blueprint.onehilltech.com/quick-start/my-first-application/validating-and-sanitizing-input.md).

# Validating & Sanitizing Input

One of the most important lesson you learn with implementing API service is that you never trust the input your receive. You must *validate the input*, which means check that the input passes constraints, and *sanitize the input*, which means converting it from a text-based value to its concrete representation, such as a `Date` or a `String`.

Blueprint facilitates validating and sanitizing the input on the controller action. The controller action has the option of using the `schema` property to perform static validation. The value of the `schema` property is a [schema definition from express-validator](https://express-validator.github.io/docs/schema-validation.html). You can also use the `validate()` method, which is used to perform dynamic and asynchronous validation.

In our `super-rentals` example, we only need to validate the id parameter for `getOne()`, `update()`, and `delete()`. The schema for each method will be the same so we are only going to show the schema for the `getOne()` method.&#x20;

{% code title="app/controllers/rental.js" %}

```javascript
module.exports = ResourceController.extend ({
  // ...
  
  getOne () {
    return Action.extend ({
      // express-validator schema
      schema: {
        [this.id]: {
          in: 'params',
          optional: false,
        }
      },
  
      execute (req, res) {
        const { rentalId } = req.params;
        const rental = this.controller.rentals.get (rentalId);
  
        if (rental) {
          res.status (200).json ({ data: [rental] });
        }
        else {
          res.sendStatus (404);
        }
      }
    })
  }
});  
```

{% endcode %}

�


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://blueprint.onehilltech.com/quick-start/my-first-application/validating-and-sanitizing-input.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
