validity-validate-if-property-equals

0.0.1 • Public • Published

validity-validate-if-property-equals

Validate the current property if another property is equal to a particular value.

E.g you have a URL property of a schema, which is not a required field. You only want to apply validation to that field if another field has a value equal to a certain value

Installation

npm install validity-validate-if-property-equals --save

Usage

Below is a simple example for usage with schemata and save:

var validity = require('validity')
  , schemata = require('schemata')
  , save = require('save')
  , collection = save('author')
  , validateIfPropertyEquals = require('validity-validate-if-property-equals')
 
var schema = schemata(
    { type:
      { type: String
      }
    , url:
      { type: String
      , validators: { all: [ validateIfPropertyEquals('type', 'link' validity.url) ] }
      }
    })
 

Credits

Adam Duncan

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.1
    77
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.1
    77
  • 0.0.0
    1

Package Sidebar

Install

npm i validity-validate-if-property-equals

Weekly Downloads

78

Version

0.0.1

License

ISC

Last publish

Collaborators

  • microadam