@clocklimited/validity-required

1.0.2 • Public • Published

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('validity-required')
  , 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

Readme

Keywords

none

Package Sidebar

Install

npm i @clocklimited/validity-required

Weekly Downloads

48

Version

1.0.2

License

ISC

Unpacked Size

3.48 kB

Total Files

4

Last publish

Collaborators

  • mrstebo
  • scott-clock
  • clock-release-bot
  • steepnicki
  • asheboy