This package has been deprecated

Author message:

Check the new module 'obj-denied' it works more logically

accepted

1.1.0 • Public • Published

Accepted

Small module that checks if the given object has given properties and are not null or undefined

Requirements

To use this module, one the following is required:

  • Node.js v6.0.0 or higher
  • An env that accepts ES6' const and let

Installation

You can install this module with NPM:

npm install --save accepted

Usage

Require the library

    const accepted = require('accepted');

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(!accepted(obj, ['foo', 'baz'])) {
        return 'Not all required props are given';
    }
 
    // Go on with life

Oops!

    if(!accepted(obj, ['nope', 'non-existend'])) {
        return 'Not all required props are given';
    }
 
    // Life stopped, accepted returned false
``

Package Sidebar

Install

npm i accepted

Weekly Downloads

1

Version

1.1.0

License

GPL-3.0

Last publish

Collaborators

  • geex