https://github.com/arshadkazmi42/json-key-validate
Validates if all required keys are present in JSON object
https://github.com/arshadkazmi42/json-key-validate
has-key json-has json-has-key json-key-validate json-validate payload-validate validate
Last synced: 12 months ago
JSON representation
Validates if all required keys are present in JSON object
- Host: GitHub
- URL: https://github.com/arshadkazmi42/json-key-validate
- Owner: arshadkazmi42
- License: mit
- Created: 2019-02-23T14:31:16.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-07-12T12:38:31.000Z (almost 4 years ago)
- Last Synced: 2024-11-28T01:46:03.294Z (over 1 year ago)
- Topics: has-key, json-has, json-has-key, json-key-validate, json-validate, payload-validate, validate
- Language: JavaScript
- Size: 88.9 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# json-key-validate
[](https://github.com/arshadkazmi42/json-key-validate/actions/workflows/nodejs.yml)
[](https://www.npmjs.com/package/json-key-validate)
[](https://www.npmjs.com/package/json-key-validate)
[](https://github.com/arshadkazmi42/json-key-validate)
[](https://github.com/arshadkazmi42/json-key-validate/blob/master/LICENSE)
[](https://github.com/arshadkazmi42/json-key-validate/graphs/contributors)
[](https://github.com/arshadkazmi42/json-key-validate/commits/master)
Validates if all required keys are present in JSON object
> Give us a :star: if you like our work :heart:
## Install
```
$ npm install json-key-validate --save
```
## Usage
```javascript
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 -> false
```
## Contributing
Interested in contributing to this project?
You can log any issues or suggestion related to this library [here](https://github.com/arshadkazmi42/json-key-validate/issues/new)
Read our contributing [guide](CONTRIBUTING.md) on getting started with contributing to the codebase