@clocklimited/validity-url
v1.0.1
Published
Validity style validator to ensure that a property is a valid URL.
Downloads
448
Keywords
Readme
validity-url
Validity style validator to ensure that a property is a valid URL.
As part of the modularisation of validity, this replaces the built-in validity.url
.
Installation
npm install --save validity-url
Usage
const schemata = require('schemata')
, url = require('validity-url')
, schema = schemata(
{ webAddress:
{ validators: [ url ] }
})
, schemaWithCustomMessage = schemata(
{ webAddress:
{ validators: [ url.setFailureMessage('#{name} not valid') ] }
})
schema.validate({}, function (error, errors) {
console.log(error, errors)
// null, 'Web Address must be a valid URL'
})
schemaWithCustomMessage.validate({}, function (error, errors) {
console.log(error, errors)
// null, 'Web Address not valid'
})
Credits
License
ISC