# rafinad

> Data validation inspired by refinement type

Latest version **0.1.1** (published 2020-05-06) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2020-05-06 |
| First published | 2020-05-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 27.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | rndr |
| Maintainers | rndr |

## Links

- npm: https://www.npmjs.com/package/rafinad
- Repository: https://github.com/rndr/rafinad
- Homepage: https://github.com/rndr/rafinad#readme
- Issues: https://github.com/rndr/rafinad/issues
- npm.io page: https://npm.io/package/rafinad

## Dependencies (1)

- [lodash.memoize](https://npm.io/package/lodash.memoize.md) ^4.1.2

## Recent versions

- 0.1.1 (latest) — 2020-05-06
- 0.1.0 — 2020-05-03

## README

# rafinad
Data validation inspired by refinement type

## Installation

`npm install rafinad`

or

`yarn add rafinad`

## Example

```javascript
const rafinad = require('rafinad')

const isArticle = rafinad.isOk({
  caption: rafinad.isString,
  tags: rafinad.isEvery(rafinad.isString),
  version: rafinad.and(
    rafinad.isNumber,
    value => value >= 0
  )
})

// Let's check valid article
console.log(isArticle.validate({
  caption: 'test',
  tags: [],
  version: 0
}).isValid()) // true

// this article is invalid: it has version less than zero
console.log(isArticle.validate({
  caption: 'test',
  tags: [],
  version: -1
}).isValid()) // false

// this article is invalid: it has number as caption
console.log(isArticle.validate({
  caption: 1,
  tags: [],
  version: 0
}).isValid()) // false

// this article is invalid: it has extra key `extraKey`
console.log(isArticle.validate({
  caption: 'test',
  tags: [],
  version: 0,
  extraKey: 1
}).isValid()) // false
```

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