开发者社区> 镜像站> NPM> validity-equal-field
validity-equal-field
Validity style validator to ensure a property is equal to another schemata field
Last updated 6 years ago by confuser .
BSD-2-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install validity-equal-field 
SYNC missed versions from official npm registry.

validity-equal-field

Build Status

Validity style validator to ensure a property is equal to another schemata field

Installation

npm install validity-equal-field

Usage

Below is a simple example for usage with schemata:


var validity = require('validity')
  , schemata = require('schemata')
  , save = require('save')
  , createValidator = require('validity-equal-field')

var schema = schemata(
    { password:
      { type: String
      , validators: { all: [ createValidator('vpassword') ] }
      }
    , vpassword:
      { type: String }
    })

A custom error message can also be passed createValidator('vpassword', 'Passwords do not match')

API

var validate = createValidator()

Create a validate function.

validate(String:key, String:keyDisplayName, Object:object, Function:cb)

This is a validity compatible function, which in turn is used by schemata for schema validation.

The callback signature cb(err, errorMessage).

err is an Error object if something bad happened and null otherwise. errorMessage is a String if a validation error happened and undefined otherwise.

Licence

Licensed under the New BSD License

Current Tags

  • 0.0.1                                ...           latest (6 years ago)

1 Versions

  • 0.0.1                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (5)
Dependents (1)