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.IsJSON = exports.isJSON = exports.IS_JSON = void 0;
|
7 | const ValidateBy_1 = require("../common/ValidateBy");
|
8 | const isJSON_1 = __importDefault(require("validator/lib/isJSON"));
|
9 | exports.IS_JSON = 'isJson';
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | function isJSON(value) {
|
15 | return typeof value === 'string' && (0, isJSON_1.default)(value);
|
16 | }
|
17 | exports.isJSON = isJSON;
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | function IsJSON(validationOptions) {
|
23 | return (0, ValidateBy_1.ValidateBy)({
|
24 | name: exports.IS_JSON,
|
25 | validator: {
|
26 | validate: (value, args) => isJSON(value),
|
27 | defaultMessage: (0, ValidateBy_1.buildMessage)(eachPrefix => eachPrefix + '$property must be a json string', validationOptions),
|
28 | },
|
29 | }, validationOptions);
|
30 | }
|
31 | exports.IsJSON = IsJSON;
|
32 |
|
\ | No newline at end of file |