# data-hero

> Checks the validity of a data

Latest version **1.6.4** (published 2021-05-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install data-hero
pnpm add data-hero
yarn add data-hero
bun add data-hero
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.6.4 |
| Published | 2021-05-30 |
| First published | 2020-05-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 25 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Akinniyi Bolade |
| Maintainers | beedyboy |
| Keywords | validator, form, data, manipulation |

## Links

- npm: https://www.npmjs.com/package/data-hero
- Repository: https://github.com/beedyboy/data-hero
- Homepage: https://github.com/beedyboy/data-hero#readme
- Issues: https://github.com/beedyboy/data-hero/issues
- npm.io page: https://npm.io/package/data-hero

## Dependencies (1)

- [typescript](https://npm.io/package/typescript.md) ^3.9.3

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.6.4 (latest) — 2021-05-30
- 1.6.3 — 2021-05-29
- 1.6.2 — 2021-05-29
- 1.6.1 — 2021-05-29
- 1.2.9 — 2020-05-31
- 1.0.0 — 2020-05-31

## README

### `data-hero`

Ground-breaking objects and strings validation in typescript for Node applications.

## Version

1.6.1

## Motto

Be your own data hero

## License

MIT - See LICENSE.md

## Install

`yarn add data-hero`

## General usage

- On node:

```
$ npm install -g data-hero
```

## Validate an object

```ts
import dataHero from 'data-hero'

const schema = {
  email: {
    min: 14,
    email: true,
    message: 'Email is required'
  },
  password: {
    min: 8,
    max: 10,
    message: 'password is required'
  }
}
const data = {
  email: 'bolade@gmail.com',
  password: 'akin'
}
dataHero.validate(schema, data)
```

will return `false` if validation passes

## Single Validation

```
import dataHero from 'data-hero';
```

- Syntax
  dataHero.validator(field, rule, rule value)
- Example 1

```
dataHero.validator('pp', 'min', 2)

```
- Example 2

```
const schema = {
    email: {
      min: 14,
      email: true,
      message: 'Email is required'
    }
  }
  const data = {
    email: 'bolade@gmail.com'
  }
  dataHero.validate(schema, data);

```
- Example 3

```
  const schema = {
           
          password: {
            compare: {
              to: 'cpaswword'
            }, 
            message: 'password does not match'
          }
        }
        const data = { 
          password: 'Bolade',
          cpaswword: 'Bolades', 
        }
dataHero.validate(schema, data)

```

## Available rules

- min `to take integer value`
- max `to take integer value`
- isEmpty `to take boolean value`
- email `to take boolean value`
- isNumeric `to take boolean value`
- isBoolean `takes a boolean value`
- isTrue `takes a boolean value`
- isFalse `takes a boolean value`
- compare `use to compare two fields e.g. password`

**Note: Any rule applied above will return `false` is validation passes !**

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