validity-url

1.0.0 • Public • Published

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.

build status dependency status

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

Paul Serby

License

ISC

Readme

Keywords

none

Package Sidebar

Install

npm i validity-url

Weekly Downloads

33

Version

1.0.0

License

ISC

Last publish

Collaborators

  • microadam
  • serby
  • jack828