api/clients.post (checkIsClient): Fix opposite condition for the patch parameter.

previously, when patch was true, it was requiring the values in the fields.
and vice versa.
It turns out the "patch" variable was negated for some reason.
This commit is contained in:
Wroclaw 2023-11-09 11:38:36 +01:00
parent ccbbfd1d3b
commit f5b205f90c

View file

@ -28,10 +28,10 @@ export function checkIsClient<Patch extends boolean = boolean>(
});
}
if (!(typeof value.name === "string" || value.name === null || (!patch && value.name === undefined))) errors.set("name", "is not string or null");
if (!(typeof value.address === "string" || value.address === null || (!patch && value.address === undefined))) errors.set("address", "is not string or null");
if (!(typeof value.phone === "string" || value.phone === null || (!patch && value.phone === undefined))) errors.set("phone", "is not string or null");
if (!(typeof value.email === "string" || value.email === null || (!patch && value.email === undefined))) errors.set("email", "is not string or null");
if (!(typeof value.name === "string" || value.name === null || (patch && value.name === undefined))) errors.set("name", "is not string or null");
if (!(typeof value.address === "string" || value.address === null || (patch && value.address === undefined))) errors.set("address", "is not string or null");
if (!(typeof value.phone === "string" || value.phone === null || (patch && value.phone === undefined))) errors.set("phone", "is not string or null");
if (!(typeof value.email === "string" || value.email === null || (patch && value.email === undefined))) errors.set("email", "is not string or null");
for (const i in value as Partial<Omit<Client, "id">>)
if (!clientKeys.includes(i)) errors.set(i, `excessive property`);