# wadofgum-validation

> Joi validation mixin for wadofgum

Latest version **2.0.0** (published 2016-02-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install wadofgum-validation
pnpm add wadofgum-validation
yarn add wadofgum-validation
bun add wadofgum-validation
```

## 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 | 2.0.0 |
| Published | 2016-02-17 |
| First published | 2015-10-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nathan LaFreniere |
| Maintainers | fritzy, nlf |
| Keywords | wadofgum |

## Links

- npm: https://www.npmjs.com/package/wadofgum-validation
- Repository: https://github.com/nlf/wadofgum-validation
- Homepage: https://github.com/nlf/wadofgum-validation#readme
- Issues: https://github.com/nlf/wadofgum-validation/issues
- npm.io page: https://npm.io/package/wadofgum-validation

## Dependencies (1)

- [joi](https://npm.io/package/joi.md) ^7.0.0

## Recent versions

- 2.0.0 (latest) — 2016-02-17
- 1.1.0 — 2015-11-15
- 1.0.0 — 2015-10-10

## README

## wadofgum-validation [![Build Status](https://travis-ci.org/nlf/wadofgum-validation.svg)](https://travis-ci.org/nlf/wadofgum-validation)

A validation mixin for [wadofgum](https://github.com/nlf/wadofgum) based on [joi](https://github.com/hapijs/joi).

### Usage

After extending your model with this mixin, instances of your class will have a `validate` method. This method returns a promise that resolves when validation is complete, or throws if validation fails.

To provide a schema for validation, assign it to the `schema` property on your class. Most Joi features are covered, including type coercion, required keys, renaming keys, and more.

```js
const Wadofgum = require('wadofgum');
const Validation = require('wadofgum-validation');
const Joi = require('joi');

class Model extends Wadofgum.mixin(Validation) {};
Model.schema = Joi.object({
  name: Joi.string().required(),
  age: Joi.number().integer()
});

let model = new Model({ name: 'test', age: '45' });
model.validate().then(function () {
  model.name; // 'test'
  model.age; // 45
});
```

If the [wadofgum-events](https://github.com/nlf/wadofgum-events) mixin is also loaded, this module will emit `preValidate` and `postValidate` events.

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