UNPKG

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