# @iryu54/object-validity

> ![coverage](./badge.svg)

Latest version **1.4.3** (published 2021-04-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @iryu54/object-validity
pnpm add @iryu54/object-validity
yarn add @iryu54/object-validity
bun add @iryu54/object-validity
```

## 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.4.3 |
| Published | 2021-04-26 |
| First published | 2019-06-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 26.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | clabroche |
| Maintainers | iryu54 |

## Links

- npm: https://www.npmjs.com/package/@iryu54/object-validity
- npm.io page: https://npm.io/package/@iryu54/object-validity

## Dependencies (2)

- [type-detect](https://npm.io/package/type-detect.md) ^4.0.8
- [@iryu54/badge-audit](https://npm.io/package/@iryu54/badge-audit.md) ^1.0.1

## Recent versions

- 1.4.3 (latest) — 2021-04-26
- 1.4.2 — 2021-04-26
- 1.4.1 — 2021-04-26
- 1.4.0 — 2019-08-27
- 1.2.2 — 2019-06-13
- 1.2.1 — 2019-06-13
- 1.1.1 — 2019-06-12
- 1.0.7 — 2019-06-11
- 1.0.6 — 2019-06-11
- 1.0.4 — 2019-06-10
- 1.0.3 — 2019-06-09
- 1.0.5 — 2019-06-09
- 1.0.2 — 2019-06-09
- 1.0.0 — 2019-06-09

## README

# Object-validity
![coverage](./badge.svg)

[![Actions Status](https://github.com/clabroche/object-validity/workflows/Node%20CI/badge.svg)](https://github.com/clabroche/object-validity/actions)

## Install
``` bash 
npm i @iryu54/object-validity
```

## Usage

A schema object is a collection of field to validate. Each field are a function with a validator object. A validator function can be chained. ex:
``` javascript
validator => validator.be('number').min(2).max(5)
```

``` javascript
const {Schema} = require('@iryu54/object-validity')
const objectToValidate = {
  number: 10,
  nestedObject: {
    object: {}
  },
  arrayNested: [
    {array: []}
  ]
}
const {valid, error} = new Schema({
  number: validator=>  validator.be('number').min(9).max(12),
  nestedObject: { object: v => v.object() },
  arrayNested : [
    { array: v => v.array() }
  ]
}).validate(objectToValidate)
expect(valid).to.be.true
expect(error).to.be.null
```

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