# joi-machine

> Generate joi schema from JSON

Latest version **3.0.0** (published 2016-11-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install joi-machine
pnpm add joi-machine
yarn add joi-machine
bun add joi-machine
```

Provides the command `joi-machine`.

## 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 | 3.0.0 |
| Published | 2016-11-13 |
| First published | 2014-11-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Alan Shaw |
| Maintainers | alanshaw |
| Keywords | joi, machine, validation, generator |

## Links

- npm: https://www.npmjs.com/package/joi-machine
- Repository: https://github.com/alanshaw/joi-machine
- Issues: https://github.com/alanshaw/joi-machine/issues
- npm.io page: https://npm.io/package/joi-machine

## Dependencies (3)

- [joi](https://npm.io/package/joi.md) ^9.2.0
- [through2](https://npm.io/package/through2.md) ^2.0.0
- [unquoted-property-validator](https://npm.io/package/unquoted-property-validator.md) ^1.0.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

- 3.0.0 (latest) — 2016-11-13
- 2.0.0 — 2015-10-13
- 1.0.2 — 2015-01-16
- 1.0.1 — 2015-01-03
- 1.0.0 — 2014-11-03

## README

# Joi Machine [![Build Status](https://img.shields.io/travis/alanshaw/joi-machine.svg?style=flat)](https://travis-ci.org/alanshaw/joi-machine) [![Dependency Status](https://david-dm.org/alanshaw/joi-machine.svg?style=flat)](https://david-dm.org/alanshaw/joi-machine)

Generate a [Joi](https://github.com/hapijs/joi) schema from some JSON or a JS object.

Useful for creating a base to build your schema from when you have a big payload to validate.

## Example

```sh
npm install -g joi-machine
echo '{"foo": {}, "bar": 45, "baz": ["foob"]}' | joi-machine
Joi.object().keys({foo: Joi.object(), bar: Joi.number().integer(), baz: Joi.array().items(Joi.string())})
```

**or**

```js
var fs = require('fs')
var concat = require('concat-stream')
var joiMachine = require('joi-machine')

// data.json: {"foo": {}, "bar": 45, "baz": ["foob"]}
fs.createReadStream(__dirname + '/data.json')
  .pipe(joiMachine())
  .pipe(concat({encoding: 'string'}, console.log))

// Output: Joi.object().keys({foo: Joi.object(), bar: Joi.number().integer(), baz: Joi.array().items(Joi.string())})
```

**or**

```js
var fs = require('fs')
var concat = require('concat-stream')
var joiMachine = require('joi-machine')

var generator = joiMachine.obj()

generator.pipe(concat({encoding: 'string'}, console.log))

// data.json: {"foo": {}, "bar": 45, "baz": ["foob"]}
generator.write(require('./data.json'))
generator.end()

// Output: Joi.object().keys({foo: Joi.object(), bar: Joi.number().integer(), baz: Joi.array().items(Joi.string())})
```

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