🐛 fix body parser

This commit is contained in:
Flam3rboy
2021-04-05 21:24:36 +02:00
parent cf70e8cff6
commit c0fd1d1f2f
2 changed files with 4 additions and 3 deletions
+2 -2
View File
@@ -114,8 +114,6 @@ export function instanceOf(
}
if (typeof type === "object") {
if (typeof value !== "object") throw new FieldError("BASE_TYPE_OBJECT", req.t("common:field.BASE_TYPE_OBJECT"));
if (Array.isArray(type)) {
if (!Array.isArray(value)) throw new FieldError("BASE_TYPE_ARRAY", req.t("common:field.BASE_TYPE_ARRAY"));
if (!type.length) return true; // type array didn't specify any type
@@ -154,6 +152,8 @@ export function instanceOf(
throw new FieldError("BASE_TYPE_CLASS", req.t("common:field.BASE_TYPE_CLASS", { type }));
}
if (typeof value !== "object") throw new FieldError("BASE_TYPE_OBJECT", req.t("common:field.BASE_TYPE_OBJECT"));
const diff = Object.keys(value).missing(
Object.keys(type).map((x) => (x.startsWith(OPTIONAL_PREFIX) ? x.slice(OPTIONAL_PREFIX.length) : x))
);