You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

ajv-filter

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajv-filter

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

1.1.1
latest
Source
npm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

ajv

FAQs

Package last updated on 23 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts