1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | exports.IsUrl = exports.isURL = exports.IS_URL = void 0;
|
7 | const ValidateBy_1 = require("../common/ValidateBy");
|
8 | const isURL_1 = __importDefault(require("validator/lib/isURL"));
|
9 | exports.IS_URL = 'isUrl';
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | function isURL(value, options) {
|
15 | return typeof value === 'string' && (0, isURL_1.default)(value, options);
|
16 | }
|
17 | exports.isURL = isURL;
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | function IsUrl(options, validationOptions) {
|
23 | return (0, ValidateBy_1.ValidateBy)({
|
24 | name: exports.IS_URL,
|
25 | constraints: [options],
|
26 | validator: {
|
27 | validate: (value, args) => isURL(value, args.constraints[0]),
|
28 | defaultMessage: (0, ValidateBy_1.buildMessage)(eachPrefix => eachPrefix + '$property must be an URL address', validationOptions),
|
29 | },
|
30 | }, validationOptions);
|
31 | }
|
32 | exports.IsUrl = IsUrl;
|
33 |
|
\ | No newline at end of file |