# express-enum-param

> Middleware for ensuring that a request parameter can only assume certain values

Latest version **0.1.0** (published 2018-12-13) · AGPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install express-enum-param
pnpm add express-enum-param
yarn add express-enum-param
bun add express-enum-param
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2018-12-13 |
| First published | 2018-12-13 |
| Weekly downloads | 0 |
| License | AGPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 35.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | nukeop |
| Maintainers | nukeop |
| Keywords | express |

## Links

- npm: https://www.npmjs.com/package/express-enum-param
- Repository: https://github.com/nukeop/express-enum-param
- Homepage: https://github.com/nukeop/express-enum-param#readme
- Issues: https://github.com/nukeop/express-enum-param/issues
- npm.io page: https://npm.io/package/express-enum-param

## Dependencies (2)

- [lodash.includes](https://npm.io/package/lodash.includes.md) ^4.3.0
- [express-http-errors-json](https://npm.io/package/express-http-errors-json.md) ^0.1.0

## Recent versions

- 0.1.0 (latest) — 2018-12-13

## README

# express-enum-param
Middleware for ensuring that a request parameter can only assume certain values

## Installation

```shell
$ npm install --save express-enum-param
```
Requires `body-parser`.

## Usage
```javascript
import enumParam from 'express-enum-param';

let allowedAnimals = ['crocodile', 'heron', 'turtle'];

router.get('/', 
	enumParam('animal', allowedAnimals),
	(req, res) => {
    res.status(200).send();
});
```

The above code will return a 400 HTTP status code and a message informing the client that this parameter can only have values from a certain list if `animal` is anything else than `crocodile`, `heron`, or `turtle`.

## About
### License
Copyright © 2018, [nukeop](https://github.com/nukeop).
Released under the [Affero GPL 3.0 License](LICENSE).

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