File size: 1,695 Bytes
e372349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValidUrlPath = exports.ValidUrlExtension = void 0;
const tslib_1 = require("tslib");
const class_validator_1 = require("class-validator");
let ValidUrlExtension = class ValidUrlExtension {
    validate(text, args) {
        return (!!text?.split?.('?')?.[0].endsWith('.png') ||
            !!text?.split?.('?')?.[0].endsWith('.jpg') ||
            !!text?.split?.('?')?.[0].endsWith('.jpeg') ||
            !!text?.split?.('?')?.[0].endsWith('.gif') ||
            !!text?.split?.('?')?.[0].endsWith('.webp') ||
            !!text?.split?.('?')?.[0].endsWith('.mp4'));
    }
    defaultMessage(args) {
        return ('File must have a valid extension: .png, .jpg, .jpeg, .gif, .webp, or .mp4');
    }
};
exports.ValidUrlExtension = ValidUrlExtension;
exports.ValidUrlExtension = ValidUrlExtension = tslib_1.__decorate([
    (0, class_validator_1.ValidatorConstraint)({ name: 'checkValidExtension', async: false })
], ValidUrlExtension);
let ValidUrlPath = class ValidUrlPath {
    validate(text, args) {
        if (!process.env.RESTRICT_UPLOAD_DOMAINS) {
            return true;
        }
        return ((text || 'invalid url').indexOf(process.env.RESTRICT_UPLOAD_DOMAINS) > -1);
    }
    defaultMessage(args) {
        return ('URL must contain the domain: ' + process.env.RESTRICT_UPLOAD_DOMAINS + ' Make sure you first use the upload API route.');
    }
};
exports.ValidUrlPath = ValidUrlPath;
exports.ValidUrlPath = ValidUrlPath = tslib_1.__decorate([
    (0, class_validator_1.ValidatorConstraint)({ name: 'checkValidPath', async: false })
], ValidUrlPath);
//# sourceMappingURL=valid.url.path.js.map