Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

dingle-validator

Vmlweb6MIT0.2.0

Dingle Parameter Validation

dingle, framework, module, api, layout, endpoint, backend, scalable, scale, maintain, maintainable, manager, export, code, generation, generator, client, validation, validator, validate, parameter, argument, option

readme

Dingle Validator

Dingle Parameter Validation

Installation

$ npm install --save dingle-validator

Usage

Simply require the dingle validator module and specify a data type:

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:

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)