# record-validator

> Validate typing of a JavaScript record

Latest version **1.5.0** (published 2022-06-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install record-validator
pnpm add record-validator
yarn add record-validator
bun add record-validator
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.0 |
| Published | 2022-06-12 |
| First published | 2022-06-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Lilian VERLHAC |
| Maintainers | harmos274 |

## Links

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

## Recent versions

- 1.5.0 (latest) — 2022-06-12
- 1.4.0 — 2022-06-12
- 1.3.0 — 2022-06-12
- 1.2.0 — 2022-06-11
- 1.1.0 — 2022-06-11
- 1.0.0 — 2022-06-10

## README

# Record Validator

Record validator is a NodeJS package that allows you to do a runtime check of a given Record.

## How to use it

```typescript
import { TypeValidator } from "record-validator"

interface ISimpleTest {
  id: number,
  name: string,
}


const validator = new TypeValidator<ISimpleTest>({
  id: {
    required: true,
    type: "number"
  },
  name: {
    required: true,
    type: "string"
  }
})

const value = {
  id: 12,
  name: "toto"
}

validator.test(value)
// Returns null on success and a string explaining the error on failure.
```

**You should check the [unit tests](https://github.com/Harmos274/type-validator/blob/master/tests/unit.test.ts) 
to know more about this package, including how to implement custom validators for your types and nested fields.**

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