validity-regex-match

2.0.0 • Public • Published

validity-regex-match

Validity style validator to match simple regex's to a property.

Installation

  npm install validity-regex-match

Usage

Below is a simple example for usage with schemata:

 
var validity = require('validity')
  , schemata = require('schemata')
  , regexMatch = require('validity-regex-match')
 
var schema = schemata(
    { pinCode:
      { type: String // String as we need a leading 0
      , validators:
        { all: [regexMatch(/[0-9]{4}/)]
        }
      }
      , membershipCode:
      { type: String
      }
    })
 
schema.validate({ pinCode: '2323', membershipCode: '9238' }, function (error, valid) {
  // Show the error
  console.log(valid)
})
 

Credits

Tom Gallacher follow me on twitter @tomgco

Licence

Licensed under the MIT License

Readme

Keywords

none

Package Sidebar

Install

npm i validity-regex-match

Weekly Downloads

114

Version

2.0.0

License

MIT

Last publish

Collaborators

  • tomgco