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

Package detail

validity-compose

serby63ISC1.0.2

Compose a number of validators together to use as one

readme

validity-compose

Compose a number of validators together and call as a single validator. This is useful when used with a conditional validator.

This used to be called validity-validation-group

Installation

npm install --save validity-compose

Usage

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

var validity = require('validity')
  , schemata = require('schemata')
  , compose = require('validity-compose')

var schema = schemata(
    { type:
      { type: String
      }
    , url:
      { type: String
      , validators: { all: [ validateIfPropertyIn('type', ['a', 'b'], compose([ validity.required, validity.url ]) ] }
      }
    })