UNPKG

1.25 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.IsDataURI = exports.isDataURI = exports.IS_DATA_URI = void 0;
7const ValidateBy_1 = require("../common/ValidateBy");
8const isDataURI_1 = __importDefault(require("validator/lib/isDataURI"));
9exports.IS_DATA_URI = 'isDataURI';
10/**
11 * Check if the string is a data uri format.
12 * If given value is not a string, then it returns false.
13 */
14function isDataURI(value) {
15 return typeof value === 'string' && (0, isDataURI_1.default)(value);
16}
17exports.isDataURI = isDataURI;
18/**
19 * Check if the string is a data uri format.
20 * If given value is not a string, then it returns false.
21 */
22function IsDataURI(validationOptions) {
23 return (0, ValidateBy_1.ValidateBy)({
24 name: exports.IS_DATA_URI,
25 validator: {
26 validate: (value, args) => isDataURI(value),
27 defaultMessage: (0, ValidateBy_1.buildMessage)(eachPrefix => eachPrefix + '$property must be a data uri format', validationOptions),
28 },
29 }, validationOptions);
30}
31exports.IsDataURI = IsDataURI;
32//# sourceMappingURL=IsDataURI.js.map
\No newline at end of file