1.1.1 • Published 4 years ago

ajv-filter v1.1.1

Weekly downloads
11
License
MIT
Repository
github
Last release
4 years ago

Ajv Filter

Library that enables ajv to filter objects, rather than just validating them.

Install

npm install --save ajv-filter

Usage

import AJV from 'ajv';
import Filter from 'ajv-filter';

const Schema = {
  type: 'object',
  properties: {
    foo: {
      type: 'string'
    },
    bar: {
      type: 'number'
    }
  }
};

const Data = {
  foo: 'string',
  bar: '123'
};

const ajv = Filter.patchInstance ( new AJV () ); // <- patching the instance
const validate = ajv.compile ( Filter.patchSchema ( schema ) ); // <- patching the schema

validate ( Data ); // => false
console.log ( Data ); // { foo: 'string' }
validate ( Data ); // => true

License

MIT © Fabio Spampinato

1.1.1

4 years ago

1.1.0

5 years ago

1.0.0

5 years ago