@cofondateurauchomage/libs 1.1.130 → 1.1.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/api.validate.js
CHANGED
|
@@ -212,7 +212,7 @@ function validateBodyForO(route, body) {
|
|
|
212
212
|
if (typeof body !== "object" || body === null) {
|
|
213
213
|
throw new ValidationError(400, "Le payload est requis");
|
|
214
214
|
}
|
|
215
|
-
const cleanedBody = (0, utils_1.cleanObject)(body, { keepNull: true });
|
|
215
|
+
const cleanedBody = (0, utils_1.cleanObject)(body, { keepNull: true, keepEmptyArrays: true });
|
|
216
216
|
const schema = schemasForAllRoutes[route];
|
|
217
217
|
const parsed = schema.safeParse(cleanedBody);
|
|
218
218
|
if (!parsed.success) {
|
|
@@ -21,6 +21,7 @@ type Cleaned<T> = {
|
|
|
21
21
|
export declare function cleanObject<T extends object>(obj: T, options?: {
|
|
22
22
|
recursive?: boolean;
|
|
23
23
|
keepNull?: boolean;
|
|
24
|
+
keepEmptyArrays?: boolean;
|
|
24
25
|
}): Cleaned<T>;
|
|
25
26
|
export declare function deepEqual<T>(obj1: T, obj2: T): boolean;
|
|
26
27
|
export {};
|
|
@@ -48,7 +48,7 @@ function cleanObject(obj, options) {
|
|
|
48
48
|
if (cleanedValue !== "" &&
|
|
49
49
|
cleanedValue !== undefined &&
|
|
50
50
|
(options?.keepNull || cleanedValue !== null) &&
|
|
51
|
-
(!Array.isArray(cleanedValue) || (0, arrayUtils_1.compact)(cleanedValue).length > 0) &&
|
|
51
|
+
(options?.keepEmptyArrays || !Array.isArray(cleanedValue) || (0, arrayUtils_1.compact)(cleanedValue).length > 0) &&
|
|
52
52
|
(!isObject(cleanedValue) || Object.keys(cleanedValue).length > 0)) {
|
|
53
53
|
result[key] = cleanedValue;
|
|
54
54
|
}
|