validity-email
Validity style validator to ensure that a property is a valid email address.
As part of the modularisation of validity, this replaces the built-in validity.email
.
Installation
npm install --save @clocklimited/validity-email
Usage
const schemata = require('schemata')
, email = require('@clocklimited/validity-email')
, schema = schemata(
{ emailAddress:
{ validators: [ email ] }
})
, schemaWithCustomMessage = schemata(
{ emailAddress:
{ validators: [ email.setFailureMessage('#{name} not valid') ] }
})
schema.validate({}, function (error, errors) {
console.log(error, errors)
})
schemaWithCustomMessage.validate({}, function (error, errors) {
console.log(error, errors)
})
Credits
Paul Serby
License
ISC