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 400,000 packages pre-installed, including obj-denied with all npm packages installed. Try it out:

var objDenied = require("obj-denied")

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

obj-denied v1.3.1

Check if the required properties are set, the easy way!

obj-denied

Check if the required properties are set, the easy way!

Build Status Dependency Status NSP Status

Requirements

To use this module, the following is required:

  • An env that accepts ES6' const and let

Installation

You can install this module with NPM:

npm install --save obj-denied

Usage

Require the library

    const denied = require('obj-denied');

Define an Object (or get one)

    const obj = {
        foo: 'bar',
        baz: 'qux',
        nope: null,
        sub_obj: {exists: 'Yes!'},
        sub_arr: ['element']
    }

Start checking!

Success!

    if(denied(obj, ['foo', 'baz'])) {
        return 'Not all required props are given';
    }

    // Go on with life

Oops!

    if(denied(obj, ['nope', 'non-existend'])) {
        return 'Not all required props are given';
    }

    // Nothing going on here, debug the part above, because denied returned true
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