# eagle-validator

> A modern javascript object validation NPM package available on npmjs.com

Latest version **1.0.8** (published 2019-10-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install eagle-validator
pnpm add eagle-validator
yarn add eagle-validator
bun add eagle-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.8 |
| Published | 2019-10-07 |
| First published | 2019-09-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 10.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Rumbiiha swaibu |
| Maintainers | swaibu |
| Keywords | js-validator, javascript, validation, validation.js, input-validation, input-validator, express-validator, validator, eagle-validator |

## Links

- npm: https://www.npmjs.com/package/eagle-validator
- Repository: https://github.com/swaibat/eagle-validator
- Homepage: https://github.com/swaibat/eagle-validator#readme
- Issues: https://github.com/swaibat/eagle-validator/issues
- npm.io page: https://npm.io/package/eagle-validator

## Dependencies (6)

- [esm](https://npm.io/package/esm.md) 3.2.25
- [nyc](https://npm.io/package/nyc.md) 14.1.1
- [chai](https://npm.io/package/chai.md) 4.2.0
- [mocha](https://npm.io/package/mocha.md) 6.2.0
- [chai-http](https://npm.io/package/chai-http.md) 4.3.0
- [coveralls](https://npm.io/package/coveralls.md) 3.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

- 1.0.8 (latest) — 2019-10-07
- 1.0.7 — 2019-10-07
- 1.0.6 — 2019-10-07
- 1.0.5 — 2019-09-22
- 1.0.4 — 2019-09-22
- 1.0.3 — 2019-09-22
- 1.0.2 — 2019-09-22
- 1.0.1 — 2019-09-22
- 1.0.0 — 2019-09-21

## README

# eagle-validator
[![Build Status](https://travis-ci.org/swaibat/eagle-validator.svg?branch=master)](https://travis-ci.org/swaibat/eagle-validator)
[![Coverage Status](https://coveralls.io/repos/github/swaibat/eagle-validator/badge.svg?branch=master)](https://coveralls.io/github/swaibat/eagle-validator?branch=master)

A modern javascript object validation node package available on npmjs.com

Basic usage
------------
a simple middleware for you
```js
import Check from 'eagle-validator';

export default function validator(req, res, next) {
  const valid = [
    new Check({ firstName: req }).str().req().min(2).max(20).alpha(),
    new Check({ phoneNumber: req }).str().req().min(2).num(),
    new Check({ email: req }).str().req().email(),
  ];
  const invalid = valid.find((e) => e.error);
  if (invalid) return res.status(400).send({ status:400, message:invalid.error });
  return next();
}
```
this will return simplified messages like:

#### for required field

```firstName  field is required```

```firstName should be a string```

```firstName should be greaterthan 2```

```firstName should be lessthan 19```

```firstName should be alphabetic```

Basic abbrevations used
------------

| abbrevations    | meaning                   | example           |
| --------------  |:-------------------------:| -----------------:|
| str()           | string                    | 'hello'           |
| req()           | required                  | 'world'           |
| min()           | minimum characters        |  any              |
| max(3)          | miximum characters        |  any              |
| number()        | should be a number        |  1-9              |
| num()           | only numbers in a string  | `0-9`             |
| alpha()         | should ba alphabets only  | `A-Z,a-z`         |
| alphaNum()      | mixture of alpha & nums   | `A-Z,a-z,0-9`     |
| bool()          | should be a boolean       | `true`            |
| email()         | stictly email address     | `rswaib@gmail.com`|

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