mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-11 05:02:37 +01:00
🐛 fix body parser empty error object
This commit is contained in:
parent
0f23d5bed4
commit
79894e6f27
@ -121,7 +121,8 @@ export function instanceOf(
|
||||
return (
|
||||
value.every((val, i) => {
|
||||
errors[i] = {};
|
||||
return (
|
||||
|
||||
if (
|
||||
instanceOf(type[0], val, {
|
||||
path: `${path}[${i}]`,
|
||||
optional,
|
||||
@ -129,7 +130,12 @@ export function instanceOf(
|
||||
req,
|
||||
ref: { key: i, obj: value },
|
||||
}) === true
|
||||
);
|
||||
) {
|
||||
delete errors[i];
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}) || errors
|
||||
);
|
||||
} else if (type?.constructor?.name != "Object") {
|
||||
@ -170,7 +176,7 @@ export function instanceOf(
|
||||
if (OPTIONAL) newKey = newKey.slice(OPTIONAL_PREFIX.length);
|
||||
errors[newKey] = {};
|
||||
|
||||
return (
|
||||
if (
|
||||
instanceOf(type[key], value[newKey], {
|
||||
path: `${path}.${newKey}`,
|
||||
optional: OPTIONAL,
|
||||
@ -178,7 +184,12 @@ export function instanceOf(
|
||||
req,
|
||||
ref: { key: newKey, obj: value },
|
||||
}) === true
|
||||
);
|
||||
) {
|
||||
delete errors[newKey];
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}) || errors
|
||||
);
|
||||
} else if (typeof type === "number" || typeof type === "string" || typeof type === "boolean") {
|
||||
|
Loading…
Reference in New Issue
Block a user