1.0.1 • Published 2 years ago

@clocklimited/validity-url v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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