https://github.com/roberto/chakram-joi
Chakram assertion for Joi schema.
https://github.com/roberto/chakram-joi
Last synced: 12 months ago
JSON representation
Chakram assertion for Joi schema.
- Host: GitHub
- URL: https://github.com/roberto/chakram-joi
- Owner: roberto
- Created: 2016-07-10T03:24:19.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-07-29T13:44:16.000Z (almost 10 years ago)
- Last Synced: 2025-06-25T01:13:50.829Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Chakram-Joi
[Chakram](https://github.com/dareid/chakram) assertion for checking responses using [Joi](https://github.com/hapijs/joi) schema.
## Installation
```
npm install --save-dev chakram-joi
```
## Setup
```js
chakram.addMethod('joi', require('chakram-joi'));
```
## Basic Usage
```js
const schema = joi.object().keys({
name: joi.string()
});
expect(response).to.joi(schema);
```
## Custom Options
Joi has several [options for validation](https://github.com/hapijs/joi/blob/v9.0.0/API.md#validatevalue-schema-options-callback) and it's possible to use them as shown bellow:
```js
expect(response).to.joi(schema, { abortEarly: false });
```
Default options:
```yml
abortEarly: true # stops validation on the first error
presence: 'required' # declared items must be found
allowUnknown: true # unknown object keys are ignored
```
## License
MIT