https://github.com/vmlweb/dingle-validator
Dingle Parameter Validation
https://github.com/vmlweb/dingle-validator
Last synced: about 1 year ago
JSON representation
Dingle Parameter Validation
- Host: GitHub
- URL: https://github.com/vmlweb/dingle-validator
- Owner: Vmlweb
- License: mit
- Created: 2015-05-28T14:39:22.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-06-01T16:56:39.000Z (about 11 years ago)
- Last Synced: 2025-03-11T14:50:07.398Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/dingle-validator
- Size: 141 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dingle Validator
[Dingle](https://github.com/Vmlweb/Dingle) Parameter Validation
## Installation
```bash
$ npm install --save dingle-validator
```
## Usage
Simply require the dingle validator module and specify a data type:
```javascript
exports.params.email = {
description: 'Email for the user being registered',
required: true,
validator: require('dingle-validator').email
}
```
## Custom Errors
To return a custom error you must pass it into the function like so:
```javascript
exports.params.email = {
description: 'Email for the user being registered',
required: true,
validator: function(object){
return require('dingle-validator').email(object, 'You must enter a valid email address!');
}
}
```
## Data Types
You can use any of the following data types from this module:
- string
- boolean
- float
- integer
- date *(Returns a date object)*
- file *(Returns a multer object)*
- json *(Returns an object from JSON.parse)*
- email
- ip
- url
- domain
- base64
- color *(Hexidecimal color)*
- hex *(Hexidecimal number)*
- isbn
- isin
- uuid
- mongo *(Mongo object id)*
- card *(Credit or debit card)*