validity-url

Validity style validator to ensure that a property is a valid URL.

Usage no npm install needed!

<script type="module">
  import validityUrl from 'https://cdn.skypack.dev/validity-url';
</script>

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.

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