# @hattmo/ajvmiddleware

> Middleware for express that validates json bodies in requests using ajv

Latest version **1.0.1** (published 2019-08-23) · GPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @hattmo/ajvmiddleware
pnpm add @hattmo/ajvmiddleware
yarn add @hattmo/ajvmiddleware
bun add @hattmo/ajvmiddleware
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-08-23 |
| First published | 2019-08-23 |
| Weekly downloads | 0 |
| License | GPL-3.0-or-later |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 36.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Hattmo |
| Maintainers | hattmo |

## Links

- npm: https://www.npmjs.com/package/@hattmo/ajvmiddleware
- npm.io page: https://npm.io/package/@hattmo/ajvmiddleware

## Dependencies (1)

- [ajv](https://npm.io/package/ajv.md) ^6.10.2

## Recent versions

- 1.0.1 (latest) — 2019-08-23
- 1.0.0 — 2019-08-23

## README

# AJVMIDDLEWARE

## About

Middleware for express that validates json bodies in requests using ajv

## Installation

```bash

npm i @hattmo/ajvmiddleware

```

## Example

```node

import { Router } from "express";
import ajvmiddleware from "@hattmo/ajvmiddleware";

const schema = {
  $schema: "http://json-schema.org/draft-07/schema#",
  type: "object",
  required: [
    "name",
    "age",
  ],
  properties: {
    name: {
      type: "string",
    },
    age: {
      type: "integer",
    },
  },
};

const route = Router();

route.post("/submit", ajvmiddleware(schema), (req, _res, next) => {
  console.log(`${req.body.name} is ${req.body.age} years old`);
  next()
});

export default route;

```

## Author

Designed and maintained by [Matthew Howard](https://www.linkedin.com/in/matthew-howard-4013ba87/).

Support me with a [donation](https://www.paypal.me/hattmo)!

---
_Source: https://npm.io/package/@hattmo/ajvmiddleware · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
