# express-dee-validator

> Object fields validator for express framework

Latest version **3.0.2** (published 2025-12-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install express-dee-validator
pnpm add express-dee-validator
yarn add express-dee-validator
bun add express-dee-validator
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

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

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2025-12-20 |
| First published | 2017-03-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=22.0.0 |
| Dependencies | 2 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ilya Markevich |
| Maintainers | ilya.markevich |
| Keywords | validator, validation, check, valid, express |

## Links

- npm: https://www.npmjs.com/package/express-dee-validator
- Repository: https://github.com/ilya-markevich/node-express-validator
- Homepage: https://github.com/ilya-markevich/node-express-validator#readme
- Issues: https://github.com/ilya-markevich/node-express-validator/issues
- npm.io page: https://npm.io/package/express-dee-validator

## Dependencies (2)

- [dee-validator](https://npm.io/package/dee-validator.md) 2.2.0
- [@types/express](https://npm.io/package/@types/express.md) 5.0.6

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 3.0.2 (latest) — 2025-12-20
- 3.0.1 — 2025-12-17
- 3.0.0 — 2025-12-17
- 2.0.0 — 2021-08-08
- 1.1.1 — 2017-04-25
- 1.0.0 — 2017-04-10
- 0.3.0 — 2017-03-31
- 0.2.1 — 2017-03-31
- 0.2.0 — 2017-03-31
- 0.1.0 — 2017-03-31
- 0.0.1 — 2017-03-30

## README

# Express Dee Validator

[![npm](https://img.shields.io/npm/v/express-dee-validator.svg?maxAge=1000)](https://www.npmjs.com/package/express-dee-validator)
[![npm](https://img.shields.io/npm/dt/express-dee-validator.svg?maxAge=1000)](https://www.npmjs.com/package/express-dee-validator)

[Dee-validator](https://github.com/ilya-markevich/node-validator) port for Express framework.

# Table of contents
* [Migration to v2/v3](#migration-to-v2-v3)
* [Usage](#usage)
* [Author](#author)

# Migration to v2-v3

The [v1](https://github.com/ilya-markevich/node-express-validator/tree/v1.1.1) doesn't support async validators meaning the API is synchronous.
For migration to v2/v3, await `getErrors` and `hasErrors` methods.

# Usage

The middleware creates validator which contains three [dee-validators](https://github.com/ilya-markevich/node-validator) for `req.body`, `req.query` and `req.params` objects.
You can use each validator separately.

The example of code:
```javascript

const express = require('express');
const validator = require('express-dee-validator');

const app = express();
const customValidators = { // custom validators
    isTestString: {
        execute: value => value === 'test'
    }
}

app.use(validator(customValidators));

app.use(async (req, res, next) => {
    const validator = req.validator;
    const { bodyValidator, paramsValidator, queryValidator } = validator;

    console.log(validator.request); // you can get request object from the req.validator

    bodyValidator.property('name').isNotEmpty().isTestString();

    paramsValidator.property('id').isNotEmpty();

    queryValidator.property('test').optional().isUpperCaseString();

    if (await validator.hasErrors()) { // return true in case if no errors in body, params and query validators
      next({
        errors: await validator.getErrors() // here you can get errors from all of the validators
      });
    } else {
      next();
    }
})
```

You can find more details about creation of custom validators and a validator usage [here](https://github.com/ilya-markevich/node-validator).

Example of errors format:
``` javascript
{
    'name': {
        param: 'name',
        message: 'name should be a string',
        value: 0
    },
    'id': {
        param: 'id',
        message: 'id should be an integer',
        value: 'test'
    }
}
```

# Author
Ilya Markevich

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