Skip to content

Corgi-IT/obj-denied

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published