vr-commons 1.0.112 → 1.0.114

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.
@@ -1,43 +1,47 @@
1
1
  import { z } from "zod";
2
2
  export declare const phoneRegex: RegExp;
3
+ export declare const emailRegex: RegExp;
3
4
  export declare const passwordRegex: RegExp;
5
+ export declare const strongPasswordRegex: RegExp;
6
+ export declare const detectContactType: (value: string) => "EMAIL" | "PHONE" | "WHATSAPP" | "UNKNOWN";
7
+ export declare const validateContactValue: (value: string) => boolean;
4
8
  export declare const userLoginSchema: z.ZodObject<{
5
9
  body: z.ZodObject<{
6
- email: z.ZodString;
10
+ contactValue: z.ZodEffects<z.ZodString, string, string>;
7
11
  password: z.ZodString;
8
12
  }, "strip", z.ZodTypeAny, {
9
- email: string;
10
13
  password: string;
14
+ contactValue: string;
11
15
  }, {
12
- email: string;
13
16
  password: string;
17
+ contactValue: string;
14
18
  }>;
15
19
  }, "strip", z.ZodTypeAny, {
16
20
  body: {
17
- email: string;
18
21
  password: string;
22
+ contactValue: string;
19
23
  };
20
24
  }, {
21
25
  body: {
22
- email: string;
23
26
  password: string;
27
+ contactValue: string;
24
28
  };
25
29
  }>;
26
30
  export declare const forgotPasswordSchema: z.ZodObject<{
27
31
  body: z.ZodObject<{
28
- email: z.ZodString;
32
+ contactValue: z.ZodEffects<z.ZodString, string, string>;
29
33
  }, "strip", z.ZodTypeAny, {
30
- email: string;
34
+ contactValue: string;
31
35
  }, {
32
- email: string;
36
+ contactValue: string;
33
37
  }>;
34
38
  }, "strip", z.ZodTypeAny, {
35
39
  body: {
36
- email: string;
40
+ contactValue: string;
37
41
  };
38
42
  }, {
39
43
  body: {
40
- email: string;
44
+ contactValue: string;
41
45
  };
42
46
  }>;
43
47
  export declare const changePasswordSchema: z.ZodObject<{
@@ -83,65 +87,85 @@ export declare const registerSchema: z.ZodObject<{
83
87
  body: z.ZodObject<{
84
88
  firstName: z.ZodString;
85
89
  lastName: z.ZodString;
86
- phoneNumber: z.ZodString;
87
- email: z.ZodOptional<z.ZodString>;
90
+ contactValue: z.ZodEffects<z.ZodString, string, string>;
88
91
  password: z.ZodString;
92
+ role: z.ZodDefault<z.ZodOptional<z.ZodEnum<["PASSENGER", "RIDER"]>>>;
93
+ gender: z.ZodOptional<z.ZodEnum<["male", "female"]>>;
94
+ birthDate: z.ZodOptional<z.ZodNumber>;
95
+ birthMonth: z.ZodOptional<z.ZodNumber>;
96
+ birthYear: z.ZodOptional<z.ZodNumber>;
89
97
  }, "strict", z.ZodTypeAny, {
90
98
  firstName: string;
91
99
  lastName: string;
92
100
  password: string;
93
- phoneNumber: string;
94
- email?: string | undefined;
101
+ role: "RIDER" | "PASSENGER";
102
+ contactValue: string;
103
+ gender?: "male" | "female" | undefined;
104
+ birthDate?: number | undefined;
105
+ birthMonth?: number | undefined;
106
+ birthYear?: number | undefined;
95
107
  }, {
96
108
  firstName: string;
97
109
  lastName: string;
98
110
  password: string;
99
- phoneNumber: string;
100
- email?: string | undefined;
111
+ contactValue: string;
112
+ gender?: "male" | "female" | undefined;
113
+ birthDate?: number | undefined;
114
+ birthMonth?: number | undefined;
115
+ birthYear?: number | undefined;
116
+ role?: "RIDER" | "PASSENGER" | undefined;
101
117
  }>;
102
118
  }, "strip", z.ZodTypeAny, {
103
119
  body: {
104
120
  firstName: string;
105
121
  lastName: string;
106
122
  password: string;
107
- phoneNumber: string;
108
- email?: string | undefined;
123
+ role: "RIDER" | "PASSENGER";
124
+ contactValue: string;
125
+ gender?: "male" | "female" | undefined;
126
+ birthDate?: number | undefined;
127
+ birthMonth?: number | undefined;
128
+ birthYear?: number | undefined;
109
129
  };
110
130
  }, {
111
131
  body: {
112
132
  firstName: string;
113
133
  lastName: string;
114
134
  password: string;
115
- phoneNumber: string;
116
- email?: string | undefined;
135
+ contactValue: string;
136
+ gender?: "male" | "female" | undefined;
137
+ birthDate?: number | undefined;
138
+ birthMonth?: number | undefined;
139
+ birthYear?: number | undefined;
140
+ role?: "RIDER" | "PASSENGER" | undefined;
117
141
  };
118
142
  }>;
119
143
  export declare const riderLoginSchema: z.ZodObject<{
120
144
  body: z.ZodObject<{
121
- phoneNumber: z.ZodString;
122
- nationalId: z.ZodString;
145
+ contactValue: z.ZodEffects<z.ZodString, string, string>;
146
+ password: z.ZodString;
123
147
  }, "strip", z.ZodTypeAny, {
124
- phoneNumber: string;
125
- nationalId: string;
148
+ password: string;
149
+ contactValue: string;
126
150
  }, {
127
- phoneNumber: string;
128
- nationalId: string;
151
+ password: string;
152
+ contactValue: string;
129
153
  }>;
130
154
  query: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
131
155
  params: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
132
156
  headers: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
133
157
  }, "strip", z.ZodTypeAny, {
134
158
  body: {
135
- phoneNumber: string;
136
- nationalId: string;
159
+ password: string;
160
+ contactValue: string;
137
161
  };
138
162
  params?: {} | undefined;
139
163
  query?: {} | undefined;
140
164
  headers?: {} | undefined;
141
165
  }, {
142
166
  body: {
143
- phoneNumber: string;
144
- nationalId: string;
167
+ password: string;
168
+ contactValue: string;
145
169
  };
146
170
  params?: {} | undefined;
147
171
  query?: {} | undefined;
@@ -149,58 +173,58 @@ export declare const riderLoginSchema: z.ZodObject<{
149
173
  }>;
150
174
  export declare const requestOtpSchema: z.ZodObject<{
151
175
  body: z.ZodObject<{
152
- phoneNumber: z.ZodString;
176
+ contactValue: z.ZodEffects<z.ZodString, string, string>;
153
177
  }, "strip", z.ZodTypeAny, {
154
- phoneNumber: string;
178
+ contactValue: string;
155
179
  }, {
156
- phoneNumber: string;
180
+ contactValue: string;
157
181
  }>;
158
182
  }, "strip", z.ZodTypeAny, {
159
183
  body: {
160
- phoneNumber: string;
184
+ contactValue: string;
161
185
  };
162
186
  }, {
163
187
  body: {
164
- phoneNumber: string;
188
+ contactValue: string;
165
189
  };
166
190
  }>;
167
191
  export declare const verifyOtpSchema: z.ZodObject<{
168
192
  body: z.ZodEffects<z.ZodObject<{
169
- phoneNumber: z.ZodString;
193
+ contactValue: z.ZodEffects<z.ZodString, string, string>;
170
194
  otp: z.ZodString;
171
195
  firstName: z.ZodOptional<z.ZodString>;
172
196
  lastName: z.ZodOptional<z.ZodString>;
173
197
  }, "strip", z.ZodTypeAny, {
174
- phoneNumber: string;
198
+ contactValue: string;
175
199
  otp: string;
176
200
  firstName?: string | undefined;
177
201
  lastName?: string | undefined;
178
202
  }, {
179
- phoneNumber: string;
203
+ contactValue: string;
180
204
  otp: string;
181
205
  firstName?: string | undefined;
182
206
  lastName?: string | undefined;
183
207
  }>, {
184
- phoneNumber: string;
208
+ contactValue: string;
185
209
  otp: string;
186
210
  firstName?: string | undefined;
187
211
  lastName?: string | undefined;
188
212
  }, {
189
- phoneNumber: string;
213
+ contactValue: string;
190
214
  otp: string;
191
215
  firstName?: string | undefined;
192
216
  lastName?: string | undefined;
193
217
  }>;
194
218
  }, "strip", z.ZodTypeAny, {
195
219
  body: {
196
- phoneNumber: string;
220
+ contactValue: string;
197
221
  otp: string;
198
222
  firstName?: string | undefined;
199
223
  lastName?: string | undefined;
200
224
  };
201
225
  }, {
202
226
  body: {
203
- phoneNumber: string;
227
+ contactValue: string;
204
228
  otp: string;
205
229
  firstName?: string | undefined;
206
230
  lastName?: string | undefined;
@@ -208,18 +232,136 @@ export declare const verifyOtpSchema: z.ZodObject<{
208
232
  }>;
209
233
  export declare const resendOtpSchema: z.ZodObject<{
210
234
  body: z.ZodObject<{
211
- phoneNumber: z.ZodString;
235
+ contactValue: z.ZodEffects<z.ZodString, string, string>;
236
+ }, "strip", z.ZodTypeAny, {
237
+ contactValue: string;
238
+ }, {
239
+ contactValue: string;
240
+ }>;
241
+ }, "strip", z.ZodTypeAny, {
242
+ body: {
243
+ contactValue: string;
244
+ };
245
+ }, {
246
+ body: {
247
+ contactValue: string;
248
+ };
249
+ }>;
250
+ export declare const createUserSchema: z.ZodObject<{
251
+ body: z.ZodObject<{
252
+ firstName: z.ZodString;
253
+ lastName: z.ZodString;
254
+ contactValue: z.ZodEffects<z.ZodString, string, string>;
255
+ password: z.ZodString;
256
+ role: z.ZodEnum<["PASSENGER", "RIDER", "AGENT", "ADMIN", "SUPER_ADMIN"]>;
257
+ gender: z.ZodOptional<z.ZodEnum<["male", "female"]>>;
258
+ birthDate: z.ZodOptional<z.ZodNumber>;
259
+ birthMonth: z.ZodOptional<z.ZodNumber>;
260
+ birthYear: z.ZodOptional<z.ZodNumber>;
261
+ jacketId: z.ZodOptional<z.ZodString>;
262
+ plateNumber: z.ZodOptional<z.ZodString>;
263
+ }, "strip", z.ZodTypeAny, {
264
+ firstName: string;
265
+ lastName: string;
266
+ password: string;
267
+ role: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN";
268
+ contactValue: string;
269
+ jacketId?: string | undefined;
270
+ plateNumber?: string | undefined;
271
+ gender?: "male" | "female" | undefined;
272
+ birthDate?: number | undefined;
273
+ birthMonth?: number | undefined;
274
+ birthYear?: number | undefined;
275
+ }, {
276
+ firstName: string;
277
+ lastName: string;
278
+ password: string;
279
+ role: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN";
280
+ contactValue: string;
281
+ jacketId?: string | undefined;
282
+ plateNumber?: string | undefined;
283
+ gender?: "male" | "female" | undefined;
284
+ birthDate?: number | undefined;
285
+ birthMonth?: number | undefined;
286
+ birthYear?: number | undefined;
287
+ }>;
288
+ }, "strip", z.ZodTypeAny, {
289
+ body: {
290
+ firstName: string;
291
+ lastName: string;
292
+ password: string;
293
+ role: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN";
294
+ contactValue: string;
295
+ jacketId?: string | undefined;
296
+ plateNumber?: string | undefined;
297
+ gender?: "male" | "female" | undefined;
298
+ birthDate?: number | undefined;
299
+ birthMonth?: number | undefined;
300
+ birthYear?: number | undefined;
301
+ };
302
+ }, {
303
+ body: {
304
+ firstName: string;
305
+ lastName: string;
306
+ password: string;
307
+ role: "RIDER" | "PASSENGER" | "ADMIN" | "AGENT" | "SUPER_ADMIN";
308
+ contactValue: string;
309
+ jacketId?: string | undefined;
310
+ plateNumber?: string | undefined;
311
+ gender?: "male" | "female" | undefined;
312
+ birthDate?: number | undefined;
313
+ birthMonth?: number | undefined;
314
+ birthYear?: number | undefined;
315
+ };
316
+ }>;
317
+ export declare const updateContactSchema: z.ZodObject<{
318
+ body: z.ZodObject<{
319
+ contactValue: z.ZodEffects<z.ZodString, string, string>;
320
+ }, "strip", z.ZodTypeAny, {
321
+ contactValue: string;
322
+ }, {
323
+ contactValue: string;
324
+ }>;
325
+ }, "strip", z.ZodTypeAny, {
326
+ body: {
327
+ contactValue: string;
328
+ };
329
+ }, {
330
+ body: {
331
+ contactValue: string;
332
+ };
333
+ }>;
334
+ export declare const addContactSchema: z.ZodObject<{
335
+ body: z.ZodObject<{
336
+ contactValue: z.ZodEffects<z.ZodString, string, string>;
337
+ type: z.ZodOptional<z.ZodEnum<["EMAIL", "PHONE", "WHATSAPP"]>>;
212
338
  }, "strip", z.ZodTypeAny, {
213
- phoneNumber: string;
339
+ contactValue: string;
340
+ type?: "EMAIL" | "PHONE" | "WHATSAPP" | undefined;
214
341
  }, {
215
- phoneNumber: string;
342
+ contactValue: string;
343
+ type?: "EMAIL" | "PHONE" | "WHATSAPP" | undefined;
216
344
  }>;
217
345
  }, "strip", z.ZodTypeAny, {
218
346
  body: {
219
- phoneNumber: string;
347
+ contactValue: string;
348
+ type?: "EMAIL" | "PHONE" | "WHATSAPP" | undefined;
220
349
  };
221
350
  }, {
222
351
  body: {
223
- phoneNumber: string;
352
+ contactValue: string;
353
+ type?: "EMAIL" | "PHONE" | "WHATSAPP" | undefined;
224
354
  };
225
355
  }>;
356
+ export type UserLoginSchema = z.infer<typeof userLoginSchema>;
357
+ export type ForgotPasswordSchema = z.infer<typeof forgotPasswordSchema>;
358
+ export type ChangePasswordSchema = z.infer<typeof changePasswordSchema>;
359
+ export type RefreshTokenSchema = z.infer<typeof refreshTokenSchema>;
360
+ export type RegisterSchema = z.infer<typeof registerSchema>;
361
+ export type RiderLoginSchema = z.infer<typeof riderLoginSchema>;
362
+ export type RequestOtpSchema = z.infer<typeof requestOtpSchema>;
363
+ export type VerifyOtpSchema = z.infer<typeof verifyOtpSchema>;
364
+ export type ResendOtpSchema = z.infer<typeof resendOtpSchema>;
365
+ export type CreateUserSchema = z.infer<typeof createUserSchema>;
366
+ export type UpdateContactSchema = z.infer<typeof updateContactSchema>;
367
+ export type AddContactSchema = z.infer<typeof addContactSchema>;
@@ -1,35 +1,72 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resendOtpSchema = exports.verifyOtpSchema = exports.requestOtpSchema = exports.riderLoginSchema = exports.registerSchema = exports.refreshTokenSchema = exports.changePasswordSchema = exports.forgotPasswordSchema = exports.userLoginSchema = exports.passwordRegex = exports.phoneRegex = void 0;
3
+ exports.addContactSchema = exports.updateContactSchema = exports.createUserSchema = exports.resendOtpSchema = exports.verifyOtpSchema = exports.requestOtpSchema = exports.riderLoginSchema = exports.registerSchema = exports.refreshTokenSchema = exports.changePasswordSchema = exports.forgotPasswordSchema = exports.userLoginSchema = exports.validateContactValue = exports.detectContactType = exports.strongPasswordRegex = exports.passwordRegex = exports.emailRegex = exports.phoneRegex = void 0;
4
4
  // src/validations/auth.schema.ts
5
5
  const zod_1 = require("zod");
6
+ // ==================== REGEX PATTERNS ====================
6
7
  exports.phoneRegex = /^\+250(78|79|73|72)[0-9]{7}$/;
8
+ exports.emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
7
9
  exports.passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,}$/;
10
+ exports.strongPasswordRegex = /^(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&#^()_\-+=])[A-Za-z\d@$!%*?&#^()_\-+=]{8,}$/;
11
+ // ==================== CONTACT VALIDATION HELPERS ====================
12
+ const detectContactType = (value) => {
13
+ if (!value)
14
+ return "UNKNOWN";
15
+ // Check if it's an email
16
+ if (exports.emailRegex.test(value)) {
17
+ return "EMAIL";
18
+ }
19
+ // Check if it's a phone number
20
+ if (exports.phoneRegex.test(value)) {
21
+ return "PHONE";
22
+ }
23
+ return "UNKNOWN";
24
+ };
25
+ exports.detectContactType = detectContactType;
26
+ const validateContactValue = (value) => {
27
+ return exports.emailRegex.test(value) || exports.phoneRegex.test(value);
28
+ };
29
+ exports.validateContactValue = validateContactValue;
8
30
  // ==================== ADMIN AUTH VALIDATIONS ====================
31
+ // Login with contact (email or phone)
9
32
  exports.userLoginSchema = zod_1.z.object({
10
33
  body: zod_1.z.object({
11
- email: zod_1.z.string().email(),
12
- password: zod_1.z.string().min(6),
34
+ contactValue: zod_1.z
35
+ .string()
36
+ .min(1, "Email or phone number is required")
37
+ .refine((val) => (0, exports.validateContactValue)(val), {
38
+ message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
39
+ }),
40
+ password: zod_1.z.string().min(6, "Password must be at least 6 characters"),
13
41
  }),
14
42
  });
43
+ // Forgot password with contact (email or phone)
15
44
  exports.forgotPasswordSchema = zod_1.z.object({
16
45
  body: zod_1.z.object({
17
- email: zod_1.z.string().email(),
46
+ contactValue: zod_1.z
47
+ .string()
48
+ .min(1, "Email or phone number is required")
49
+ .refine((val) => (0, exports.validateContactValue)(val), {
50
+ message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
51
+ }),
18
52
  }),
19
53
  });
54
+ // Change password (authenticated users)
20
55
  exports.changePasswordSchema = zod_1.z.object({
21
56
  body: zod_1.z.object({
22
57
  oldPassword: zod_1.z.string().min(1, "Old password is required"),
23
58
  newPassword: zod_1.z
24
59
  .string()
25
- .regex(exports.passwordRegex, "Password must be at least 6 characters with at least one letter and one number"),
60
+ .regex(exports.strongPasswordRegex, "Password must be at least 8 characters, include 1 uppercase letter, 1 number and 1 symbol"),
26
61
  }),
27
62
  });
63
+ // Refresh token
28
64
  exports.refreshTokenSchema = zod_1.z.object({
29
65
  body: zod_1.z.object({
30
66
  refreshToken: zod_1.z.string().min(1, "Refresh token is required"),
31
67
  }),
32
68
  });
69
+ // Register new user (public registration)
33
70
  exports.registerSchema = zod_1.z.object({
34
71
  body: zod_1.z
35
72
  .object({
@@ -41,39 +78,60 @@ exports.registerSchema = zod_1.z.object({
41
78
  .string()
42
79
  .min(2, "Last name must be at least 2 characters")
43
80
  .max(50, "Last name too long"),
44
- phoneNumber: zod_1.z.string().regex(exports.phoneRegex, "Invalid phone number format"),
45
- email: zod_1.z.string().email("Invalid email format").optional(),
81
+ contactValue: zod_1.z
82
+ .string()
83
+ .min(1, "Email or phone number is required")
84
+ .refine((val) => (0, exports.validateContactValue)(val), {
85
+ message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
86
+ }),
46
87
  password: zod_1.z
47
88
  .string()
48
- .regex(exports.passwordRegex, "Password must be at least 6 characters with at least one letter and one number"),
89
+ .regex(exports.strongPasswordRegex, "Password must be at least 8 characters, include 1 uppercase letter, 1 number and 1 symbol"),
90
+ role: zod_1.z.enum(["PASSENGER", "RIDER"]).optional().default("PASSENGER"),
91
+ gender: zod_1.z.enum(["male", "female"]).optional(),
92
+ birthDate: zod_1.z.number().min(1).max(31).optional(),
93
+ birthMonth: zod_1.z.number().min(1).max(12).optional(),
94
+ birthYear: zod_1.z.number().min(1900).max(new Date().getFullYear()).optional(),
49
95
  })
50
96
  .strict(),
51
97
  });
52
98
  // ==================== USER (RIDER/PASSENGER) AUTH VALIDATIONS ====================
99
+ // Rider login with contact
53
100
  exports.riderLoginSchema = zod_1.z.object({
54
101
  body: zod_1.z.object({
55
- phoneNumber: zod_1.z
102
+ contactValue: zod_1.z
56
103
  .string()
57
- .trim()
58
- .min(10, "Phone number must be at least 10 digits")
59
- .max(15, "Phone number must be at most 15 digits"),
60
- nationalId: zod_1.z.string().min(16, "National ID must be atleast 16 digits"),
104
+ .min(1, "Email or phone number is required")
105
+ .refine((val) => (0, exports.validateContactValue)(val), {
106
+ message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
107
+ }),
108
+ password: zod_1.z.string().min(6, "Password must be at least 6 characters"),
61
109
  }),
62
110
  query: zod_1.z.object({}).optional(),
63
111
  params: zod_1.z.object({}).optional(),
64
112
  headers: zod_1.z.object({}).optional(),
65
113
  });
114
+ // Request OTP (for phone verification)
66
115
  exports.requestOtpSchema = zod_1.z.object({
67
116
  body: zod_1.z.object({
68
- phoneNumber: zod_1.z
117
+ contactValue: zod_1.z
69
118
  .string()
70
- .regex(exports.phoneRegex, "Invalid phone number format. Use format: +250788123456"),
119
+ .min(1, "Email or phone number is required")
120
+ .refine((val) => (0, exports.validateContactValue)(val), {
121
+ message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
122
+ }),
71
123
  }),
72
124
  });
125
+ // Verify OTP with contact
73
126
  exports.verifyOtpSchema = zod_1.z.object({
74
127
  body: zod_1.z
75
128
  .object({
76
- phoneNumber: zod_1.z.string().regex(exports.phoneRegex, "Invalid phone number format"),
129
+ contactValue: zod_1.z
130
+ .string()
131
+ .min(1, "Email or phone number is required")
132
+ .refine((val) => (0, exports.validateContactValue)(val), {
133
+ message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
134
+ }),
77
135
  otp: zod_1.z.string().length(6, "OTP must be 6 digits"),
78
136
  firstName: zod_1.z
79
137
  .string()
@@ -87,14 +145,71 @@ exports.verifyOtpSchema = zod_1.z.object({
87
145
  .optional(),
88
146
  })
89
147
  .refine((data) => {
148
+ // If firstName and lastName are provided, they must be valid
149
+ if (data.firstName || data.lastName) {
150
+ return data.firstName && data.lastName;
151
+ }
90
152
  return true;
91
153
  }, {
92
- message: "First name and last name are required for new users",
154
+ message: "Both first name and last name are required for new users",
93
155
  path: ["firstName", "lastName"],
94
156
  }),
95
157
  });
158
+ // Resend OTP
96
159
  exports.resendOtpSchema = zod_1.z.object({
97
160
  body: zod_1.z.object({
98
- phoneNumber: zod_1.z.string().regex(exports.phoneRegex, "Invalid phone number format"),
161
+ contactValue: zod_1.z
162
+ .string()
163
+ .min(1, "Email or phone number is required")
164
+ .refine((val) => (0, exports.validateContactValue)(val), {
165
+ message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
166
+ }),
167
+ }),
168
+ });
169
+ // ==================== ADDITIONAL SCHEMAS ====================
170
+ // For administrators to create users
171
+ exports.createUserSchema = zod_1.z.object({
172
+ body: zod_1.z.object({
173
+ firstName: zod_1.z.string().min(2).max(50),
174
+ lastName: zod_1.z.string().min(2).max(50),
175
+ contactValue: zod_1.z
176
+ .string()
177
+ .min(1, "Email or phone number is required")
178
+ .refine((val) => (0, exports.validateContactValue)(val), {
179
+ message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
180
+ }),
181
+ password: zod_1.z
182
+ .string()
183
+ .regex(exports.strongPasswordRegex, "Password must be at least 8 characters, include 1 uppercase letter, 1 number and 1 symbol"),
184
+ role: zod_1.z.enum(["PASSENGER", "RIDER", "AGENT", "ADMIN", "SUPER_ADMIN"]),
185
+ gender: zod_1.z.enum(["male", "female"]).optional(),
186
+ birthDate: zod_1.z.number().min(1).max(31).optional(),
187
+ birthMonth: zod_1.z.number().min(1).max(12).optional(),
188
+ birthYear: zod_1.z.number().min(1900).max(new Date().getFullYear()).optional(),
189
+ jacketId: zod_1.z.string().optional(),
190
+ plateNumber: zod_1.z.string().optional(),
191
+ }),
192
+ });
193
+ // For users to update their own contact
194
+ exports.updateContactSchema = zod_1.z.object({
195
+ body: zod_1.z.object({
196
+ contactValue: zod_1.z
197
+ .string()
198
+ .min(1, "Email or phone number is required")
199
+ .refine((val) => (0, exports.validateContactValue)(val), {
200
+ message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
201
+ }),
202
+ }),
203
+ });
204
+ // For users to add a new contact
205
+ exports.addContactSchema = zod_1.z.object({
206
+ body: zod_1.z.object({
207
+ contactValue: zod_1.z
208
+ .string()
209
+ .min(1, "Email or phone number is required")
210
+ .refine((val) => (0, exports.validateContactValue)(val), {
211
+ message: "Invalid contact value. Must be a valid email or Rwandan phone number (+250...)",
212
+ }),
213
+ type: zod_1.z.enum(["EMAIL", "PHONE", "WHATSAPP"]).optional(),
99
214
  }),
100
215
  });
@@ -32,19 +32,19 @@ export declare const getUserRestrictionsSchema: z.ZodObject<{
32
32
  includeResolved?: "true" | "false" | undefined;
33
33
  }>;
34
34
  }, "strip", z.ZodTypeAny, {
35
- params: {
36
- userId: string;
37
- };
38
35
  query: {
39
36
  includeResolved?: "true" | "false" | undefined;
40
37
  };
41
- }, {
42
38
  params: {
43
39
  userId: string;
44
40
  };
41
+ }, {
45
42
  query: {
46
43
  includeResolved?: "true" | "false" | undefined;
47
44
  };
45
+ params: {
46
+ userId: string;
47
+ };
48
48
  }>;
49
49
  export declare const createBanSchema: z.ZodObject<{
50
50
  params: z.ZodObject<{
@@ -65,19 +65,19 @@ export declare const createBanSchema: z.ZodObject<{
65
65
  isPermanent?: boolean | undefined;
66
66
  }>;
67
67
  }, "strip", z.ZodTypeAny, {
68
- params: {
69
- userId: string;
70
- };
71
68
  body: {
72
69
  reason: string;
73
70
  isPermanent: boolean;
74
71
  };
75
- }, {
76
72
  params: {
77
73
  userId: string;
78
74
  };
75
+ }, {
79
76
  body: {
80
77
  reason: string;
81
78
  isPermanent?: boolean | undefined;
82
79
  };
80
+ params: {
81
+ userId: string;
82
+ };
83
83
  }>;