@tuckerconnelly/validate

Validate json schemas

Usage no npm install needed!

<script type="module">
  import tuckerconnellyValidate from 'https://cdn.skypack.dev/@tuckerconnelly/validate';
</script>

README

Early Version

validate

Validates json schemas and outputs json-api error objects.

Usage

npm i @tuckerconnelly/validate
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