https://github.com/mamedul/objectpropvalidator
simple and small fine object properties validation checker with suggestions
https://github.com/mamedul/objectpropvalidator
javascript mamedul momedul object object-properties objectpropvalidator validator
Last synced: 3 months ago
JSON representation
simple and small fine object properties validation checker with suggestions
- Host: GitHub
- URL: https://github.com/mamedul/objectpropvalidator
- Owner: mamedul
- License: mit
- Created: 2021-12-07T20:23:51.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-22T20:21:49.000Z (over 3 years ago)
- Last Synced: 2025-03-11T11:08:53.668Z (4 months ago)
- Topics: javascript, mamedul, momedul, object, object-properties, objectpropvalidator, validator
- Language: JavaScript
- Homepage: https://mamedul.github.io/dev-projects/objectpropvalidator/
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# objectpropvalidator
-Simple and small fine object properties validation checker with suggestions using console
## Features
* Simple and smallest size
* NodeJS compatible
* ExpressJS compatible
* Easy to use and short coding
* Small size (less than 3KB)
* Suggestion to validation (exact location)
* Custom configuration
* Custom logger configuration
## Installations
objectpropvalidator is available on [npmjs](https://www.npmjs.com/package/objectpropvalidator) (using semantic versioning), and can install via npm command.
```
npm install objectpropvalidator
```
or```
npm i objectpropvalidator
```
or```
npm save objectpropvalidator
```Or you can use CDN in your HTML file-
```html
```
or```html
```
Or you can use locally downloaded file in your HTML file-
```html
```
## How to use
-Simple to use
```html
objectPropValidator(validationObject).(data)
```or
With configuration object-
```html
objectPropValidator(validationObject,config).(data)
```## Example
-If there has any error or invalid data, it will show error base on your configuration. Default error log via `console.error`
```html
// We check this data validity
var data = {
"props": {
"user": {
"name": "MAMEDUL ISLAM",
"age": 26
}
}
};var validationObject = { props: {
user: {
type: Object,
required: true,
validator: objectPropValidator({
name: {
type: String,
required: true,
},
age: {
type: Number,
required: true,
validator(value) {
return value > 0;
},
},
}),
},
}
};// Configurations
var config = {
enabled: true, // Configuration enabled
logLevel: 'log' // suggestion show via console.log
};objectPropValidator(validationObject,config)(data);
```
## Documentation
Check the [documentations here.](https://github.com/mamedul/objectpropvalidator/wiki)
## License
`objectpropvalidator` javascript library is Licensed under the [MIT license](https://github.com/mamedul/objectpropvalidator/blob/master/LICENSE).
## Contributing
The library is developed by [MAMEDUL ISLAM](https://mamedul.github.io).