@lyxa.ai/types 1.4.342 → 1.4.344

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/README.md CHANGED
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.4.342
25
+ Version: 1.4.344
26
26
 
27
27
  ## Dependencies
28
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.4.342",
3
+ "version": "1.4.344",
4
4
  "description": "Lyxa type definitions and validation schemas for both frontend and backend",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -45,9 +45,9 @@ export type FilterDTO = z.infer<typeof FilterSchema>;
45
45
  export declare const StringSchema: z.ZodString;
46
46
  export declare const AddressSchema: z.ZodObject<{
47
47
  address: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
48
- description: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
49
- city: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
50
- state: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
48
+ description: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
49
+ city: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
50
+ state: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
51
51
  country: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
52
52
  location: z.ZodObject<{
53
53
  type: z.ZodDefault<z.ZodNativeEnum<typeof GeoLocationType>>;
@@ -92,9 +92,9 @@ export declare const AddressSchema: z.ZodObject<{
92
92
  export type AddressDTO = DTO<typeof AddressSchema>;
93
93
  export declare const UserAddressSchema: z.ZodObject<{
94
94
  address: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
95
- description: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
96
- city: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
97
- state: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
95
+ description: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
96
+ city: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
97
+ state: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
98
98
  country: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
99
99
  location: z.ZodObject<{
100
100
  type: z.ZodDefault<z.ZodNativeEnum<typeof GeoLocationType>>;
@@ -113,9 +113,12 @@ export declare const UserAddressSchema: z.ZodObject<{
113
113
  addressLabel: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
114
114
  apartment: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
115
115
  buildingName: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
116
- deliveryOption: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
117
- instructions: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
116
+ deliveryOption: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
117
+ instructions: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
118
118
  }, "strip", z.ZodTypeAny, {
119
+ addressLabel: string;
120
+ apartment: string;
121
+ buildingName: string;
119
122
  address: string;
120
123
  country: string;
121
124
  location: {
@@ -124,16 +127,16 @@ export declare const UserAddressSchema: z.ZodObject<{
124
127
  };
125
128
  latitude: number;
126
129
  longitude: number;
127
- addressLabel: string;
128
- apartment: string;
129
- buildingName: string;
130
+ deliveryOption?: string | undefined;
131
+ instructions?: string | undefined;
130
132
  description?: string | undefined;
131
133
  city?: string | undefined;
132
134
  state?: string | undefined;
133
135
  zone?: import("mongoose").Types.ObjectId | undefined;
134
- deliveryOption?: string | undefined;
135
- instructions?: string | undefined;
136
136
  }, {
137
+ addressLabel: string;
138
+ apartment: string;
139
+ buildingName: string;
137
140
  address: string;
138
141
  country: string;
139
142
  location: {
@@ -142,22 +145,19 @@ export declare const UserAddressSchema: z.ZodObject<{
142
145
  };
143
146
  latitude: number;
144
147
  longitude: number;
145
- addressLabel: string;
146
- apartment: string;
147
- buildingName: string;
148
+ deliveryOption?: string | undefined;
149
+ instructions?: string | undefined;
148
150
  description?: string | undefined;
149
151
  city?: string | undefined;
150
152
  state?: string | undefined;
151
153
  zone?: string | import("mongoose").Types.ObjectId | undefined;
152
- deliveryOption?: string | undefined;
153
- instructions?: string | undefined;
154
154
  }>;
155
155
  export type UserAddressDTO = DTO<typeof UserAddressSchema>;
156
156
  export declare const RegularOrderAddressSchema: z.ZodObject<{
157
157
  address: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
158
- description: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
159
- city: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
160
- state: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
158
+ description: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
159
+ city: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
160
+ state: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
161
161
  country: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
162
162
  location: z.ZodObject<{
163
163
  type: z.ZodDefault<z.ZodNativeEnum<typeof GeoLocationType>>;
@@ -176,12 +176,15 @@ export declare const RegularOrderAddressSchema: z.ZodObject<{
176
176
  addressLabel: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
177
177
  apartment: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
178
178
  buildingName: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
179
- deliveryOption: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
180
- instructions: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
179
+ deliveryOption: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
180
+ instructions: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
181
181
  } & {
182
182
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
183
183
  }, "strip", z.ZodTypeAny, {
184
184
  _id: import("mongoose").Types.ObjectId;
185
+ addressLabel: string;
186
+ apartment: string;
187
+ buildingName: string;
185
188
  address: string;
186
189
  country: string;
187
190
  location: {
@@ -190,17 +193,17 @@ export declare const RegularOrderAddressSchema: z.ZodObject<{
190
193
  };
191
194
  latitude: number;
192
195
  longitude: number;
193
- addressLabel: string;
194
- apartment: string;
195
- buildingName: string;
196
+ deliveryOption?: string | undefined;
197
+ instructions?: string | undefined;
196
198
  description?: string | undefined;
197
199
  city?: string | undefined;
198
200
  state?: string | undefined;
199
201
  zone?: import("mongoose").Types.ObjectId | undefined;
200
- deliveryOption?: string | undefined;
201
- instructions?: string | undefined;
202
202
  }, {
203
203
  _id: string | import("mongoose").Types.ObjectId;
204
+ addressLabel: string;
205
+ apartment: string;
206
+ buildingName: string;
204
207
  address: string;
205
208
  country: string;
206
209
  location: {
@@ -209,22 +212,19 @@ export declare const RegularOrderAddressSchema: z.ZodObject<{
209
212
  };
210
213
  latitude: number;
211
214
  longitude: number;
212
- addressLabel: string;
213
- apartment: string;
214
- buildingName: string;
215
+ deliveryOption?: string | undefined;
216
+ instructions?: string | undefined;
215
217
  description?: string | undefined;
216
218
  city?: string | undefined;
217
219
  state?: string | undefined;
218
220
  zone?: string | import("mongoose").Types.ObjectId | undefined;
219
- deliveryOption?: string | undefined;
220
- instructions?: string | undefined;
221
221
  }>;
222
222
  export type RegularOrderAddressDTO = DTO<typeof RegularOrderAddressSchema>;
223
223
  export declare const CourierAddressSchema: z.ZodObject<{
224
224
  address: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
225
- description: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
226
- city: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
227
- state: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
225
+ description: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
226
+ city: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
227
+ state: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
228
228
  country: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
229
229
  location: z.ZodObject<{
230
230
  type: z.ZodDefault<z.ZodNativeEnum<typeof GeoLocationType>>;
@@ -240,14 +240,15 @@ export declare const CourierAddressSchema: z.ZodObject<{
240
240
  longitude: z.ZodNumber;
241
241
  zone: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>>;
242
242
  addressLabel: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
243
- deliveryOption: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
244
- instructions: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
243
+ deliveryOption: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
244
+ instructions: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
245
245
  } & {
246
246
  name: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
247
247
  phoneNumber: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
248
- apartment: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
249
- buildingName: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
248
+ apartment: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
249
+ buildingName: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
250
250
  }, "strip", z.ZodTypeAny, {
251
+ addressLabel: string;
251
252
  address: string;
252
253
  country: string;
253
254
  location: {
@@ -256,18 +257,18 @@ export declare const CourierAddressSchema: z.ZodObject<{
256
257
  };
257
258
  latitude: number;
258
259
  longitude: number;
259
- addressLabel: string;
260
260
  name: string;
261
261
  phoneNumber: string;
262
- description?: string | undefined;
263
- city?: string | undefined;
264
- state?: string | undefined;
265
- zone?: import("mongoose").Types.ObjectId | undefined;
266
262
  apartment?: string | undefined;
267
263
  buildingName?: string | undefined;
268
264
  deliveryOption?: string | undefined;
269
265
  instructions?: string | undefined;
266
+ description?: string | undefined;
267
+ city?: string | undefined;
268
+ state?: string | undefined;
269
+ zone?: import("mongoose").Types.ObjectId | undefined;
270
270
  }, {
271
+ addressLabel: string;
271
272
  address: string;
272
273
  country: string;
273
274
  location: {
@@ -276,17 +277,16 @@ export declare const CourierAddressSchema: z.ZodObject<{
276
277
  };
277
278
  latitude: number;
278
279
  longitude: number;
279
- addressLabel: string;
280
280
  name: string;
281
281
  phoneNumber: string;
282
- description?: string | undefined;
283
- city?: string | undefined;
284
- state?: string | undefined;
285
- zone?: string | import("mongoose").Types.ObjectId | undefined;
286
282
  apartment?: string | undefined;
287
283
  buildingName?: string | undefined;
288
284
  deliveryOption?: string | undefined;
289
285
  instructions?: string | undefined;
286
+ description?: string | undefined;
287
+ city?: string | undefined;
288
+ state?: string | undefined;
289
+ zone?: string | import("mongoose").Types.ObjectId | undefined;
290
290
  }>;
291
291
  export type CourierAddressDTO = DTO<typeof CourierAddressSchema>;
292
292
  export declare const DurationSchema: z.ZodObject<{
@@ -510,7 +510,7 @@ export declare const WorkHourSettingSchema: z.ZodObject<{
510
510
  export declare const LoginSchema: z.ZodObject<{
511
511
  email: z.ZodEffects<z.ZodString, string, string>;
512
512
  password: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
513
- deviceId: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
513
+ deviceId: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
514
514
  }, "strip", z.ZodTypeAny, {
515
515
  email: string;
516
516
  password: string;
@@ -920,8 +920,8 @@ export declare const UpdateFcmTokenInputSchema: z.ZodObject<{
920
920
  fcmToken: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
921
921
  action: z.ZodNativeEnum<typeof ActionType>;
922
922
  platform: z.ZodOptional<z.ZodNativeEnum<typeof AppPlatform>>;
923
- appVersion: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
924
- deviceId: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
923
+ appVersion: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
924
+ deviceId: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
925
925
  }, "strip", z.ZodTypeAny, {
926
926
  fcmToken: string;
927
927
  action: ActionType;
@@ -949,9 +949,9 @@ export declare const AssignRiderSchema: z.ZodObject<{
949
949
  export type AssignRiderDTO = DTO<typeof AssignRiderSchema>;
950
950
  export declare const PaymentInformationSchema: z.ZodObject<{
951
951
  cardType: z.ZodDefault<z.ZodNativeEnum<typeof CardType>>;
952
- paymentIntentId: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
953
- orderId: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
954
- transactionId: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
952
+ paymentIntentId: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
953
+ orderId: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
954
+ transactionId: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
955
955
  }, "strip", z.ZodTypeAny, {
956
956
  cardType: CardType;
957
957
  paymentIntentId?: string | undefined;
@@ -15,6 +15,16 @@ export declare class ZodValidation {
15
15
  isNegative?: boolean;
16
16
  isNonnegative?: boolean;
17
17
  }): z.ZodNumber;
18
+ static numberWithRefinement(field?: string, options?: {
19
+ min?: number;
20
+ max?: number;
21
+ isInt?: boolean;
22
+ isPositive?: boolean;
23
+ isNonpositive?: boolean;
24
+ isNegative?: boolean;
25
+ isNonnegative?: boolean;
26
+ decimalPlaces?: number;
27
+ }): z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
18
28
  static string(field?: string, options?: {
19
29
  minLength?: number;
20
30
  maxLength?: number;
@@ -75,6 +75,16 @@ class ZodValidation {
75
75
  }
76
76
  return schema;
77
77
  }
78
+ static numberWithRefinement(field = 'Field', options) {
79
+ let schema = ZodValidation.number(field, options);
80
+ if (options?.decimalPlaces !== undefined) {
81
+ const multiplier = 10 ** options.decimalPlaces;
82
+ schema = schema.refine(value => Math.abs(value * multiplier - Math.round(value * multiplier)) < Number.EPSILON, {
83
+ message: `${field} must have at most ${options.decimalPlaces} decimal place${options.decimalPlaces === 1 ? '' : 's'}`,
84
+ });
85
+ }
86
+ return schema;
87
+ }
78
88
  static string(field = 'Field', options) {
79
89
  let schema = zod_1.z.string({
80
90
  required_error: options?.requiredMessage || `${field} is required`,
@@ -1 +1 @@
1
- {"version":3,"file":"global-validation.js","sourceRoot":"/","sources":["utilities/validation/global-validation.ts"],"names":[],"mappings":";;;AAi2BA,kDAMC;AAv2BD,6BAAwB;AACxB,oDAAgD;AAChD,yDAA+D;AAgB/D,MAAa,aAAa;IAczB,MAAM,CAAC,sBAAsB,GAAG,OAAC,CAAC,MAAM,CACvC,GAAG,CAAC,EAAE;QACL,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;QAC1E,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,YAAY,oBAAQ,CAAC,KAAK,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAC;QACnF,OAAO,KAAK,CAAC;IACd,CAAC,EACD,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAC/B,CAAC;IAEF,MAAM,CAAC,QAAQ,CAAC,QAAgB,OAAO;QACtC,OAAO,OAAC,CAAC,KAAK,CACb;YACC,OAAC;iBACC,MAAM,CAAC,EAAE,cAAc,EAAE,GAAG,KAAK,cAAc,EAAE,CAAC;iBAClD,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBACpD,OAAO,EAAE,GAAG,KAAK,2BAA2B;aAC5C,CAAC;iBACD,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YACpD,OAAC,CAAC,UAAU,CAAC,oBAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE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ACf,CAAC;IAmBD,aAAa,CAAC,iBAAqC;QAClD,OAAO;YACN,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE;YAChC,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE;YACpC,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE;YAC5B,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAC;YACrD,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE;SACpC,CAAC;IACH,CAAC;CACD;AAlND,sCAkNC;AA8CD,SAAgB,mBAAmB,CAClC,UAAa,EACb,oBAA6B,IAAI,EACjC,kBAA2B,KAAK;IAEhC,OAAO,IAAI,aAAa,CAAC,UAAU,EAAE,iBAAiB,EAAE,eAAe,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["import { z } from 'zod';\nimport { mongoose } from '@typegoose/typegoose';\nimport { parsePhoneNumberFromString } from 'libphonenumber-js';\nimport { Require_id, FlattenMaps } from 'mongoose';\n\n/**\n * Enhanced validation utilities for creating robust Zod schemas.\n * This class provides a collection of static methods to create common validation patterns.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * username: ZodValidation.requiredString(\"Username is required\"),\n * email: ZodValidation.email(),\n * role: ZodValidation.enumType(UserRole)\n * });\n * ```\n */\nexport class ZodValidation {\n\t/**\n\t * Creates a union type that accepts both string ObjectId and mongoose ObjectId instance.\n\t * This is useful when dealing with both raw string IDs and Mongoose ObjectId instances.\n\t *\n\t * @param field - The name of the field to be included in the error message\n\t * @returns A Zod union schema that accepts both string and ObjectId\n\t *\n\t * @example\n\t * ```typescript\n\t * const idSchema = ZodValidation.objectIdUnion();\n\t * // Accepts \"507f1f77bcf86cd799439011\" or new mongoose.Types.ObjectId(\"507f1f77bcf86cd799439011\")\n\t * ```\n\t */\n\tstatic objectIdOrStringSchema = z.custom<mongoose.Types.ObjectId | string>(\n\t\tval => {\n\t\t\tif (typeof val === 'string' && /^[0-9a-fA-F]{24}$/.test(val)) return true;\n\t\t\tif (typeof val === 'object' && val instanceof mongoose.Types.ObjectId) return true;\n\t\t\treturn false;\n\t\t},\n\t\t{ message: 'Invalid ObjectId' }\n\t);\n\n\tstatic objectId(field: string = 'Field') {\n\t\treturn z.union(\n\t\t\t[\n\t\t\t\tz\n\t\t\t\t\t.string({ required_error: `${field} is required` })\n\t\t\t\t\t.refine(val => mongoose.Types.ObjectId.isValid(val), {\n\t\t\t\t\t\tmessage: `${field} must be a valid ObjectID`,\n\t\t\t\t\t})\n\t\t\t\t\t.transform(val => new mongoose.Types.ObjectId(val)),\n\t\t\t\tz.instanceof(mongoose.Types.ObjectId, {\n\t\t\t\t\tmessage: `${field} must be a valid ObjectID`,\n\t\t\t\t}),\n\t\t\t],\n\t\t\t{ message: `${field} is required` }\n\t\t);\n\t}\n\n\tstatic objectIdStringWithTransform(field: string = 'Field') {\n\t\treturn z.string().transform((val, ctx) => {\n\t\t\tif (!mongoose.Types.ObjectId.isValid(val)) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\t\t\tmessage: `${field} must be a valid ObjectID.`,\n\t\t\t\t});\n\t\t\t\treturn z.NEVER;\n\t\t\t}\n\t\t\treturn new mongoose.Types.ObjectId(val);\n\t\t});\n\t}\n\n\t/**\n\t * Creates an enum validation with custom error message.\n\t * This validates that a value is one of the values defined in the enum.\n\t *\n\t * @template T - Type of the enum\n\t * @param enumObj - The enum object to validate against\n\t * @param field - The name of the field to be included in the error message\n\t * @returns A Zod schema that validates against the provided enum\n\t *\n\t * @example\n\t * ```typescript\n\t * enum UserRole { ADMIN = \"admin\", USER = \"user\" }\n\t * const roleSchema = ZodValidation.enumType(UserRole, \"Invalid user role\");\n\t * ```\n\t */\n\tstatic enumType<T extends z.EnumLike>(enumObj: T, field: string = 'Field') {\n\t\treturn z.nativeEnum(enumObj, {\n\t\t\tmessage: `${field} must be one of: ${Object.values(enumObj).join(', ')}`,\n\t\t});\n\t}\n\n\t/**\n\t * Creates a required number validation with a minimum length.\n\t * The number is also trimmed to remove leading/trailing whitespace.\n\t *\n\t * @param field - The name of the field to be included in the error message\n\t * @param min - Minimum number (optional)\n\t * @param max - MAximum number (optional)\n\t * @param options - options (optional)\n\t * @returns A Zod schema that validates numbers with minimum length\n\t *\n\t * @example\n\t * ```typescript\n\t * const nameSchema = ZodValidation.Number(\"Price\");\n\t * ```\n\t */\n\tstatic number(\n\t\tfield: string = 'Field',\n\t\toptions?: {\n\t\t\tmin?: number;\n\t\t\tmax?: number;\n\t\t\tisInt?: boolean;\n\t\t\tisPositive?: boolean;\n\t\t\tisNonpositive?: boolean;\n\t\t\tisNegative?: boolean;\n\t\t\tisNonnegative?: boolean;\n\t\t}\n\t) {\n\t\tlet schema = z.number({\n\t\t\trequired_error: `${field} is required`,\n\t\t\tinvalid_type_error: `${field} must be a number`,\n\t\t});\n\n\t\t// Range validation\n\t\tif (options?.min !== undefined) {\n\t\t\tschema = schema.gte(options?.min, {\n\t\t\t\tmessage: `${field} must be at least ${options?.min}`,\n\t\t\t});\n\t\t}\n\t\tif (options?.max !== undefined) {\n\t\t\tschema = schema.lte(options?.max, {\n\t\t\t\tmessage: `${field} must be at most ${options?.max}`,\n\t\t\t});\n\t\t}\n\n\t\t// Option validation\n\t\tif (options?.isInt) {\n\t\t\tschema = schema.int({ message: `${field} must be an integer` });\n\t\t}\n\t\tif (options?.isPositive) {\n\t\t\tschema = schema.positive({ message: `${field} must be positive` });\n\t\t}\n\t\tif (options?.isNonpositive) {\n\t\t\tschema = schema.nonpositive({ message: `${field} must be non-positive` });\n\t\t}\n\t\tif (options?.isNegative) {\n\t\t\tschema = schema.negative({ message: `${field} must be negative` });\n\t\t}\n\t\tif (options?.isNonnegative) {\n\t\t\tschema = schema.nonnegative({ message: `${field} must be non-negative` });\n\t\t}\n\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Creates a required string validation with a minimum length.\n\t * The string is also trimmed to remove leading/trailing whitespace.\n\t *\n\t * @param field - The name of the field to be included in the error message\n\t * @param minLength - Minimum required length (optional)\n\t * @param maxLength - Maximum required length (optional)\n\t * @param regex - Regular expression (optional)\n\t * @returns A Zod schema that validates strings with minimum length\n\t *\n\t * @example\n\t * ```typescript\n\t * const nameSchema = ZodValidation.String(\"Name\");\n\t * ```\n\t */\n\tstatic string(\n\t\tfield: string = 'Field',\n\t\toptions?: {\n\t\t\tminLength?: number;\n\t\t\tmaxLength?: number;\n\t\t\tminMessage?: string;\n\t\t\tmaxMessage?: string;\n\t\t\trequiredMessage?: string;\n\t\t\tregex?: { pattern: RegExp; message: string }; // Add regex option\n\t\t\tisTrimmed?: boolean;\n\t\t}\n\t) {\n\t\tlet schema = z.string({\n\t\t\trequired_error: options?.requiredMessage || `${field} is required`,\n\t\t});\n\n\t\tif (options?.minLength) {\n\t\t\tschema = schema.min(\n\t\t\t\toptions.minLength,\n\t\t\t\toptions.minMessage || `${field} must be at least ${options.minLength} characters`\n\t\t\t);\n\t\t}\n\n\t\tif (options?.maxLength) {\n\t\t\tschema = schema.max(\n\t\t\t\toptions.maxLength,\n\t\t\t\toptions.maxMessage || `${field} shouldn’t exceed ${options.maxLength} characters`\n\t\t\t);\n\t\t}\n\n\t\t// Check for regex pattern and add regex validation\n\t\tif (options?.regex) {\n\t\t\tschema = schema.regex(options.regex.pattern, options.regex.message);\n\t\t}\n\n\t\tif (options?.isTrimmed) {\n\t\t\treturn schema\n\t\t\t\t.transform(val => val?.trim())\n\t\t\t\t.refine(val => val?.length && val?.length > 0, {\n\t\t\t\t\tmessage: options?.requiredMessage || `${field} is required`,\n\t\t\t\t});\n\t\t}\n\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Creates an email validation.\n\t * Validates that the string is a valid email address format.\n\t *\n\t * @param field - The name of the field to be included in the error message\n\t * @returns A Zod schema that validates email addresses\n\t *\n\t * @example\n\t * ```typescript\n\t * const emailSchema = ZodValidation.email(\"Please enter a valid email\");\n\t * ```\n\t */\n\tstatic email(\n\t\tfield: string = 'Email',\n\t\toptions?: {\n\t\t\trequiredMessage?: string;\n\t\t\tinvalidMessage?: string;\n\t\t}\n\t) {\n\t\tconst schema = z\n\t\t\t.string({\n\t\t\t\trequired_error: options?.requiredMessage || `${field} is required`,\n\t\t\t})\n\t\t\t.trim()\n\t\t\t.email(options?.invalidMessage || `${field} must be a valid email address`)\n\t\t\t.transform(value => value.toLowerCase());\n\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Creates a URL validation.\n\t * Validates that the string is a valid URL format.\n\t *\n\t * @param field - The name of the field to be included in the error message\n\t * @returns A Zod schema that validates URLs\n\t *\n\t * @example\n\t * ```typescript\n\t * const websiteSchema = ZodValidation.url(\"Please enter a valid URL\");\n\t * ```\n\t */\n\tstatic url(field: string = 'Field') {\n\t\treturn z.string({ required_error: `${field} is required` }).url(`${field} must be a valid URL`);\n\t}\n\n\t/**\n\t * Creates a Password validation.\n\t * Validates that the string is a valid password format.\n\t *\n\t * @param field - The name of the field to be included in the error message\n\t * @returns A Zod schema that validates password\n\t *\n\t * @example\n\t * ```typescript\n\t * const websiteSchema = ZodValidation.password(\"Please enter a valid password\");\n\t * ```\n\t */\n\tstatic password(field: string = 'Field') {\n\t\treturn z.string({ required_error: `${field} is required` }).refine(\n\t\t\tval =>\n\t\t\t\t!val || // allow undefined or empty, but validate when provided\n\t\t\t\t(val.length >= 8 && // minimum length\n\t\t\t\t\t/[a-z]/.test(val) && // lowercase\n\t\t\t\t\t/[A-Z]/.test(val) && // uppercase\n\t\t\t\t\t/[0-9]/.test(val) && // number\n\t\t\t\t\t/[!@#$%^&*(),.?\":{}|<>]/.test(val)), // special char\n\t\t\t{\n\t\t\t\tmessage:\n\t\t\t\t\t'Password must include at least one uppercase letter, one lowercase letter, one number, one special character and minimum 8 character required',\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Creates a phone number validation schema using a regex pattern for global phone numbers.\n\t *\n\t * @param field - The name of the field to be included in the error message\n\t * @returns A Zod schema that validates phone numbers\n\t *\n\t * @example\n\t * ```typescript\n\t * const phoneSchema = ZodValidation.phoneNumber(\"Phone number\");\n\t * ```\n\t */\n\n\tstatic phoneNumber(field: string = 'Field') {\n\t\treturn z.string({ required_error: `${field} is required` }).refine(\n\t\t\tvalue => {\n\t\t\t\ttry {\n\t\t\t\t\tconst phone = parsePhoneNumberFromString(value);\n\t\t\t\t\treturn phone?.isValid();\n\t\t\t\t} catch {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\tmessage: `Please enter a valid phone number`,\n\t\t\t}\n\t\t);\n\t}\n\n\tstatic validPhoneNumber(field: string = 'Field') {\n\t\treturn z.string({ required_error: `${field} is required` }).superRefine((phoneWithCountryCode, ctx) => {\n\t\t\tconst phoneWithoutCountryCode = phoneWithCountryCode.replace(/^\\+\\d{1,3}/, '');\n\t\t\tif (phoneWithoutCountryCode.length < 4) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\t\t\tmessage: `${field} must have 4 or more digits`,\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (/^\\d{4}$|^\\d{5}$|^\\d{7}$|^\\d{8}$/.test(phoneWithoutCountryCode)) {\n\t\t\t\treturn; // ✅ Accept 4,5,7 or 8 digit short numbers\n\t\t\t}\n\t\t\t// Otherwise, parse as real phone number\n\t\t\tconst phone = parsePhoneNumberFromString(phoneWithCountryCode);\n\t\t\tif (!phone) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\t\t\tmessage: `Invalid phone number format in ${field}`,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!phone.isValid()) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\t\t\tmessage: `Please enter a valid phone number in ${field}`,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Creates a date validation.\n\t * Validates that the input is a JavaScript Date object.\n\t *@param field - The name of the field to be included in the error message\n\t *@param minDate - Minimum required date (optional)\n\t *@param maxDate - Maximum required date (optional)\n\t * @returns A Zod schema that validates Date objects\n\t *\n\t * @example\n\t * ```typescript\n\t * const createdAtSchema = ZodValidation.date();\n\t * ```\n\t */\n\tstatic date(field: string = 'Field', minDate?: Date, maxDate?: Date) {\n\t\treturn z\n\t\t\t.union(\n\t\t\t\t[\n\t\t\t\t\tz\n\t\t\t\t\t\t.string({ required_error: `${field} is required` })\n\t\t\t\t\t\t.refine(val => {\n\t\t\t\t\t\t\tconst date = new Date(val);\n\t\t\t\t\t\t\treturn !isNaN(date.getTime());\n\t\t\t\t\t\t}, `${field} must be a valid date`)\n\t\t\t\t\t\t.transform(val => new Date(val)),\n\t\t\t\t\tz.date({\n\t\t\t\t\t\trequired_error: `${field} is required`,\n\t\t\t\t\t\tinvalid_type_error: `${field} must be a valid date`,\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\t{ message: `${field} is required` }\n\t\t\t)\n\t\t\t.refine(\n\t\t\t\tval => minDate === undefined || val >= minDate,\n\t\t\t\t`${field} must be on or after ${minDate?.toISOString()}`\n\t\t\t)\n\t\t\t.refine(\n\t\t\t\tval => maxDate === undefined || val <= maxDate,\n\t\t\t\t`${field} must be on or before ${maxDate?.toISOString()}`\n\t\t\t);\n\t}\n\n\t/**\n\t * Creates a boolean validation with an optional default value.\n\t *\n\t * @param field - The name of the field to be included in the error message\n\t * @returns A Zod schema that validates booleans\n\t *\n\t * @example\n\t * ```typescript\n\t * const isActiveSchema = ZodValidation.boolean(true); // Defaults to true\n\t * ```\n\t */\n\tstatic boolean(field: string = 'Field') {\n\t\treturn z.boolean({\n\t\t\trequired_error: `${field} is required`,\n\t\t\tinvalid_type_error: `${field} must be a boolean`,\n\t\t});\n\t}\n\n\t/**\n\t * Creates an array validation with optional minimum items constraint.\n\t *\n\t * @template T - Type of the schema for array items\n\t * @param schema - The schema for validating array items\n\t * @param field - The name of the field to be included in the error message\n\t * @param minItems - Minimum number of items required (optional)\n\t * @param maxItems - Maximum number of items required (optional)\n\t * @returns A Zod schema that validates arrays\n\t *\n\t * @example\n\t * ```typescript\n\t * const tagsSchema = ZodValidation.array(z.string(), \"At least one tag required\", 1);\n\t * ```\n\t */\n\tstatic array<T extends z.ZodTypeAny>(\n\t\tschema: T,\n\t\tfield: string = 'Array',\n\t\tminItems?: number,\n\t\tmaxItems?: number\n\t) {\n\t\tlet arraySchema = z.array(schema, {\n\t\t\trequired_error: `${field} is required`,\n\t\t});\n\n\t\tif (minItems === 1) {\n\t\t\tarraySchema = arraySchema.min(1, `${field} cannot be empty`);\n\t\t}\n\t\tif (minItems !== undefined && minItems !== 1) {\n\t\t\tarraySchema = arraySchema.min(minItems, `${field} must have at least ${minItems} items`);\n\t\t}\n\t\tif (maxItems !== undefined) {\n\t\t\tarraySchema = arraySchema.max(maxItems, `${field} must have at most ${maxItems} items`);\n\t\t}\n\n\t\treturn arraySchema;\n\t}\n\n\t/**\n\t * Standard timestamp fields for entities.\n\t * Includes createdAt, updatedAt, and deletedAt fields.\n\t *\n\t * @returns An object containing timestamp field schemas\n\t *\n\t * @example\n\t * ```typescript\n\t * const userSchema = z.object({\n\t * name: z.string(),\n\t * ...ZodValidation.timestamps()\n\t * });\n\t * ```\n\t */\n\tstatic timestamps() {\n\t\treturn {\n\t\t\tcreatedAt: z.date().nullable().optional(),\n\t\t\tupdatedAt: z.date().nullable().optional(),\n\t\t\tdeletedAt: z.date().nullable().optional(),\n\t\t};\n\t}\n\n\t/**\n\t * Common fields for tracking model metadata.\n\t * Includes timestamps and user tracking fields (createdBy, updatedBy, deletedBy).\n\t *\n\t * @returns An object containing tracking field schemas\n\t *\n\t * @example\n\t * ```typescript\n\t * const postSchema = z.object({\n\t * title: z.string(),\n\t * content: z.string(),\n\t * ...ZodValidation.trackingFields()\n\t * });\n\t * ```\n\t */\n\tstatic trackingFields() {\n\t\treturn {\n\t\t\tcreatedBy: ZodValidation.objectId().optional(),\n\t\t\tupdatedBy: ZodValidation.objectId().optional(),\n\t\t\tdeletedBy: ZodValidation.objectId().optional(),\n\t\t\t...ZodValidation.timestamps(),\n\t\t};\n\t}\n\n\t/**\n\t * Namespace for coercion-based Zod validators.\n\t * Provides schemas that automatically convert input types to the expected type.\n\t *\n\t * @example\n\t * ```typescript\n\t * const schema = z.object({\n\t * startDate: ZodValidation.coerce.date(\"Start Date\"),\n\t * age: ZodValidation.coerce.number(\"Age\", { min: 18 }),\n\t * isActive: ZodValidation.coerce.boolean(\"Active\"),\n\t * });\n\t * ```\n\t */\n\tstatic coerce = {\n\t\tnumber: (\n\t\t\tfield: string = 'Field',\n\t\t\toptions?: {\n\t\t\t\tmin?: number;\n\t\t\t\tmax?: number;\n\t\t\t\tisInt?: boolean;\n\t\t\t\tisPositive?: boolean;\n\t\t\t\tisNonpositive?: boolean;\n\t\t\t\tisNegative?: boolean;\n\t\t\t\tisNonnegative?: boolean;\n\t\t\t}\n\t\t) => {\n\t\t\tlet schema = z.coerce.number({\n\t\t\t\trequired_error: `${field} is required`,\n\t\t\t\tinvalid_type_error: `${field} must be a number`,\n\t\t\t});\n\n\t\t\tif (options?.min !== undefined) {\n\t\t\t\tschema = schema.gte(options.min, { message: `${field} must be at least ${options.min}` });\n\t\t\t}\n\t\t\tif (options?.max !== undefined) {\n\t\t\t\tschema = schema.lte(options.max, { message: `${field} must be at most ${options.max}` });\n\t\t\t}\n\t\t\tif (options?.isInt) schema = schema.int({ message: `${field} must be an integer` });\n\t\t\tif (options?.isPositive) schema = schema.positive({ message: `${field} must be positive` });\n\t\t\tif (options?.isNonpositive) schema = schema.nonpositive({ message: `${field} must be non-positive` });\n\t\t\tif (options?.isNegative) schema = schema.negative({ message: `${field} must be negative` });\n\t\t\tif (options?.isNonnegative) schema = schema.nonnegative({ message: `${field} must be non-negative` });\n\n\t\t\treturn schema;\n\t\t},\n\n\t\tdate: (field: string = 'Field', minDate?: Date, maxDate?: Date) => {\n\t\t\treturn z.coerce\n\t\t\t\t.date({\n\t\t\t\t\trequired_error: `${field} is required`,\n\t\t\t\t\tinvalid_type_error: `${field} must be a valid date`,\n\t\t\t\t})\n\t\t\t\t.refine(val => minDate === undefined || val >= minDate, {\n\t\t\t\t\tmessage: `${field} must be on or after ${minDate?.toISOString()}`,\n\t\t\t\t})\n\t\t\t\t.refine(val => maxDate === undefined || val <= maxDate, {\n\t\t\t\t\tmessage: `${field} must be on or before ${maxDate?.toISOString()}`,\n\t\t\t\t});\n\t\t},\n\n\t\tboolean: (field: string = 'Field') => {\n\t\t\treturn z.coerce.boolean({\n\t\t\t\trequired_error: `${field} is required`,\n\t\t\t\tinvalid_type_error: `${field} must be true or false`,\n\t\t\t});\n\t\t},\n\t\tobjectId: (field: string = 'Field') =>\n\t\t\tz\n\t\t\t\t.custom<mongoose.Types.ObjectId>(\n\t\t\t\t\tval => {\n\t\t\t\t\t\tif (typeof val === 'string' && mongoose.Types.ObjectId.isValid(val)) return true;\n\t\t\t\t\t\tif (val instanceof mongoose.Types.ObjectId) return true;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t},\n\t\t\t\t\t{ message: `${field} must be a valid ObjectId` }\n\t\t\t\t)\n\t\t\t\t.transform(val => (typeof val === 'string' ? new mongoose.Types.ObjectId(val) : val)),\n\t};\n}\n\n/**\n * Represents the common fields to exclude from update operations.\n * This is used to specify which fields should not be updateable.\n *\n * @example\n * ```typescript\n * const excludeFields: ExcludeFromUpdate = {\n * createdAt: true,\n * createdBy: true,\n * status: true // Prevent status from being updated\n * };\n * ```\n */\nexport type ExcludeFromUpdate = {\n\tcreatedAt?: true;\n\tupdatedAt?: true;\n\tdeletedAt?: true;\n\tcreatedBy?: true;\n\t_id?: true;\n} & Record<string, true>;\n\n/**\n * Schema builder for creating consistent CRUD schemas.\n * Provides utility methods to generate schemas for create, read, update, and delete operations.\n *\n * @template T - Type of the base schema shape\n *\n * @example\n * ```typescript\n * const userBuilder = new SchemaBuilder({\n * name: z.string(),\n * email: z.string().email()\n * });\n *\n * const schemas = userBuilder.getAllSchemas();\n * ```\n */\nexport class SchemaBuilder<T extends z.ZodRawShape> {\n\tprivate baseSchema: z.ZodObject<T>;\n\n\t/**\n\t * Create a new schema builder\n\t *\n\t * @param baseFields - The base fields for the schema\n\t * @param includeTimestamps - Whether to include timestamp fields (default: true)\n\t * @param includeTracking - Whether to include tracking fields (createdBy, etc.) (default: false)\n\t *\n\t * @example\n\t * ```typescript\n\t * const userFields = {\n\t * name: ZodValidation.requiredString(),\n\t * email: ZodValidation.email()\n\t * };\n\t *\n\t * // With timestamps\n\t * const builder1 = new SchemaBuilder(userFields);\n\t *\n\t * // Without timestamps\n\t * const builder2 = new SchemaBuilder(userFields, false);\n\t *\n\t * // With tracking fields\n\t * const builder3 = new SchemaBuilder(userFields, true, true);\n\t * ```\n\t */\n\tconstructor(\n\t\tbaseFields: T,\n\t\tprivate includeTimestamps: boolean = true,\n\t\tprivate includeTracking: boolean = false\n\t) {\n\t\tthis.baseSchema = this.createBaseSchema(baseFields);\n\t}\n\n\t/**\n\t * Creates the base schema with optional timestamps and tracking fields.\n\t */\n\tprivate createBaseSchema(baseFields: T) {\n\t\tconst additionalFields = this.includeTracking\n\t\t\t? ZodValidation.trackingFields()\n\t\t\t: this.includeTimestamps\n\t\t\t\t? ZodValidation.timestamps()\n\t\t\t\t: {};\n\n\t\treturn z.object({\n\t\t\t...baseFields,\n\t\t\t...additionalFields,\n\t\t});\n\t}\n\n\t/**\n\t * Gets the base validation schema without ID.\n\t * Used for creating new entities.\n\t *\n\t * @returns The base schema for creating new entities\n\t *\n\t * @example\n\t * ```typescript\n\t * const createUserSchema = userBuilder.getBaseSchema();\n\t * ```\n\t */\n\tgetBaseSchema() {\n\t\treturn this.baseSchema.strict();\n\t}\n\n\t/**\n\t * Gets the schema for entities with ID.\n\t * Used for representing complete entities with their ID.\n\t *\n\t * @returns The entity schema including ID\n\t *\n\t * @example\n\t * ```typescript\n\t * const userSchema = userBuilder.getEntitySchema();\n\t * ```\n\t */\n\tgetEntitySchema() {\n\t\treturn this.baseSchema\n\t\t\t.extend({\n\t\t\t\t_id: ZodValidation.objectId(),\n\t\t\t})\n\t\t\t.partial()\n\t\t\t.passthrough();\n\t}\n\n\t/**\n\t * Gets the schema for validating an entity ID.\n\t * Used for validating ID parameters in requests.\n\t *\n\t * @returns The ID validation schema\n\t *\n\t * @example\n\t * ```typescript\n\t * const userIdSchema = userBuilder.getIdSchema();\n\t * ```\n\t */\n\tgetIdSchema() {\n\t\treturn ZodValidation.objectId();\n\t}\n\n\t/**\n\t * Gets the schema for updating an entity, excluding specified fields.\n\t * Creates a partial schema where all fields are optional, and removes\n\t * fields that should not be updatable.\n\t *\n\t * @param excludeFields - Fields to exclude from update operations\n\t * @returns The update schema with excluded fields removed\n\t *\n\t * @example\n\t * ```typescript\n\t * // Prevent updating createdAt and status\n\t * const updateUserSchema = userBuilder.getUpdateSchema({\n\t * createdAt: true,\n\t * status: true\n\t * });\n\t * ```\n\t */\n\tgetUpdateSchema(excludeFields: ExcludeFromUpdate = { createdAt: true, updatedAt: true }) {\n\t\tconst entitySchema = this.getEntitySchema();\n\n\t\t// Simple approach - just make everything optional\n\t\tif (Object.keys(excludeFields).length === 0) {\n\t\t\treturn entitySchema;\n\t\t}\n\n\t\t// For the type-safe approach, we need to create a new schema\n\t\t// without the excluded fields and then make it partial\n\n\t\t// Get all fields from the entity schema\n\t\tconst shape = entitySchema._def.shape();\n\n\t\t// Filter out the fields we want to exclude\n\t\tconst filteredShape: z.ZodRawShape = {};\n\t\tfor (const key in shape) {\n\t\t\tif (!excludeFields[key as keyof typeof excludeFields]) {\n\t\t\t\tfilteredShape[key] = shape[key];\n\t\t\t}\n\t\t}\n\n\t\t// Create a new schema with the filtered fields\n\t\treturn z.object(filteredShape).partial().strict();\n\t}\n\n\t/**\n\t * Gets the schema for validating a delete request.\n\t * Used for validating parameters in delete requests, including the entity ID and soft delete flag.\n\t *\n\t * @returns The delete validation schema\n\t *\n\t * @example\n\t * ```typescript\n\t * const deleteSchema = userBuilder.getDeleteSchema();\n\t * ```\n\t */\n\tgetDeleteSchema() {\n\t\treturn z.object({\n\t\t\t_id: ZodValidation.objectId('_id'),\n\t\t\tsoftDelete: ZodValidation.boolean('Soft Delete').default(true),\n\t\t});\n\t}\n\n\t/**\n\t * Creates an update schema by optionally extending the base schema with additional fields\n\t * and optionally omitting specified fields.\n\t *\n\t * @param extendFields - Optional fields to add to the schema (e.g., `_id`, `softDelete`).\n\t * @param omitFields - Optional fields to omit from the base schema (e.g., `name`).\n\t * @returns A new Zod schema for updates.\n\t */\n\tupdateBaseSchema(extendFields?: z.ZodRawShape, omitFields?: string[]) {\n\t\tlet schema: z.ZodObject<any> = this.baseSchema;\n\n\t\tif (omitFields && omitFields.length > 0) {\n\t\t\tschema = schema.omit(omitFields.reduce((acc, key) => ({ ...acc, [key]: true }), {}));\n\t\t}\n\n\t\tif (extendFields) {\n\t\t\tschema = schema.extend({ _id: ZodValidation.objectId().optional(), ...extendFields });\n\t\t}\n\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Gets all common schemas for an entity.\n\t * Returns base, entity, ID, and update schemas in a single object.\n\t *\n\t * @param excludeFromUpdate - Fields to exclude from update operations\n\t * @returns Object containing all schemas\n\t *\n\t * @example\n\t * ```typescript\n\t * const {\n\t * BaseSchema, // For creating\n\t * EntitySchema, // For reading\n\t * IdSchema, // For validating IDs\n\t * UpdateSchema // For updating\n\t * } = userBuilder.getAllSchemas();\n\t * ```\n\t */\n\tgetAllSchemas(excludeFromUpdate?: ExcludeFromUpdate) {\n\t\treturn {\n\t\t\tBaseSchema: this.getBaseSchema(),\n\t\t\tEntitySchema: this.getEntitySchema(),\n\t\t\tIdSchema: this.getIdSchema(),\n\t\t\tUpdateSchema: this.getUpdateSchema(excludeFromUpdate),\n\t\t\tDeleteSchema: this.getDeleteSchema(),\n\t\t};\n\t}\n}\n\n/**\n * Type helper for creating DTO types from creation schemas.\n * Used to derive the type for creating new entities.\n *\n * @template T - The schema type\n *\n * @example\n * ```typescript\n * type CreateUserDTO = DTO<typeof UserValidationSchema>;\n * ```\n */\nexport type DTO<T extends z.ZodType> = z.infer<T>;\n\n/**\n * Creates a schema builder for an entity.\n * Helper function to create a new SchemaBuilder instance.\n *\n * @template T - Type of the base schema shape\n * @param baseFields - Base fields for the entity\n * @param includeTimestamps - Whether to include timestamp fields (default: true)\n * @param includeTracking - Whether to include tracking fields (default: false)\n * @returns A new SchemaBuilder instance\n *\n * @example\n * ```typescript\n * const userFields = {\n * name: ZodValidation.requiredString(),\n * email: ZodValidation.email()\n * };\n *\n * const userSchemaBuilder = createSchemaBuilder(userFields);\n * const userSchemaBuilder = createSchemaBuilder(userFields, true, true); // With tracking\n * ```\n */\nexport type PaginatedResponse<T> = {\n\tmetadata: {\n\t\tpage: number;\n\t\tsize: number;\n\t\ttotalElements: number;\n\t\ttotalPages: number;\n\t};\n\tdocuments: T[];\n};\n\nexport function createSchemaBuilder<T extends z.ZodRawShape>(\n\tbaseFields: T,\n\tincludeTimestamps: boolean = true,\n\tincludeTracking: boolean = false\n) {\n\treturn new SchemaBuilder(baseFields, includeTimestamps, includeTracking);\n}\n\n// Custom Pagination utilities\nexport interface CustomPaginatorOptions<T> {\n\tpage?: number;\n\tsize?: number;\n\tsort?: Record<string, 1 | -1>;\n\tquery?: any;\n\tselect?: any;\n\tpopulate?: string[] | any[];\n\t// Optional function to transform each document\n\ttransform?: (doc: T) => any;\n}\n\nexport interface CustomPaginatedResponse<T> {\n\tdocuments: T[];\n\tmetadata: {\n\t\tpage: number;\n\t\tsize: number;\n\t\ttotalElements: number;\n\t\ttotalPages: number;\n\t};\n}\n\nexport type LeanDocument<T> = Require_id<FlattenMaps<T>>;\n"]}
1
+ {"version":3,"file":"global-validation.js","sourceRoot":"/","sources":["utilities/validation/global-validation.ts"],"names":[],"mappings":";;;AAi4BA,kDAMC;AAv4BD,6BAAwB;AACxB,oDAAgD;AAChD,yDAA+D;AAgB/D,MAAa,aAAa;IAczB,MAAM,CAAC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C,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QACtF,CAAC;QAED,IAAI,YAAY,EAAE,CAAC;YAClB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,aAAa,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC;QACvF,CAAC;QAED,OAAO,MAAM,CAAC;IACf,CAAC;IAmBD,aAAa,CAAC,iBAAqC;QAClD,OAAO;YACN,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE;YAChC,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE;YACpC,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE;YAC5B,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAC;YACrD,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE;SACpC,CAAC;IACH,CAAC;CACD;AAlND,sCAkNC;AA8CD,SAAgB,mBAAmB,CAClC,UAAa,EACb,oBAA6B,IAAI,EACjC,kBAA2B,KAAK;IAEhC,OAAO,IAAI,aAAa,CAAC,UAAU,EAAE,iBAAiB,EAAE,eAAe,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["import { z } from 'zod';\nimport { mongoose } from '@typegoose/typegoose';\nimport { parsePhoneNumberFromString } from 'libphonenumber-js';\nimport { Require_id, FlattenMaps } from 'mongoose';\n\n/**\n * Enhanced validation utilities for creating robust Zod schemas.\n * This class provides a collection of static methods to create common validation patterns.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * username: ZodValidation.requiredString(\"Username is required\"),\n * email: ZodValidation.email(),\n * role: ZodValidation.enumType(UserRole)\n * });\n * ```\n */\nexport class ZodValidation {\n\t/**\n\t * Creates a union type that accepts both string ObjectId and mongoose ObjectId instance.\n\t * This is useful when dealing with both raw string IDs and Mongoose ObjectId instances.\n\t *\n\t * @param field - The name of the field to be included in the error message\n\t * @returns A Zod union schema that accepts both string and ObjectId\n\t *\n\t * @example\n\t * ```typescript\n\t * const idSchema = ZodValidation.objectIdUnion();\n\t * // Accepts \"507f1f77bcf86cd799439011\" or new mongoose.Types.ObjectId(\"507f1f77bcf86cd799439011\")\n\t * ```\n\t */\n\tstatic objectIdOrStringSchema = z.custom<mongoose.Types.ObjectId | string>(\n\t\tval => {\n\t\t\tif (typeof val === 'string' && /^[0-9a-fA-F]{24}$/.test(val)) return true;\n\t\t\tif (typeof val === 'object' && val instanceof mongoose.Types.ObjectId) return true;\n\t\t\treturn false;\n\t\t},\n\t\t{ message: 'Invalid ObjectId' }\n\t);\n\n\tstatic objectId(field: string = 'Field') {\n\t\treturn z.union(\n\t\t\t[\n\t\t\t\tz\n\t\t\t\t\t.string({ required_error: `${field} is required` })\n\t\t\t\t\t.refine(val => mongoose.Types.ObjectId.isValid(val), {\n\t\t\t\t\t\tmessage: `${field} must be a valid ObjectID`,\n\t\t\t\t\t})\n\t\t\t\t\t.transform(val => new mongoose.Types.ObjectId(val)),\n\t\t\t\tz.instanceof(mongoose.Types.ObjectId, {\n\t\t\t\t\tmessage: `${field} must be a valid ObjectID`,\n\t\t\t\t}),\n\t\t\t],\n\t\t\t{ message: `${field} is required` }\n\t\t);\n\t}\n\n\tstatic objectIdStringWithTransform(field: string = 'Field') {\n\t\treturn z.string().transform((val, ctx) => {\n\t\t\tif (!mongoose.Types.ObjectId.isValid(val)) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\t\t\tmessage: `${field} must be a valid ObjectID.`,\n\t\t\t\t});\n\t\t\t\treturn z.NEVER;\n\t\t\t}\n\t\t\treturn new mongoose.Types.ObjectId(val);\n\t\t});\n\t}\n\n\t/**\n\t * Creates an enum validation with custom error message.\n\t * This validates that a value is one of the values defined in the enum.\n\t *\n\t * @template T - Type of the enum\n\t * @param enumObj - The enum object to validate against\n\t * @param field - The name of the field to be included in the error message\n\t * @returns A Zod schema that validates against the provided enum\n\t *\n\t * @example\n\t * ```typescript\n\t * enum UserRole { ADMIN = \"admin\", USER = \"user\" }\n\t * const roleSchema = ZodValidation.enumType(UserRole, \"Invalid user role\");\n\t * ```\n\t */\n\tstatic enumType<T extends z.EnumLike>(enumObj: T, field: string = 'Field') {\n\t\treturn z.nativeEnum(enumObj, {\n\t\t\tmessage: `${field} must be one of: ${Object.values(enumObj).join(', ')}`,\n\t\t});\n\t}\n\n\t/**\n\t * Creates a required number validation with a minimum length.\n\t * The number is also trimmed to remove leading/trailing whitespace.\n\t *\n\t * @param field - The name of the field to be included in the error message\n\t * @param min - Minimum number (optional)\n\t * @param max - MAximum number (optional)\n\t * @param options - options (optional)\n\t * @returns A Zod schema that validates numbers with minimum length\n\t *\n\t * @example\n\t * ```typescript\n\t * const nameSchema = ZodValidation.Number(\"Price\");\n\t * ```\n\t */\n\tstatic number(\n\t\tfield: string = 'Field',\n\t\toptions?: {\n\t\t\tmin?: number;\n\t\t\tmax?: number;\n\t\t\tisInt?: boolean;\n\t\t\tisPositive?: boolean;\n\t\t\tisNonpositive?: boolean;\n\t\t\tisNegative?: boolean;\n\t\t\tisNonnegative?: boolean;\n\t\t}\n\t) {\n\t\tlet schema = z.number({\n\t\t\trequired_error: `${field} is required`,\n\t\t\tinvalid_type_error: `${field} must be a number`,\n\t\t});\n\n\t\t// Range validation\n\t\tif (options?.min !== undefined) {\n\t\t\tschema = schema.gte(options?.min, {\n\t\t\t\tmessage: `${field} must be at least ${options?.min}`,\n\t\t\t});\n\t\t}\n\t\tif (options?.max !== undefined) {\n\t\t\tschema = schema.lte(options?.max, {\n\t\t\t\tmessage: `${field} must be at most ${options?.max}`,\n\t\t\t});\n\t\t}\n\n\t\t// Option validation\n\t\tif (options?.isInt) {\n\t\t\tschema = schema.int({ message: `${field} must be an integer` });\n\t\t}\n\t\tif (options?.isPositive) {\n\t\t\tschema = schema.positive({ message: `${field} must be positive` });\n\t\t}\n\t\tif (options?.isNonpositive) {\n\t\t\tschema = schema.nonpositive({ message: `${field} must be non-positive` });\n\t\t}\n\t\tif (options?.isNegative) {\n\t\t\tschema = schema.negative({ message: `${field} must be negative` });\n\t\t}\n\t\tif (options?.isNonnegative) {\n\t\t\tschema = schema.nonnegative({ message: `${field} must be non-negative` });\n\t\t}\n\n\t\treturn schema;\n\t}\n\n\tstatic numberWithRefinement(\n\t\tfield: string = 'Field',\n\t\toptions?: {\n\t\t\tmin?: number;\n\t\t\tmax?: number;\n\t\t\tisInt?: boolean;\n\t\t\tisPositive?: boolean;\n\t\t\tisNonpositive?: boolean;\n\t\t\tisNegative?: boolean;\n\t\t\tisNonnegative?: boolean;\n\t\t\tdecimalPlaces?: number;\n\t\t}\n\t) {\n\t\tlet schema: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number> = ZodValidation.number(\n\t\t\tfield,\n\t\t\toptions\n\t\t);\n\n\t\tif (options?.decimalPlaces !== undefined) {\n\t\t\tconst multiplier = 10 ** options.decimalPlaces;\n\n\t\t\tschema = schema.refine(\n\t\t\t\tvalue => Math.abs(value * multiplier - Math.round(value * multiplier)) < Number.EPSILON,\n\t\t\t\t{\n\t\t\t\t\tmessage: `${field} must have at most ${options.decimalPlaces} decimal place${options.decimalPlaces === 1 ? '' : 's'}`,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Creates a required string validation with a minimum length.\n\t * The string is also trimmed to remove leading/trailing whitespace.\n\t *\n\t * @param field - The name of the field to be included in the error message\n\t * @param minLength - Minimum required length (optional)\n\t * @param maxLength - Maximum required length (optional)\n\t * @param regex - Regular expression (optional)\n\t * @returns A Zod schema that validates strings with minimum length\n\t *\n\t * @example\n\t * ```typescript\n\t * const nameSchema = ZodValidation.String(\"Name\");\n\t * ```\n\t */\n\tstatic string(\n\t\tfield: string = 'Field',\n\t\toptions?: {\n\t\t\tminLength?: number;\n\t\t\tmaxLength?: number;\n\t\t\tminMessage?: string;\n\t\t\tmaxMessage?: string;\n\t\t\trequiredMessage?: string;\n\t\t\tregex?: { pattern: RegExp; message: string }; // Add regex option\n\t\t\tisTrimmed?: boolean;\n\t\t}\n\t) {\n\t\tlet schema = z.string({\n\t\t\trequired_error: options?.requiredMessage || `${field} is required`,\n\t\t});\n\n\t\tif (options?.minLength) {\n\t\t\tschema = schema.min(\n\t\t\t\toptions.minLength,\n\t\t\t\toptions.minMessage || `${field} must be at least ${options.minLength} characters`\n\t\t\t);\n\t\t}\n\n\t\tif (options?.maxLength) {\n\t\t\tschema = schema.max(\n\t\t\t\toptions.maxLength,\n\t\t\t\toptions.maxMessage || `${field} shouldn’t exceed ${options.maxLength} characters`\n\t\t\t);\n\t\t}\n\n\t\t// Check for regex pattern and add regex validation\n\t\tif (options?.regex) {\n\t\t\tschema = schema.regex(options.regex.pattern, options.regex.message);\n\t\t}\n\n\t\tif (options?.isTrimmed) {\n\t\t\treturn schema\n\t\t\t\t.transform(val => val?.trim())\n\t\t\t\t.refine(val => val?.length && val?.length > 0, {\n\t\t\t\t\tmessage: options?.requiredMessage || `${field} is required`,\n\t\t\t\t});\n\t\t}\n\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Creates an email validation.\n\t * Validates that the string is a valid email address format.\n\t *\n\t * @param field - The name of the field to be included in the error message\n\t * @returns A Zod schema that validates email addresses\n\t *\n\t * @example\n\t * ```typescript\n\t * const emailSchema = ZodValidation.email(\"Please enter a valid email\");\n\t * ```\n\t */\n\tstatic email(\n\t\tfield: string = 'Email',\n\t\toptions?: {\n\t\t\trequiredMessage?: string;\n\t\t\tinvalidMessage?: string;\n\t\t}\n\t) {\n\t\tconst schema = z\n\t\t\t.string({\n\t\t\t\trequired_error: options?.requiredMessage || `${field} is required`,\n\t\t\t})\n\t\t\t.trim()\n\t\t\t.email(options?.invalidMessage || `${field} must be a valid email address`)\n\t\t\t.transform(value => value.toLowerCase());\n\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Creates a URL validation.\n\t * Validates that the string is a valid URL format.\n\t *\n\t * @param field - The name of the field to be included in the error message\n\t * @returns A Zod schema that validates URLs\n\t *\n\t * @example\n\t * ```typescript\n\t * const websiteSchema = ZodValidation.url(\"Please enter a valid URL\");\n\t * ```\n\t */\n\tstatic url(field: string = 'Field') {\n\t\treturn z.string({ required_error: `${field} is required` }).url(`${field} must be a valid URL`);\n\t}\n\n\t/**\n\t * Creates a Password validation.\n\t * Validates that the string is a valid password format.\n\t *\n\t * @param field - The name of the field to be included in the error message\n\t * @returns A Zod schema that validates password\n\t *\n\t * @example\n\t * ```typescript\n\t * const websiteSchema = ZodValidation.password(\"Please enter a valid password\");\n\t * ```\n\t */\n\tstatic password(field: string = 'Field') {\n\t\treturn z.string({ required_error: `${field} is required` }).refine(\n\t\t\tval =>\n\t\t\t\t!val || // allow undefined or empty, but validate when provided\n\t\t\t\t(val.length >= 8 && // minimum length\n\t\t\t\t\t/[a-z]/.test(val) && // lowercase\n\t\t\t\t\t/[A-Z]/.test(val) && // uppercase\n\t\t\t\t\t/[0-9]/.test(val) && // number\n\t\t\t\t\t/[!@#$%^&*(),.?\":{}|<>]/.test(val)), // special char\n\t\t\t{\n\t\t\t\tmessage:\n\t\t\t\t\t'Password must include at least one uppercase letter, one lowercase letter, one number, one special character and minimum 8 character required',\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Creates a phone number validation schema using a regex pattern for global phone numbers.\n\t *\n\t * @param field - The name of the field to be included in the error message\n\t * @returns A Zod schema that validates phone numbers\n\t *\n\t * @example\n\t * ```typescript\n\t * const phoneSchema = ZodValidation.phoneNumber(\"Phone number\");\n\t * ```\n\t */\n\n\tstatic phoneNumber(field: string = 'Field') {\n\t\treturn z.string({ required_error: `${field} is required` }).refine(\n\t\t\tvalue => {\n\t\t\t\ttry {\n\t\t\t\t\tconst phone = parsePhoneNumberFromString(value);\n\t\t\t\t\treturn phone?.isValid();\n\t\t\t\t} catch {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\tmessage: `Please enter a valid phone number`,\n\t\t\t}\n\t\t);\n\t}\n\n\tstatic validPhoneNumber(field: string = 'Field') {\n\t\treturn z.string({ required_error: `${field} is required` }).superRefine((phoneWithCountryCode, ctx) => {\n\t\t\tconst phoneWithoutCountryCode = phoneWithCountryCode.replace(/^\\+\\d{1,3}/, '');\n\t\t\tif (phoneWithoutCountryCode.length < 4) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\t\t\tmessage: `${field} must have 4 or more digits`,\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (/^\\d{4}$|^\\d{5}$|^\\d{7}$|^\\d{8}$/.test(phoneWithoutCountryCode)) {\n\t\t\t\treturn; // ✅ Accept 4,5,7 or 8 digit short numbers\n\t\t\t}\n\t\t\t// Otherwise, parse as real phone number\n\t\t\tconst phone = parsePhoneNumberFromString(phoneWithCountryCode);\n\t\t\tif (!phone) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\t\t\tmessage: `Invalid phone number format in ${field}`,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!phone.isValid()) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\t\t\tmessage: `Please enter a valid phone number in ${field}`,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Creates a date validation.\n\t * Validates that the input is a JavaScript Date object.\n\t *@param field - The name of the field to be included in the error message\n\t *@param minDate - Minimum required date (optional)\n\t *@param maxDate - Maximum required date (optional)\n\t * @returns A Zod schema that validates Date objects\n\t *\n\t * @example\n\t * ```typescript\n\t * const createdAtSchema = ZodValidation.date();\n\t * ```\n\t */\n\tstatic date(field: string = 'Field', minDate?: Date, maxDate?: Date) {\n\t\treturn z\n\t\t\t.union(\n\t\t\t\t[\n\t\t\t\t\tz\n\t\t\t\t\t\t.string({ required_error: `${field} is required` })\n\t\t\t\t\t\t.refine(val => {\n\t\t\t\t\t\t\tconst date = new Date(val);\n\t\t\t\t\t\t\treturn !isNaN(date.getTime());\n\t\t\t\t\t\t}, `${field} must be a valid date`)\n\t\t\t\t\t\t.transform(val => new Date(val)),\n\t\t\t\t\tz.date({\n\t\t\t\t\t\trequired_error: `${field} is required`,\n\t\t\t\t\t\tinvalid_type_error: `${field} must be a valid date`,\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\t{ message: `${field} is required` }\n\t\t\t)\n\t\t\t.refine(\n\t\t\t\tval => minDate === undefined || val >= minDate,\n\t\t\t\t`${field} must be on or after ${minDate?.toISOString()}`\n\t\t\t)\n\t\t\t.refine(\n\t\t\t\tval => maxDate === undefined || val <= maxDate,\n\t\t\t\t`${field} must be on or before ${maxDate?.toISOString()}`\n\t\t\t);\n\t}\n\n\t/**\n\t * Creates a boolean validation with an optional default value.\n\t *\n\t * @param field - The name of the field to be included in the error message\n\t * @returns A Zod schema that validates booleans\n\t *\n\t * @example\n\t * ```typescript\n\t * const isActiveSchema = ZodValidation.boolean(true); // Defaults to true\n\t * ```\n\t */\n\tstatic boolean(field: string = 'Field') {\n\t\treturn z.boolean({\n\t\t\trequired_error: `${field} is required`,\n\t\t\tinvalid_type_error: `${field} must be a boolean`,\n\t\t});\n\t}\n\n\t/**\n\t * Creates an array validation with optional minimum items constraint.\n\t *\n\t * @template T - Type of the schema for array items\n\t * @param schema - The schema for validating array items\n\t * @param field - The name of the field to be included in the error message\n\t * @param minItems - Minimum number of items required (optional)\n\t * @param maxItems - Maximum number of items required (optional)\n\t * @returns A Zod schema that validates arrays\n\t *\n\t * @example\n\t * ```typescript\n\t * const tagsSchema = ZodValidation.array(z.string(), \"At least one tag required\", 1);\n\t * ```\n\t */\n\tstatic array<T extends z.ZodTypeAny>(\n\t\tschema: T,\n\t\tfield: string = 'Array',\n\t\tminItems?: number,\n\t\tmaxItems?: number\n\t) {\n\t\tlet arraySchema = z.array(schema, {\n\t\t\trequired_error: `${field} is required`,\n\t\t});\n\n\t\tif (minItems === 1) {\n\t\t\tarraySchema = arraySchema.min(1, `${field} cannot be empty`);\n\t\t}\n\t\tif (minItems !== undefined && minItems !== 1) {\n\t\t\tarraySchema = arraySchema.min(minItems, `${field} must have at least ${minItems} items`);\n\t\t}\n\t\tif (maxItems !== undefined) {\n\t\t\tarraySchema = arraySchema.max(maxItems, `${field} must have at most ${maxItems} items`);\n\t\t}\n\n\t\treturn arraySchema;\n\t}\n\n\t/**\n\t * Standard timestamp fields for entities.\n\t * Includes createdAt, updatedAt, and deletedAt fields.\n\t *\n\t * @returns An object containing timestamp field schemas\n\t *\n\t * @example\n\t * ```typescript\n\t * const userSchema = z.object({\n\t * name: z.string(),\n\t * ...ZodValidation.timestamps()\n\t * });\n\t * ```\n\t */\n\tstatic timestamps() {\n\t\treturn {\n\t\t\tcreatedAt: z.date().nullable().optional(),\n\t\t\tupdatedAt: z.date().nullable().optional(),\n\t\t\tdeletedAt: z.date().nullable().optional(),\n\t\t};\n\t}\n\n\t/**\n\t * Common fields for tracking model metadata.\n\t * Includes timestamps and user tracking fields (createdBy, updatedBy, deletedBy).\n\t *\n\t * @returns An object containing tracking field schemas\n\t *\n\t * @example\n\t * ```typescript\n\t * const postSchema = z.object({\n\t * title: z.string(),\n\t * content: z.string(),\n\t * ...ZodValidation.trackingFields()\n\t * });\n\t * ```\n\t */\n\tstatic trackingFields() {\n\t\treturn {\n\t\t\tcreatedBy: ZodValidation.objectId().optional(),\n\t\t\tupdatedBy: ZodValidation.objectId().optional(),\n\t\t\tdeletedBy: ZodValidation.objectId().optional(),\n\t\t\t...ZodValidation.timestamps(),\n\t\t};\n\t}\n\n\t/**\n\t * Namespace for coercion-based Zod validators.\n\t * Provides schemas that automatically convert input types to the expected type.\n\t *\n\t * @example\n\t * ```typescript\n\t * const schema = z.object({\n\t * startDate: ZodValidation.coerce.date(\"Start Date\"),\n\t * age: ZodValidation.coerce.number(\"Age\", { min: 18 }),\n\t * isActive: ZodValidation.coerce.boolean(\"Active\"),\n\t * });\n\t * ```\n\t */\n\tstatic coerce = {\n\t\tnumber: (\n\t\t\tfield: string = 'Field',\n\t\t\toptions?: {\n\t\t\t\tmin?: number;\n\t\t\t\tmax?: number;\n\t\t\t\tisInt?: boolean;\n\t\t\t\tisPositive?: boolean;\n\t\t\t\tisNonpositive?: boolean;\n\t\t\t\tisNegative?: boolean;\n\t\t\t\tisNonnegative?: boolean;\n\t\t\t}\n\t\t) => {\n\t\t\tlet schema = z.coerce.number({\n\t\t\t\trequired_error: `${field} is required`,\n\t\t\t\tinvalid_type_error: `${field} must be a number`,\n\t\t\t});\n\n\t\t\tif (options?.min !== undefined) {\n\t\t\t\tschema = schema.gte(options.min, { message: `${field} must be at least ${options.min}` });\n\t\t\t}\n\t\t\tif (options?.max !== undefined) {\n\t\t\t\tschema = schema.lte(options.max, { message: `${field} must be at most ${options.max}` });\n\t\t\t}\n\t\t\tif (options?.isInt) schema = schema.int({ message: `${field} must be an integer` });\n\t\t\tif (options?.isPositive) schema = schema.positive({ message: `${field} must be positive` });\n\t\t\tif (options?.isNonpositive) schema = schema.nonpositive({ message: `${field} must be non-positive` });\n\t\t\tif (options?.isNegative) schema = schema.negative({ message: `${field} must be negative` });\n\t\t\tif (options?.isNonnegative) schema = schema.nonnegative({ message: `${field} must be non-negative` });\n\n\t\t\treturn schema;\n\t\t},\n\n\t\tdate: (field: string = 'Field', minDate?: Date, maxDate?: Date) => {\n\t\t\treturn z.coerce\n\t\t\t\t.date({\n\t\t\t\t\trequired_error: `${field} is required`,\n\t\t\t\t\tinvalid_type_error: `${field} must be a valid date`,\n\t\t\t\t})\n\t\t\t\t.refine(val => minDate === undefined || val >= minDate, {\n\t\t\t\t\tmessage: `${field} must be on or after ${minDate?.toISOString()}`,\n\t\t\t\t})\n\t\t\t\t.refine(val => maxDate === undefined || val <= maxDate, {\n\t\t\t\t\tmessage: `${field} must be on or before ${maxDate?.toISOString()}`,\n\t\t\t\t});\n\t\t},\n\n\t\tboolean: (field: string = 'Field') => {\n\t\t\treturn z.coerce.boolean({\n\t\t\t\trequired_error: `${field} is required`,\n\t\t\t\tinvalid_type_error: `${field} must be true or false`,\n\t\t\t});\n\t\t},\n\t\tobjectId: (field: string = 'Field') =>\n\t\t\tz\n\t\t\t\t.custom<mongoose.Types.ObjectId>(\n\t\t\t\t\tval => {\n\t\t\t\t\t\tif (typeof val === 'string' && mongoose.Types.ObjectId.isValid(val)) return true;\n\t\t\t\t\t\tif (val instanceof mongoose.Types.ObjectId) return true;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t},\n\t\t\t\t\t{ message: `${field} must be a valid ObjectId` }\n\t\t\t\t)\n\t\t\t\t.transform(val => (typeof val === 'string' ? new mongoose.Types.ObjectId(val) : val)),\n\t};\n}\n\n/**\n * Represents the common fields to exclude from update operations.\n * This is used to specify which fields should not be updateable.\n *\n * @example\n * ```typescript\n * const excludeFields: ExcludeFromUpdate = {\n * createdAt: true,\n * createdBy: true,\n * status: true // Prevent status from being updated\n * };\n * ```\n */\nexport type ExcludeFromUpdate = {\n\tcreatedAt?: true;\n\tupdatedAt?: true;\n\tdeletedAt?: true;\n\tcreatedBy?: true;\n\t_id?: true;\n} & Record<string, true>;\n\n/**\n * Schema builder for creating consistent CRUD schemas.\n * Provides utility methods to generate schemas for create, read, update, and delete operations.\n *\n * @template T - Type of the base schema shape\n *\n * @example\n * ```typescript\n * const userBuilder = new SchemaBuilder({\n * name: z.string(),\n * email: z.string().email()\n * });\n *\n * const schemas = userBuilder.getAllSchemas();\n * ```\n */\nexport class SchemaBuilder<T extends z.ZodRawShape> {\n\tprivate baseSchema: z.ZodObject<T>;\n\n\t/**\n\t * Create a new schema builder\n\t *\n\t * @param baseFields - The base fields for the schema\n\t * @param includeTimestamps - Whether to include timestamp fields (default: true)\n\t * @param includeTracking - Whether to include tracking fields (createdBy, etc.) (default: false)\n\t *\n\t * @example\n\t * ```typescript\n\t * const userFields = {\n\t * name: ZodValidation.requiredString(),\n\t * email: ZodValidation.email()\n\t * };\n\t *\n\t * // With timestamps\n\t * const builder1 = new SchemaBuilder(userFields);\n\t *\n\t * // Without timestamps\n\t * const builder2 = new SchemaBuilder(userFields, false);\n\t *\n\t * // With tracking fields\n\t * const builder3 = new SchemaBuilder(userFields, true, true);\n\t * ```\n\t */\n\tconstructor(\n\t\tbaseFields: T,\n\t\tprivate includeTimestamps: boolean = true,\n\t\tprivate includeTracking: boolean = false\n\t) {\n\t\tthis.baseSchema = this.createBaseSchema(baseFields);\n\t}\n\n\t/**\n\t * Creates the base schema with optional timestamps and tracking fields.\n\t */\n\tprivate createBaseSchema(baseFields: T) {\n\t\tconst additionalFields = this.includeTracking\n\t\t\t? ZodValidation.trackingFields()\n\t\t\t: this.includeTimestamps\n\t\t\t\t? ZodValidation.timestamps()\n\t\t\t\t: {};\n\n\t\treturn z.object({\n\t\t\t...baseFields,\n\t\t\t...additionalFields,\n\t\t});\n\t}\n\n\t/**\n\t * Gets the base validation schema without ID.\n\t * Used for creating new entities.\n\t *\n\t * @returns The base schema for creating new entities\n\t *\n\t * @example\n\t * ```typescript\n\t * const createUserSchema = userBuilder.getBaseSchema();\n\t * ```\n\t */\n\tgetBaseSchema() {\n\t\treturn this.baseSchema.strict();\n\t}\n\n\t/**\n\t * Gets the schema for entities with ID.\n\t * Used for representing complete entities with their ID.\n\t *\n\t * @returns The entity schema including ID\n\t *\n\t * @example\n\t * ```typescript\n\t * const userSchema = userBuilder.getEntitySchema();\n\t * ```\n\t */\n\tgetEntitySchema() {\n\t\treturn this.baseSchema\n\t\t\t.extend({\n\t\t\t\t_id: ZodValidation.objectId(),\n\t\t\t})\n\t\t\t.partial()\n\t\t\t.passthrough();\n\t}\n\n\t/**\n\t * Gets the schema for validating an entity ID.\n\t * Used for validating ID parameters in requests.\n\t *\n\t * @returns The ID validation schema\n\t *\n\t * @example\n\t * ```typescript\n\t * const userIdSchema = userBuilder.getIdSchema();\n\t * ```\n\t */\n\tgetIdSchema() {\n\t\treturn ZodValidation.objectId();\n\t}\n\n\t/**\n\t * Gets the schema for updating an entity, excluding specified fields.\n\t * Creates a partial schema where all fields are optional, and removes\n\t * fields that should not be updatable.\n\t *\n\t * @param excludeFields - Fields to exclude from update operations\n\t * @returns The update schema with excluded fields removed\n\t *\n\t * @example\n\t * ```typescript\n\t * // Prevent updating createdAt and status\n\t * const updateUserSchema = userBuilder.getUpdateSchema({\n\t * createdAt: true,\n\t * status: true\n\t * });\n\t * ```\n\t */\n\tgetUpdateSchema(excludeFields: ExcludeFromUpdate = { createdAt: true, updatedAt: true }) {\n\t\tconst entitySchema = this.getEntitySchema();\n\n\t\t// Simple approach - just make everything optional\n\t\tif (Object.keys(excludeFields).length === 0) {\n\t\t\treturn entitySchema;\n\t\t}\n\n\t\t// For the type-safe approach, we need to create a new schema\n\t\t// without the excluded fields and then make it partial\n\n\t\t// Get all fields from the entity schema\n\t\tconst shape = entitySchema._def.shape();\n\n\t\t// Filter out the fields we want to exclude\n\t\tconst filteredShape: z.ZodRawShape = {};\n\t\tfor (const key in shape) {\n\t\t\tif (!excludeFields[key as keyof typeof excludeFields]) {\n\t\t\t\tfilteredShape[key] = shape[key];\n\t\t\t}\n\t\t}\n\n\t\t// Create a new schema with the filtered fields\n\t\treturn z.object(filteredShape).partial().strict();\n\t}\n\n\t/**\n\t * Gets the schema for validating a delete request.\n\t * Used for validating parameters in delete requests, including the entity ID and soft delete flag.\n\t *\n\t * @returns The delete validation schema\n\t *\n\t * @example\n\t * ```typescript\n\t * const deleteSchema = userBuilder.getDeleteSchema();\n\t * ```\n\t */\n\tgetDeleteSchema() {\n\t\treturn z.object({\n\t\t\t_id: ZodValidation.objectId('_id'),\n\t\t\tsoftDelete: ZodValidation.boolean('Soft Delete').default(true),\n\t\t});\n\t}\n\n\t/**\n\t * Creates an update schema by optionally extending the base schema with additional fields\n\t * and optionally omitting specified fields.\n\t *\n\t * @param extendFields - Optional fields to add to the schema (e.g., `_id`, `softDelete`).\n\t * @param omitFields - Optional fields to omit from the base schema (e.g., `name`).\n\t * @returns A new Zod schema for updates.\n\t */\n\tupdateBaseSchema(extendFields?: z.ZodRawShape, omitFields?: string[]) {\n\t\tlet schema: z.ZodObject<any> = this.baseSchema;\n\n\t\tif (omitFields && omitFields.length > 0) {\n\t\t\tschema = schema.omit(omitFields.reduce((acc, key) => ({ ...acc, [key]: true }), {}));\n\t\t}\n\n\t\tif (extendFields) {\n\t\t\tschema = schema.extend({ _id: ZodValidation.objectId().optional(), ...extendFields });\n\t\t}\n\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Gets all common schemas for an entity.\n\t * Returns base, entity, ID, and update schemas in a single object.\n\t *\n\t * @param excludeFromUpdate - Fields to exclude from update operations\n\t * @returns Object containing all schemas\n\t *\n\t * @example\n\t * ```typescript\n\t * const {\n\t * BaseSchema, // For creating\n\t * EntitySchema, // For reading\n\t * IdSchema, // For validating IDs\n\t * UpdateSchema // For updating\n\t * } = userBuilder.getAllSchemas();\n\t * ```\n\t */\n\tgetAllSchemas(excludeFromUpdate?: ExcludeFromUpdate) {\n\t\treturn {\n\t\t\tBaseSchema: this.getBaseSchema(),\n\t\t\tEntitySchema: this.getEntitySchema(),\n\t\t\tIdSchema: this.getIdSchema(),\n\t\t\tUpdateSchema: this.getUpdateSchema(excludeFromUpdate),\n\t\t\tDeleteSchema: this.getDeleteSchema(),\n\t\t};\n\t}\n}\n\n/**\n * Type helper for creating DTO types from creation schemas.\n * Used to derive the type for creating new entities.\n *\n * @template T - The schema type\n *\n * @example\n * ```typescript\n * type CreateUserDTO = DTO<typeof UserValidationSchema>;\n * ```\n */\nexport type DTO<T extends z.ZodType> = z.infer<T>;\n\n/**\n * Creates a schema builder for an entity.\n * Helper function to create a new SchemaBuilder instance.\n *\n * @template T - Type of the base schema shape\n * @param baseFields - Base fields for the entity\n * @param includeTimestamps - Whether to include timestamp fields (default: true)\n * @param includeTracking - Whether to include tracking fields (default: false)\n * @returns A new SchemaBuilder instance\n *\n * @example\n * ```typescript\n * const userFields = {\n * name: ZodValidation.requiredString(),\n * email: ZodValidation.email()\n * };\n *\n * const userSchemaBuilder = createSchemaBuilder(userFields);\n * const userSchemaBuilder = createSchemaBuilder(userFields, true, true); // With tracking\n * ```\n */\nexport type PaginatedResponse<T> = {\n\tmetadata: {\n\t\tpage: number;\n\t\tsize: number;\n\t\ttotalElements: number;\n\t\ttotalPages: number;\n\t};\n\tdocuments: T[];\n};\n\nexport function createSchemaBuilder<T extends z.ZodRawShape>(\n\tbaseFields: T,\n\tincludeTimestamps: boolean = true,\n\tincludeTracking: boolean = false\n) {\n\treturn new SchemaBuilder(baseFields, includeTimestamps, includeTracking);\n}\n\n// Custom Pagination utilities\nexport interface CustomPaginatorOptions<T> {\n\tpage?: number;\n\tsize?: number;\n\tsort?: Record<string, 1 | -1>;\n\tquery?: any;\n\tselect?: any;\n\tpopulate?: string[] | any[];\n\t// Optional function to transform each document\n\ttransform?: (doc: T) => any;\n}\n\nexport interface CustomPaginatedResponse<T> {\n\tdocuments: T[];\n\tmetadata: {\n\t\tpage: number;\n\t\tsize: number;\n\t\ttotalElements: number;\n\t\ttotalPages: number;\n\t};\n}\n\nexport type LeanDocument<T> = Require_id<FlattenMaps<T>>;\n"]}
@@ -4,8 +4,8 @@ export declare const UserAddressFrontendSchema: z.ZodObject<{
4
4
  addressLabel: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
5
5
  apartment: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
6
6
  buildingName: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
7
- deliveryOption: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
8
- instructions: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
7
+ deliveryOption: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
8
+ instructions: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
9
9
  }, "strip", z.ZodTypeAny, {
10
10
  addressLabel: string;
11
11
  apartment: string;