# indicative-compiler

> Indicative compiler to compile parsed schema into highly optimized functions

Latest version **7.2.4** (published 2019-12-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install indicative-compiler
pnpm add indicative-compiler
yarn add indicative-compiler
bun add indicative-compiler
```

## 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 | 7.2.4 |
| Published | 2019-12-25 |
| First published | 2019-03-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 55 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | virk,poppinss |
| Maintainers | virk |
| Keywords | indicative, compiler, ast |

## Links

- npm: https://www.npmjs.com/package/indicative-compiler
- Repository: https://github.com/poppinss/indicative-compiler
- Homepage: https://github.com/poppinss/indicative-compiler#readme
- Issues: https://github.com/poppinss/indicative-compiler/issues
- npm.io page: https://npm.io/package/indicative-compiler

## Dependencies (5)

- [pope](https://npm.io/package/pope.md) ^2.0.2
- [isobject](https://npm.io/package/isobject.md) ^4.0.0
- [lodash.get](https://npm.io/package/lodash.get.md) ^4.4.2
- [lodash.set](https://npm.io/package/lodash.set.md) ^4.3.2
- [indicative-parser](https://npm.io/package/indicative-parser.md) ^7.1.4

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 7.2.4 (latest) — 2019-12-25
- 1.0.2 (alpha) — 2019-06-11
- 7.2.3 — 2019-12-25
- 7.2.2 — 2019-12-11
- 7.2.1 — 2019-12-09
- 7.2.0 — 2019-12-08
- 7.1.0 — 2019-12-02
- 7.0.5 — 2019-10-22
- 7.0.4 — 2019-10-17
- 7.0.3 — 2019-09-02
- 7.0.2 — 2019-07-09
- 7.0.1 — 2019-07-08
- 1.0.4 — 2019-07-07
- 1.0.3 — 2019-07-07
- 1.0.1 — 2019-06-09
- … 3 more at https://npm.io/package/indicative-compiler/versions

## README

<div align="center">
  <img src="https://res.cloudinary.com/adonisjs/image/upload/q_100/v1557762307/poppinss_iftxlt.jpg" width="600px">
</div>

# Indicative Compiler
[![circleci-image]][circleci-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]
> Indicative compiler to compile validations schema into a highly optimized executable function.

Indicative is a highly performant validation library for Node.js. It achieves this by compiling the schema into a tree and then an a top level executable function.

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
## Table of contents

- [Usage](#usage)
- [API Docs](#api-docs)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Usage
Install the package from npm registry as follows:

> You must use [indicative](https://github.com/poppinss/indicative) directly. This is a low level module meant to be used by indicative itself.

```sh
npm i indicative-compiler

# yarn
yarn add indicative-compiler
```

and then use it as follows:

```ts
import { ValidatorCompiler, ValidatorExecutor } from 'indicative-compiler'
import { VanillaFormatter } from 'indicative-formatters'
import * as validations from 'indicative-rules'

const schema = {
  username: 'required',
  email: 'required|email'
}

const messages = {}

// Do it once for each schema
const compiledFunctions = new ValidatorCompiler(schema, messages).compile()

await new ValidatorExecutor(compiledFunctions).exec(data, VanillaFormatter, {}, false, false)
```

The `ValidatorExecutor.exec` function takes 5 parameters.

1. `data`: The runtime data to validate against the compiled schema.
2. `formatter`: Formatter constructor to collect and format error messages.
3. `config`: The config to be passed to all the validation functions.
4. `bail`: When `true`, it will stop after first error.
5. `removeAdditional`: When `true`, the `exec` will return only validated properties.

## API Docs
Following are the autogenerated files via Typedoc

* [API](docs/README.md)

[circleci-image]: https://img.shields.io/circleci/project/github/poppinss/indicative-compiler/master.svg?style=for-the-badge&logo=circleci
[circleci-url]: https://circleci.com/gh/poppinss/indicative-compiler "circleci"

[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
[typescript-url]:  "typescript"

[npm-image]: https://img.shields.io/npm/v/indicative-compiler.svg?style=for-the-badge&logo=npm
[npm-url]: https://npmjs.org/package/indicative-compiler "npm"

[license-image]: https://img.shields.io/npm/l/indicative-compiler?color=blueviolet&style=for-the-badge
[license-url]: LICENSE.md "license"

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