@cofondateurauchomage/libs 1.1.132 → 1.1.134
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
|
@@ -76,10 +76,38 @@ const userBody = {
|
|
|
76
76
|
industries: zod_1.z.array(zIndustryWithNeverMind).optional(),
|
|
77
77
|
photo: zod_1.z.string().optional(),
|
|
78
78
|
};
|
|
79
|
+
const FIELDS_LABEL = {
|
|
80
|
+
ambitions: "Ambitions",
|
|
81
|
+
availability: "Disponibilité",
|
|
82
|
+
bestStrength: "Meilleur atout",
|
|
83
|
+
business: "Business",
|
|
84
|
+
city: "Ville",
|
|
85
|
+
description: "Description",
|
|
86
|
+
email: "Email",
|
|
87
|
+
firstName: "Prénom",
|
|
88
|
+
industries: "Industries",
|
|
89
|
+
invest: "Investissement",
|
|
90
|
+
lastName: "Nom",
|
|
91
|
+
linkedin: "Linkedin",
|
|
92
|
+
motivations: "Motivations",
|
|
93
|
+
name: "Nom",
|
|
94
|
+
partner: "Partenaire",
|
|
95
|
+
partner_iii: "Partenaire III",
|
|
96
|
+
partner_swanbase: "Partenaire Swanbase",
|
|
97
|
+
productTypes: "Types de produits",
|
|
98
|
+
projectStatus: "Statut du projet",
|
|
99
|
+
skills: "Compétences",
|
|
100
|
+
status: "Statut",
|
|
101
|
+
status_detail: "Détail du statut",
|
|
102
|
+
tel: "Téléphone",
|
|
103
|
+
turnover: "Chiffre d'affaires",
|
|
104
|
+
website: "Site web",
|
|
105
|
+
yearsOfExperience: "Années d'expérience",
|
|
106
|
+
};
|
|
79
107
|
function throwFromZodError(error) {
|
|
80
108
|
const issue = error.issues[0];
|
|
81
109
|
const key = issue.path.find((p) => typeof p === "string") ?? "champ";
|
|
82
|
-
const humanKey = (0, utils_1.capitalize)(key.replaceAll("_", " "));
|
|
110
|
+
const humanKey = FIELDS_LABEL[key] ?? (0, utils_1.capitalize)(key.replaceAll("_", " "));
|
|
83
111
|
if (issue.code === "invalid_type" &&
|
|
84
112
|
/\breceived undefined\b/i.test(issue.message)) {
|
|
85
113
|
throw new ValidationError(400, `${humanKey} requis`);
|
|
@@ -23,5 +23,10 @@ export declare function cleanObject<T extends object>(obj: T, options?: {
|
|
|
23
23
|
keepNull?: boolean;
|
|
24
24
|
keepEmptyArrays?: boolean;
|
|
25
25
|
}): Cleaned<T>;
|
|
26
|
+
type IsNull<T> = T extends null ? true : false;
|
|
27
|
+
type WithoutNull<T> = {
|
|
28
|
+
[K in keyof T as IsNull<T[K]> extends true ? never : K]: Exclude<T[K], null>;
|
|
29
|
+
};
|
|
30
|
+
export declare function removeNull<T extends Record<string, any>>(obj: T): WithoutNull<T>;
|
|
26
31
|
export declare function deepEqual<T>(obj1: T, obj2: T): boolean;
|
|
27
32
|
export {};
|
|
@@ -6,6 +6,7 @@ exports.typedKeys = typedKeys;
|
|
|
6
6
|
exports.typedObjectEntries = typedObjectEntries;
|
|
7
7
|
exports.isObject = isObject;
|
|
8
8
|
exports.cleanObject = cleanObject;
|
|
9
|
+
exports.removeNull = removeNull;
|
|
9
10
|
exports.deepEqual = deepEqual;
|
|
10
11
|
const arrayUtils_1 = require("./arrayUtils");
|
|
11
12
|
/**
|
|
@@ -55,6 +56,16 @@ function cleanObject(obj, options) {
|
|
|
55
56
|
}
|
|
56
57
|
return result;
|
|
57
58
|
}
|
|
59
|
+
function removeNull(obj) {
|
|
60
|
+
const acc = {};
|
|
61
|
+
for (const [key, value] of typedObjectEntries(obj)) {
|
|
62
|
+
const cleanedValue = isObject(value) ? removeNull(value) : value;
|
|
63
|
+
if (cleanedValue !== null) {
|
|
64
|
+
acc[key] = cleanedValue;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return acc;
|
|
68
|
+
}
|
|
58
69
|
function deepEqual(obj1, obj2) {
|
|
59
70
|
if (obj1 === obj2) {
|
|
60
71
|
return true;
|