Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.
/ ajv-filter Public archive

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

License

Notifications You must be signed in to change notification settings

fabiospampinato/ajv-filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published