obj-denied

1.3.1 • Public • Published

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

/obj-denied/

    Package Sidebar

    Install

    npm i obj-denied

    Weekly Downloads

    20

    Version

    1.3.1

    License

    GPL-3.0

    Last publish

    Collaborators

    • geex