# validation-helpers

> validation-helpers

Latest version **1.1.1** (published 2019-12-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install validation-helpers
pnpm add validation-helpers
yarn add validation-helpers
bun add validation-helpers
```

## 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.1.1 |
| Published | 2019-12-19 |
| First published | 2019-03-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 407.8 KB |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | mohamedGamalAbuGalala |
| Maintainers | bugalala |
| Keywords | validation helpers, validation helper, validations, validation, validate, helpers, helper, request validation, request validations, express validation, express validations, validator, validators |

## Links

- npm: https://www.npmjs.com/package/validation-helpers
- Repository: https://github.com/mohamedGamalAbuGalala/validation-helpers
- Homepage: https://github.com/mohamedGamalAbuGalala/validation-helpers#readme
- Issues: https://github.com/mohamedGamalAbuGalala/validation-helpers/issues
- npm.io page: https://npm.io/package/validation-helpers

## Dependencies (2)

- [moment](https://npm.io/package/moment.md) ^2.24.0
- [validator](https://npm.io/package/validator.md) ^12.1.0

## Alternatives

- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@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

## Recent versions

- 1.1.1 (latest) — 2019-12-19
- 1.1.0 — 2019-12-19
- 0.4.0 — 2019-05-27
- 1.0.4-beta — 2019-05-21
- 1.0.3-beta — 2019-04-23
- 1.0.2-beta — 2019-04-23
- 1.0.1-beta — 2019-04-23
- 1.0.0-beta — 2019-04-23
- 0.1.2 — 2019-04-22
- 0.1.1 — 2019-04-22
- 0.1.0 — 2019-04-22
- 0.0.6 — 2019-04-17
- 0.0.5 — 2019-04-16
- 0.0.4 — 2019-04-16
- 0.0.3 — 2019-03-28
- … 4 more at https://npm.io/package/validation-helpers/versions

## README

# [Validation-helpers](https://www.npmjs.com/package/validation-helpers)

Validation helpers makes you validate your body of request or any value you want with a simple set of rules with the help of [Validator](https://www.npmjs.com/package/validator) and other simple packages.

## Usage

```js
const { errors, isValid } = validationHelpers(value, rules);
```

`rules` need to be like

```js
new Builder().required().isMember(["foo", "bla", "hi"]).value;
```

## Example

```js
const { errors, isValid } =
        validationHelpers('hello',
              new Builder()
              .required()
              .isMember(['foo', 'bla', 'hi'],'Not a valid member')
              .value;
);
```

This will throw an error for isMember rule with a simple message `'Not a valid member'`.

Or the **old way** rules can be written with array of objects.

```js
[
  { type: Rules.REQUIRED },
  { type: Rules.IS_MEMBER, array: ["foo", "bla", "hi"] }
];
```

`type` must be a valid type from validationHelpers.Types every type may have a second property must be passed like

`{ type: Rules.IS_MEMBER, array: ['foo', 'bla', 'hi']`

## TODO

1. Write readable usage example.
2. Write Unit test for all cases.
3. Integrate with CI.

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