@cofondateurauchomage/libs 1.1.114 → 1.1.116
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
|
@@ -62,7 +62,7 @@ const userBody = {
|
|
|
62
62
|
invest: zod_1.z.number().min(0).max(1_000_000).optional(),
|
|
63
63
|
motivations: zStrMax1000.optional(),
|
|
64
64
|
partner: zStrMax1000.optional(),
|
|
65
|
-
business: zStrMax1000,
|
|
65
|
+
business: zStrMax1000.optional(),
|
|
66
66
|
bestStrength: zStrMax1000.optional(),
|
|
67
67
|
projectStatus: zod_1.z.array(zProjectStatus).optional(),
|
|
68
68
|
ambitions: zod_1.z.array(zAmbition).optional(),
|
|
@@ -197,12 +197,13 @@ function validateBodyForO(route, body) {
|
|
|
197
197
|
if (typeof body !== "object" || body === null) {
|
|
198
198
|
throw new ValidationError(400, "Le payload est requis");
|
|
199
199
|
}
|
|
200
|
+
const cleanedBody = (0, utils_1.cleanObject)(body, { keepNull: true });
|
|
200
201
|
const schema = schemasForAllRoutes[route];
|
|
201
|
-
const parsed = schema.safeParse(
|
|
202
|
+
const parsed = schema.safeParse(cleanedBody);
|
|
202
203
|
if (!parsed.success) {
|
|
203
204
|
throwFromZodError(parsed.error);
|
|
204
205
|
}
|
|
205
|
-
const input =
|
|
206
|
+
const input = cleanedBody;
|
|
206
207
|
const result = {};
|
|
207
208
|
for (const key of Object.keys(schema.shape)) {
|
|
208
209
|
if (input[key] !== undefined) {
|
package/build/db.model.d.ts
CHANGED
|
@@ -43,13 +43,13 @@ function cleanObject(obj, options) {
|
|
|
43
43
|
const result = {};
|
|
44
44
|
for (const [key, value] of typedObjectEntries(obj)) {
|
|
45
45
|
const cleanedValue = isObject(value) && options?.recursive
|
|
46
|
-
? cleanObject(value,
|
|
46
|
+
? cleanObject(value, options)
|
|
47
47
|
: value;
|
|
48
48
|
if (cleanedValue !== "" &&
|
|
49
49
|
cleanedValue !== undefined &&
|
|
50
|
-
cleanedValue !== null &&
|
|
50
|
+
(options?.keepNull || cleanedValue !== null) &&
|
|
51
51
|
(!Array.isArray(cleanedValue) || (0, arrayUtils_1.compact)(cleanedValue).length > 0) &&
|
|
52
|
-
(!isObject(
|
|
52
|
+
(!isObject(cleanedValue) || Object.keys(cleanedValue).length > 0)) {
|
|
53
53
|
result[key] = cleanedValue;
|
|
54
54
|
}
|
|
55
55
|
}
|