Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
RunKit + npm: json-conditions
node v14.20.1
endpoint
share
tweet
var checkConditions = require("json-conditions") const objectToTest = { toy: { engines: 1, }, batteries: 'AA', fun: true, }; const simpleRules = [ // required: true means This first condition must always be satisfied { property: 'fun', op: 'eq', value: true, required: true }, { property: 'toy.engines', op: 'gt', value: 2 }, { property: 'batteries', op: 'present' }, ]; // Returns true checkConditions({ rules: simpleRules, satisfy: 'ANY', // or ALL to require all conditions to pass log: console.log, }, objectToTest);
Created from: https://npm.runkit.com/json-conditions
Loading…
Clone and edit this document