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.

19 lines
694 B
JavaScript

4 years ago
"use strict";
const { validateValue } = require("@validatem/core");
const isURL = require("./");
console.log(validateValue("https://example.com/", [ isURL() ])); // Url { ... }
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("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
*/