# seneca-joi

> Seneca plugin that provides joi message validation.

Latest version **7.0.2** (published 2020-03-12) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 7.0.2 |
| Published | 2020-03-12 |
| First published | 2016-05-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Richard Rodger |
| Maintainers | mihaidma, rjrodger |
| Keywords | seneca, plugin, message, validate, joi |

## Links

- npm: https://www.npmjs.com/package/seneca-joi
- Repository: https://github.com/senecajs/seneca-joi
- Homepage: https://github.com/senecajs/seneca-joi#readme
- Issues: https://github.com/senecajs/seneca-joi/issues
- npm.io page: https://npm.io/package/seneca-joi

## Dependencies (1)

- [@hapi/joi](https://npm.io/package/@hapi/joi.md) ^17.1.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

- 7.0.2 (latest) — 2020-03-12
- 7.0.1 — 2020-01-28
- 7.0.0 — 2020-01-27
- 6.0.0 — 2019-12-07
- 5.2.0 — 2019-10-02
- 5.1.0 — 2019-09-20
- 5.0.1 — 2019-09-20
- 5.0.0 — 2019-09-20
- 4.1.0 — 2019-07-22
- 4.0.1 — 2019-05-14
- 4.0.0 — 2019-05-14
- 3.1.0 — 2019-02-10
- 3.0.0 — 2019-01-08
- 2.0.0 — 2018-10-03
- 1.0.1 — 2017-06-13
- … 6 more at https://npm.io/package/seneca-joi/versions

## README

![Seneca](http://senecajs.org/files/assets/seneca-logo.png)

> A [Seneca.js][] plugin that validates messages using the
> [joi](github.com/rjrodger/joi) module.

# seneca-joi
[![npm version][npm-badge]][npm-url]
[![Dependency Status][david-badge]][david-url]
[![Build Status][travis-badge]][travis-url]
[![Maintainability](https://api.codeclimate.com/v1/badges/1c51502c58c942a9c583/maintainability)](https://codeclimate.com/github/senecajs/seneca-joi/maintainability)
[![Coverage Status](https://coveralls.io/repos/github/senecajs/seneca-joi/badge.svg?branch=master)](https://coveralls.io/github/senecajs/seneca-joi?branch=master)
[![Gitter][gitter-badge]][gitter-url]


## Installation
```sh
npm install seneca-joi
```

And in your code:

```js
require('seneca')({
  legacy: {validate: false} // needed if using Seneca 2.x
})
.use('seneca-joi', {
  joi: {allowUnknown: true}    // example of passing in Joi options
})
```

## Usage

You can validate action messages by providing
[joi](https://github.com/hapijs/joi) rules as part of the
action definition.

```js
var Joi = require('joi')

require('seneca')
    .use('seneca-joi')
    .add(
      {
        a: 1,
        b: Joi.required()
      },
      function (msg, done) {
        done(null, {c: msg.b})
      })
    .act('a:1,b:2') // valid
    .act('a:1') // invalid as no b value
```

Any properties in the action pattern that are not constants are
interpreted as _joi_ rules.

You can also modify or replace the Joi schema by providing a function
via the `joi$` property. This gives you full control of the Joi schema.

```js
var Joi = require('joi')

require('seneca')
    .use('seneca-joi')
    .add(
      {
        a: 1,
        joi$: function (schema) {
          return schema.keys({b: Joi.required()})
        }
      },
      function (msg, done) {
        done(null, {c: msg.b})
      })
    .act('a:1,b:2') // valid
    .act('a:1') // invalid as no b value
```

## Contributing

The [Senecajs org][] encourages open participation. If you feel you
can help in any way, be it with documentation, examples, extra
testing, or new features please get in touch.


## License
Licensed under [MIT][].

[MIT]: ./LICENSE
[npm-badge]: https://badge.fury.io/js/seneca-joi.svg
[npm-url]: https://badge.fury.io/js/seneca-joi
[Senecajs org]: https://github.com/senecajs/
[Seneca.js]: https://www.npmjs.com/package/seneca
[@senecajs]: http://twitter.com/senecajs
[senecajs.org]: http://senecajs.org/
[travis-badge]: https://travis-ci.org/senecajs/seneca-joi.svg
[travis-url]: https://travis-ci.org/senecajs/seneca-joi
[gitter-badge]: https://badges.gitter.im/Join%20Chat.svg
[gitter-url]: https://gitter.im/senecajs/seneca
[github issue]: https://github.com/senecajs/seneca-joi/issues
[david-badge]: https://david-dm.org/senecajs/seneca-joi.svg
[david-url]: https://david-dm.org/senecajs/seneca-joi

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