@cofondateurauchomage/libs 1.1.130 → 1.1.132

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.
@@ -212,13 +212,12 @@ 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 });
216
215
  const schema = schemasForAllRoutes[route];
217
- const parsed = schema.safeParse(cleanedBody);
216
+ const parsed = schema.safeParse(body);
218
217
  if (!parsed.success) {
219
218
  throwFromZodError(parsed.error);
220
219
  }
221
- const input = cleanedBody;
220
+ const input = body;
222
221
  const result = {};
223
222
  for (const key of Object.keys(schema.shape)) {
224
223
  if (input[key] !== undefined) {
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cofondateurauchomage/libs",
3
- "version": "1.1.130",
3
+ "version": "1.1.132",
4
4
  "description": "",
5
5
  "main": "build/index",
6
6
  "scripts": {