|
|
|
"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
|
|
|
|
*/
|