badmfck-api-server 1.7.2 → 1.7.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,21 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isError = void 0;
|
4
|
+
const Validator_1 = require("../helper/Validator");
|
3
5
|
class DefaultErrors {
|
4
6
|
static NOT_IMPLEMENTED = { code: 1, message: "Not implemented" };
|
5
7
|
static UNKNOWN_REQUEST = { code: 2, message: "Unknown request" };
|
6
8
|
static JSON_MALFORMED = { code: 3, message: "JSON malformed" };
|
7
9
|
}
|
10
|
+
const isError = (obj) => {
|
11
|
+
const isFieldsExists = Validator_1.Validator.validateObject(['code', 'message'], obj);
|
12
|
+
if (!isFieldsExists)
|
13
|
+
return false;
|
14
|
+
if (Validator_1.Validator.validateValue("code", { type: "number" }) !== Validator_1.ValidationReport.OK)
|
15
|
+
return false;
|
16
|
+
if (Validator_1.Validator.validateValue("message", { type: "string" }) !== Validator_1.ValidationReport.OK)
|
17
|
+
return false;
|
18
|
+
return true;
|
19
|
+
};
|
20
|
+
exports.isError = isError;
|
8
21
|
exports.default = DefaultErrors;
|