Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tuckerconnelly/validate


https://github.com/tuckerconnelly/validate

Last synced: 23 days ago
JSON representation

Awesome Lists containing this project

README

        

***Early Version***

# validate

Validates json schemas and outputs [json-api error objects](https://jsonapi.org/format/#error-objects).

## Usage

```
npm i @tuckerconnelly/validate
```

```js
const validate = require('@tuckerconnelly/validate');

try {
validate(
{
properties: {
title: 'id',
id: { type: integer }
}
},
{ notId: 'A string' }
)
} catch (err) {
console.error(err.errors);

// [
// {
// title: 'Expected id to be a string.'
// source: '/id'
// }
// ]
}
```

## License

MIT