Skip to content

tomgco/validity-regex-match

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Define simple inline rules to match

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •