# sifted

> Sift out your valid inputs... functionally!

Latest version **0.2.2** (published 2015-12-13) · MIT license · 0 weekly downloads

## Install

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

## 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.2.2 |
| Published | 2015-12-13 |
| First published | 2015-11-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Ryan Zeigler |
| Maintainers | arzig |
| Keywords | functional, schema, validation |

## Links

- npm: https://www.npmjs.com/package/sifted
- Repository: https://github.com/arzig/sifted
- Issues: https://github.com/arzig/sifted/issues
- npm.io page: https://npm.io/package/sifted

## Dependencies (4)

- [ramda](https://npm.io/package/ramda.md) ^0.18.0
- [data.maybe](https://npm.io/package/data.maybe.md) ^1.2.1
- [core.inspect](https://npm.io/package/core.inspect.md) ^1.0.3
- [data.validation](https://npm.io/package/data.validation.md) ^1.3.0

## Alternatives

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

## Recent versions

- 0.2.2 (latest) — 2015-12-13
- 0.2.1 — 2015-12-12
- 0.1.2 — 2015-11-30
- 0.1.1 — 2015-11-30

## README

# Sifted
[![Build Status](https://travis-ci.org/arzig/sifted.svg?branch=master)](https://travis-ci.org/arzig/sifted)

Sift out your valid inputs... functionally!
Sifted allows the purely compositional construction of a schema by which to verify arbitrarily shaped javascript object hierarchies with optional coercion.

## Basic Usage

Create constraints using combinators and then execute them with run.

    var sifted = requre('sifted'),
        C = sifted.Constraint,
        schema = C.assoc([
                C.property(C.isNumber, 'a'),
                C.property(C.anyLenArray(C.isString), 'b')
            ]),
        result = sifted.run(schema, input);
    result.fold(err => console.error(err), v => console.log(v));

At this point, `result` will be a `Validation[Array[Reason], A]` which is an object conforming to the specification you might expect.
The `A` type will match the ideal structure of your input including none of the superfluous fields.
Each `Reason` in the output type is a `Context` indicating the location in the input an error occurred and an associated error message.
There is also a `sifted.runCont(c, input, cb)` that exposes an api similar to Joi where cb should have the signature `Array[Reason], Output -> Null`.
Note that if validation fails, the callback receives null for output.

For more see
* The [Constraint API](doc/constraint.md)
* The [Coercion API](doc/coercion.md)
* The [Types](doc/types.md)

These are exported from sifted as

    {
        Constraint,
        Coercion,
        Types
        run,
        runCont
    }

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