propset
verifies that all the needed properties for your JavaScript objects are set
To install run npm install propset
You can begin using propset once it has been installed and added to your script like so;
const propset = require('propset');
propset(object, array|string)
First parameter is the object to be tested. Second parameter should contain names of properties in the object to be tested. These properties would be ignored i.e propset would not check if those properties are set.
const propset = require('propset')
let testObject = {
firstName:"John",
lastName:"Doe",
age:50,
eyeColor:"blue"
}
if (propset(testObject)){
console.log('All object properties are set.')
}
let anotherTestObject = {
firstName:"John",
lastName:"Doe",
age:null,
eyeColor:undefined
}
//the properties passed as the second argument are ignored and the object test passes.
if (propset(anotherTestObject, ['age', 'eyeColor'])){
console.log('All object properties are set.')
}
PRs are welcome but kindly open an issue first to discuss potential changes/additions.
Copyright (c) 2014 Bill Gooch
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.