validate-form
v1.0.1
Published
Simple functional form validation
Downloads
8
Readme
validate-form
Simple functional form validation
Example
var Validator = require("validate-form")
var truthy = require("validate-form/truthy")
var isEmail = require("validate-form/email")
var isCreditCard = require("validate-form/credit-card")
var range = require("validate-form/range")
var match = require("validate-form/match")
var memberOf = require("validate-form/member-of")
var validDate = /^\d\d\d\d\/\d\d$/
var countries = ["US-en", "UK-en", "BR-pt", ...]
var validate = Validator({
firstName: [truthy()],
lastName: [truthy("Custom message: The %s field is required")],
email: [truthy(), isEmail("Please ensure that you enter valid email")],
cardNumber: [isCreditCard()],
cvv: [range(3, 4)],
expirationDate: [match(validDate)],
country: [memberOf(countries, "enter valid country code")]
})
Installation
npm install validate-form
Contributors
- Raynos