# express-single-value-validator

> Validate any value with (key,value) pair like resquest body, params, query, headers etc in express.

Latest version **1.0.6** (published 2022-02-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install express-single-value-validator
pnpm add express-single-value-validator
yarn add express-single-value-validator
bun add express-single-value-validator
```

## 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.6 |
| Published | 2022-02-20 |
| First published | 2022-02-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Emran Ibn Shayed |
| Maintainers | ibnshayed |
| Keywords | express, validator, nodejs |

## Links

- npm: https://www.npmjs.com/package/express-single-value-validator
- Repository: https://github.com/ibnshayed/express-single-value-validator
- Homepage: https://github.com/ibnshayed/express-single-value-validator#readme
- Issues: https://github.com/ibnshayed/express-single-value-validator/issues
- npm.io page: https://npm.io/package/express-single-value-validator

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2022-02-20
- 1.0.5 — 2022-02-19
- 1.0.4 — 2022-02-19
- 1.0.3 — 2022-02-19
- 1.0.2 — 2022-02-19
- 1.0.1 — 2022-02-19
- 1.0.0 — 2022-02-19

## README

# What is this?
Validate any value with (key,value) pair like resquest body, params, query, headers etc in express.
Validator only throw {message: "Validation Messages"}. So you have to catch the error message throw try/catch.

# How to install?
`npm i express-single-value-validator --save`

# How to use?
```javascript
const Validator = require('express-single-value-validator');

const demoFunction = (req, res) => {
	try{
		Validator("name", "Emran Ibn Shayed")
			.isString() // check type string
			.required() // must not be empty string, null or undefined
			.minLength(3) // minimum length of string 3 characters
			.maxLength(30) // maximum length of string 30 characters

		Validator("username", "ibnshayed")
			.isString()
			.required()
			.minLength(3)
			.maxLength(16)

		Validator("email", "ibnshayed@gmail.com")
			.isString()
			.isEmail() // check a valid email address

		Validator("password", "password1234")
			.isString()
			.required()
			.isPassword() // Validate a password with minimum eight characters, at least one letter and one number

		res.status(200).json({message: "something"});
	}catch(error){
		res.status(404).json(error);
	}
}

```

# All Methods
```javascript
Validator("key", value) // key must be a string
.isString() // check the typeof value is a string or not.
.isNumber() // check the typeof value is a number or not.
.isArray() // check the typeof value is a array or not.
.isObject() // check the typeof value is a object ({}) or not.
.required() // the value should not be empty string, null or undefined.
.minLength(number) // minimum length of string
.maxLength(number) // maximum length of string
.isEmail() // check a valid email address
.notNull() // value should not be null
.isPassword() // Validate a password with minimum eight characters, at least one letter and one number
.minNumber(number) // takes a number as a argument and value should be greater than or equal to this number
.maxNumber(number) // takes a number as a argument and value should be smaller than or equal to this number

```

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