UNPKG

1.29 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6exports.IsMagnetURI = exports.isMagnetURI = exports.IS_MAGNET_URI = void 0;
7const ValidateBy_1 = require("../common/ValidateBy");
8const isMagnetURI_1 = __importDefault(require("validator/lib/isMagnetURI"));
9exports.IS_MAGNET_URI = 'isMagnetURI';
10/**
11 * Check if the string is a magnet uri format.
12 * If given value is not a string, then it returns false.
13 */
14function isMagnetURI(value) {
15 return typeof value === 'string' && (0, isMagnetURI_1.default)(value);
16}
17exports.isMagnetURI = isMagnetURI;
18/**
19 * Check if the string is a magnet uri format.
20 * If given value is not a string, then it returns false.
21 */
22function IsMagnetURI(validationOptions) {
23 return (0, ValidateBy_1.ValidateBy)({
24 name: exports.IS_MAGNET_URI,
25 validator: {
26 validate: (value, args) => isMagnetURI(value),
27 defaultMessage: (0, ValidateBy_1.buildMessage)(eachPrefix => eachPrefix + '$property must be magnet uri format', validationOptions),
28 },
29 }, validationOptions);
30}
31exports.IsMagnetURI = IsMagnetURI;
32//# sourceMappingURL=IsMagnetURI.js.map
\No newline at end of file