# bookshelf-joi-validator

> Bookshelf joi validation plugin validates model data using joi schema

Latest version **0.2.4** (published 2015-09-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install bookshelf-joi-validator
pnpm add bookshelf-joi-validator
yarn add bookshelf-joi-validator
bun add bookshelf-joi-validator
```

## 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.4 |
| Published | 2015-09-05 |
| First published | 2015-09-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+7 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Jaka Hudoklin |
| Maintainers | gatehub |
| Keywords | bookshelf, joi, validate |

## Links

- npm: https://www.npmjs.com/package/bookshelf-joi-validator
- Repository: https://github.com/GateHubNet/bookshelf-joi-validator
- Issues: https://github.com/GateHubNet/bookshelf-joi-validator/issues
- npm.io page: https://npm.io/package/bookshelf-joi-validator

## Dependencies (3)

- [joi](https://npm.io/package/joi.md) ^6.6.1
- [lodash](https://npm.io/package/lodash.md) ^3.10.0
- [bluebird](https://npm.io/package/bluebird.md) ^2.9.34

## 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.4 (latest) — 2015-09-05
- 0.2.3 — 2015-09-04

## README

# Bookshelf joi valitator

Bookshelf joi validation plugin validates model data using joi schema

## Installation

    npm install bookshelf-joi-validator

Then in your bookshelf configuration:

    var bookshelf = require('bookshelf')(knex);
    bookshelf.plugin(require('bookshelf-joi-validator');

## Usage

Define bookshelf model:

    var user = Joi.string().alphanum().min(3).max(30);
    var pass = Joi.string().regex(/[a-zA-Z0-9]{3,30}/);
    var uuid = Joi.string().guid();

    var model = bookshelf.Model.extend({
      tableName: 'users',

      schema: {
        create: Joi.object().keys({
          user: user.required(),
          pass: pass.required(),
          uuid: uuid.required()
        }),
        update: Joi.object().keys({
          user: user,
          pass: pass
        })
      }
    });

Upon saving or creation of model, plugin checks if data is valid, and on error
raises `bookshelf.Model.ValidationError`

## License

[MIT](https://opensource.org/licenses/MIT)

## Author

[offlinehacker](https://github.com/offlinehacker)

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