# valid_me_js

> a validator middleware

Latest version **1.0.9** (published 2019-03-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install valid_me_js
pnpm add valid_me_js
yarn add valid_me_js
bun add valid_me_js
```

## 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.9 |
| Published | 2019-03-21 |
| First published | 2018-11-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 163.7 KB |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | jojitoon |
| Maintainers | jojitoon |

## Links

- npm: https://www.npmjs.com/package/valid_me_js
- Repository: https://github.com/JojiAndela/validMejs
- Homepage: https://github.com/JojiAndela/validMejs#readme
- Issues: https://github.com/JojiAndela/validMejs/issues
- npm.io page: https://npm.io/package/valid_me_js

## Dependencies (1)

- [validator](https://npm.io/package/validator.md) ^10.9.0

## Recent versions

- 1.0.9 (latest) — 2019-03-21
- 1.0.8 — 2019-03-19
- 1.0.7 — 2019-01-11
- 1.0.6 — 2018-12-27
- 1.0.5 — 2018-12-27
- 1.0.4 — 2018-12-27
- 1.0.3 — 2018-11-28
- 1.0.2 — 2018-11-28
- 1.0.1 — 2018-11-19
- 1.0.0 — 2018-11-19

## README

# validMejs 
your middleware validating assistant. just super easy and flexible...

[![Build Status](https://www.travis-ci.org/JojiAndela/validMejs.svg?branch=develop)](https://www.travis-ci.org/JojiAndela/validMejs) [![Maintainability](https://api.codeclimate.com/v1/badges/5de500b6c2c9c3a07f35/maintainability)](https://codeclimate.com/github/JojiAndela/validMejs/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/5de500b6c2c9c3a07f35/test_coverage)](https://codeclimate.com/github/JojiAndela/validMejs/test_coverage)


# Installation
```bash
npm install valid_me_js
```
Also make sure that you have Node.js 6 or newer in order to use it.

# How to use

```javascript
import { middleware } from 'valid_me_js';

const signUpValidator = (req, res, next) => {
  const valid = middleware(req, res, next);
  valid
    .hasElement('email', 'Your Email')
    .hasElement('username', 'My Username')
    .hasElement('password', 'My password')
    .isEmail()
    .isLength('username', 3)
    .hasSpaces('username')
    .hasSpaces('password')
    .isLength('password', 8)
    .check();
};

const signInValidator = (req, res, next) => {
  const valid = middleware(req, res, next);
  valid
    .hasElement('email')
    .hasElement('password')
    .isEmail()
    .check();
};


export { signUpValidator, signInValidator };

```
then you can use it in the express router like this

``` javascript
import express from 'express';
import user from '../controllers/users';
import { signUpValidator, signInValidator } from '../middlewares/validator';

const { signup, login } = user;

const router = express.Router();

router.post('/', signInValidator, login);
router.post('/new', signUpValidator, signup);

export default router;
```
and get errors as 
```json
{
  "errors": [
      "tex is required",
      "myDate is an invalid date. Must not be later than today",
      "not making sense abi !!!",
      "length is bad",
      "no upper",
      "no number",
      "no special"
    ],
    "message": "Invalid Parameters"
}
```
# Changelog
Check the [GitHub Releases page](https://github.com/JojiAndela/validMejs/releases).

# Contributing
Bug reports and pull requests are welcome on GitHub at [https://github.com/jojiAndela/validmejs](https://github.com/jojiAndela/validmejs). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

# License
MIT License

# Code of Conduct
Everyone interacting in the NgBanks project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/%5BUSERNAME%5D/validmejs/blob/master/CODE_OF_CONDUCT.md).

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