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

Package detail

validity-required

serby62ISC1.0.0

Basic validity style validator to ensure a required property is present in an object.

readme

validity-required

Basic validity style validator to ensure a required property is present in an object.

As part of the modularisation of validity, this replaces the built-in validity.required.

build status dependency status

Installation

npm install --save validity-required

Usage


const schemata = require('schemata')
  , required = require('.')
  , schema = schemata(
    { emailAddress:
      { validators: [ required ] }
    })
  , schemaWithCustomMessage = schemata(
    { emailAddress:
      { validators: [ required.setFailureMessage('Where is #{name}?') ] }
    })


schema.validate({}, function (error, errors) {
  console.log(error, errors)
  // null, 'Email Address is required'
})

schemaWithCustomMessage.validate({}, function (error, errors) {
  console.log(error, errors)
  // null, 'Where is Email Address?'
})

Credits

Paul Serby

License

ISC