jungles-validators

1.8.1 • Public • Published

Jungles Validators

Validators and sanitizer to be used with jungles-validation.

Validator api

var validator = function (parameters) {

  // parameters: use these to pass extra info to validator. For example a custom message.

  return function (data, key, errors, sanitize, callback) {

    // data: the object that is getting validated
    // key: the key that is being validated
    // errors: object that holds your errors
    // sanitize: object that holds your sanitized data
    // callback: when everything is done

  });

};

Jungles Validation

If you are using this with jungles-validation then you need to use the following api for your errors and sanitized values.

Errors

Errors expect an object of arrays.

var error = {
  key: [ 'error one' , 'error two' ]
}

The utils module has a helper to set values on an array that's a property of an object.

pushValue(object, key, value);

Sanitzed values

Normal object.

Current validators and sanitizers

  • required
  • string
  • integer
  • decimal
  • email
  • array
  • url
  • compare
  • boolean

Test

mocha.js and should.js is needed.

make test

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.8.1
    0
    • latest

Version History

Package Sidebar

Install

npm i jungles-validators

Weekly Downloads

0

Version

1.8.1

License

none

Last publish

Collaborators

  • enome