Nevertheless! Party Metaphorically
Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

validity-require-one

0.1.1 • Public • Published

validity-require-one

Validate that at least one field of a given set has a value.

Installation

npm install validity-require-one --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')
  , requireOne = require('validity-require-one')
 
var schema = schemata(
    { field1:
      { type: Boolean
      , validators: { all: [ requireOne(['field1', 'field2', 'field3']) ] }
      }
    , field2:
      { type: String
      , validators: { all: [ requireOne(['field1', 'field2', 'field3']) ] }
      }
    , field3:
      { type: String
      , validators: { all: [ requireOne(['field1', 'field2', 'field3']) ] }
      }
    })
 

Install

npm i validity-require-one

DownloadsWeekly Downloads

69

Version

0.1.1

License

MIT

Last publish

Collaborators

  • avatar