Validates if all required keys are present in JSON object
Give us a ⭐ if you like our work ❤️
$ npm install json-key-validate --save
const jkValidate = require('json-key-validate');
const JSON_DATA = {
'name': 'arr-contains',
'author': 'Arshad Kazmi',
'repository': {
'url': 'https://github.com/arshadkazmi42/arr-contains',
'language': 'js'
}
};
const isValid = jkValidate(JSON_DATA, ['name', 'author']);
// Output -> true
const isValid = jkValidate(JSON_DATA, ['url', 'author']);
// Output -> false
const isValid = jkValidate('JSON_DATA', ['url', 'author']);
// Output -> falseInterested in contributing to this project? You can log any issues or suggestion related to this library here
Read our contributing guide on getting started with contributing to the codebase