2.0.0 • Published 10 years ago

validity-regex-match v2.0.0

Weekly downloads
182
License
MIT
Repository
github
Last release
10 years ago

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

2.0.0

10 years ago

1.0.0

10 years ago

0.1.0

10 years ago