Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including options-checker with all npm packages installed. Try it out:

/** * Created by brugnara on 11/10/18, * @ daniele@brugnara.me */ const optionsChecker = require('options-checker') const neededOptions = { action: ['addE', 'addV', 'drop'], name: true, _if: { action: { 'addE': { name: false, fromName: true, toName: true } } } } // valid: true console.log(optionsChecker({ action: 'addE', fromName: 'start', toName: 'end' }, neededOptions)) // valid: false, option: name console.log(optionsChecker({ action: 'addV' }, neededOptions)) // valid: false, option: action, validOptions: ['addE', 'addV', 'drop'] console.log(optionsChecker({ action: 'junk', name: 'junk2' }, neededOptions)) const field = Math.random() console.log(optionsChecker({ field, action: 'test' }, { action: true, field (value, key) { return value === field && key === 'field' } }))

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

options-checker v1.1.0

check mandatories options, even with conditionals

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free