forked from validatem/is-url
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
1.1 KiB
JavaScript
27 lines
1.1 KiB
JavaScript
"use strict";
|
|
|
|
const { validateValue } = require("@validatem/core");
|
|
const isURL = require("./");
|
|
|
|
console.log(validateValue("https://example.com/", [ isURL() ])); // Url { ... }
|
|
|
|
// validate without returning parsed Url {}
|
|
console.log(validateValue("https://example.com/", [ isURL({parse: false}) ]))
|
|
|
|
console.log(validateValue("bar", [ isURL() ])); /*
|
|
AggregrateValidationError: One or more validation errors occurred:
|
|
- At (root): Must be a valid URL
|
|
*/
|
|
|
|
console.log(validateValue("https://example.com/", [ isURL([ "http://", "https://" ]) ])); // Url { ... }
|
|
|
|
console.log(validateValue("https:example.com/", [ isURL([ "http://", "https://" ]) ])); /*
|
|
AggregrateValidationError: One or more validation errors occurred:
|
|
- At (root): Must be a URL with one of the following protocols: HTTP://, HTTPS:// - but got HTTPS: instead
|
|
*/
|
|
|
|
console.log(validateValue("ftp://example.com/", [ isURL([ "http://", "https://" ]) ])); /*
|
|
AggregrateValidationError: One or more validation errors occurred:
|
|
- At (root): Must be a URL with one of the following protocols: HTTP://, HTTPS:// - but got FTP:// instead
|
|
*/
|