@lyxa.ai/types 1.4.333-alpha.0 → 1.4.333-alpha.2

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.333-alpha.0
25
+ Version: 1.4.333-alpha.2
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.333-alpha.0",
3
+ "version": "1.4.333-alpha.2",
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",
@@ -51,7 +51,7 @@ export declare const AddressSchema: z.ZodObject<{
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>>;
54
- coordinates: z.ZodTuple<[z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>, z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>], null>;
54
+ coordinates: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
55
55
  }, "strip", z.ZodTypeAny, {
56
56
  type: GeoLocationType;
57
57
  coordinates: [number, number];
@@ -59,8 +59,8 @@ export declare const AddressSchema: z.ZodObject<{
59
59
  coordinates: [number, number];
60
60
  type?: GeoLocationType | undefined;
61
61
  }>;
62
- latitude: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
63
- longitude: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
62
+ latitude: z.ZodNumber;
63
+ longitude: z.ZodNumber;
64
64
  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>]>>;
65
65
  }, "strip", z.ZodTypeAny, {
66
66
  address: string;
@@ -98,7 +98,7 @@ export declare const UserAddressSchema: z.ZodObject<{
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>>;
101
- coordinates: z.ZodTuple<[z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>, z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>], null>;
101
+ coordinates: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
102
102
  }, "strip", z.ZodTypeAny, {
103
103
  type: GeoLocationType;
104
104
  coordinates: [number, number];
@@ -106,8 +106,8 @@ export declare const UserAddressSchema: z.ZodObject<{
106
106
  coordinates: [number, number];
107
107
  type?: GeoLocationType | undefined;
108
108
  }>;
109
- latitude: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
110
- longitude: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
109
+ latitude: z.ZodNumber;
110
+ longitude: z.ZodNumber;
111
111
  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>]>>;
112
112
  } & {
113
113
  addressLabel: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
@@ -161,7 +161,7 @@ export declare const RegularOrderAddressSchema: z.ZodObject<{
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>>;
164
- coordinates: z.ZodTuple<[z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>, z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>], null>;
164
+ coordinates: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
165
165
  }, "strip", z.ZodTypeAny, {
166
166
  type: GeoLocationType;
167
167
  coordinates: [number, number];
@@ -169,8 +169,8 @@ export declare const RegularOrderAddressSchema: z.ZodObject<{
169
169
  coordinates: [number, number];
170
170
  type?: GeoLocationType | undefined;
171
171
  }>;
172
- latitude: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
173
- longitude: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
172
+ latitude: z.ZodNumber;
173
+ longitude: z.ZodNumber;
174
174
  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>]>>;
175
175
  } & {
176
176
  addressLabel: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
@@ -228,7 +228,7 @@ export declare const CourierAddressSchema: z.ZodObject<{
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>>;
231
- coordinates: z.ZodTuple<[z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>, z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>], null>;
231
+ coordinates: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
232
232
  }, "strip", z.ZodTypeAny, {
233
233
  type: GeoLocationType;
234
234
  coordinates: [number, number];
@@ -236,8 +236,8 @@ export declare const CourierAddressSchema: z.ZodObject<{
236
236
  coordinates: [number, number];
237
237
  type?: GeoLocationType | undefined;
238
238
  }>;
239
- latitude: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
240
- longitude: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
239
+ latitude: z.ZodNumber;
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
243
  deliveryOption: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>> | z.ZodOptional<z.ZodString>;
@@ -522,10 +522,10 @@ export declare const LoginSchema: z.ZodObject<{
522
522
  }>;
523
523
  export type LoginDTO = DTO<typeof LoginSchema>;
524
524
  declare const metadataSchema: z.ZodObject<{
525
- page: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
526
- size: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
527
- totalElements: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
528
- totalPages: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
525
+ page: z.ZodNumber;
526
+ size: z.ZodNumber;
527
+ totalElements: z.ZodNumber;
528
+ totalPages: z.ZodNumber;
529
529
  }, "strip", z.ZodTypeAny, {
530
530
  size: number;
531
531
  page: number;
@@ -539,10 +539,10 @@ declare const metadataSchema: z.ZodObject<{
539
539
  }>;
540
540
  export declare const createPaginatedSchema: <T>(documentSchema: z.ZodSchema<T>) => z.ZodObject<{
541
541
  metadata: z.ZodOptional<z.ZodObject<{
542
- page: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
543
- size: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
544
- totalElements: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
545
- totalPages: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
542
+ page: z.ZodNumber;
543
+ size: z.ZodNumber;
544
+ totalElements: z.ZodNumber;
545
+ totalPages: z.ZodNumber;
546
546
  }, "strip", z.ZodTypeAny, {
547
547
  size: number;
548
548
  page: number;
@@ -577,10 +577,10 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
577
577
  message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
578
578
  data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
579
579
  metadata: z.ZodOptional<z.ZodObject<{
580
- page: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
581
- size: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
582
- totalElements: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
583
- totalPages: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
580
+ page: z.ZodNumber;
581
+ size: z.ZodNumber;
582
+ totalElements: z.ZodNumber;
583
+ totalPages: z.ZodNumber;
584
584
  }, "strip", z.ZodTypeAny, {
585
585
  size: number;
586
586
  page: number;
@@ -615,10 +615,10 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
615
615
  message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
616
616
  data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
617
617
  metadata: z.ZodOptional<z.ZodObject<{
618
- page: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
619
- size: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
620
- totalElements: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
621
- totalPages: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
618
+ page: z.ZodNumber;
619
+ size: z.ZodNumber;
620
+ totalElements: z.ZodNumber;
621
+ totalPages: z.ZodNumber;
622
622
  }, "strip", z.ZodTypeAny, {
623
623
  size: number;
624
624
  page: number;
@@ -653,10 +653,10 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
653
653
  message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
654
654
  data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
655
655
  metadata: z.ZodOptional<z.ZodObject<{
656
- page: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
657
- size: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
658
- totalElements: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
659
- totalPages: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
656
+ page: z.ZodNumber;
657
+ size: z.ZodNumber;
658
+ totalElements: z.ZodNumber;
659
+ totalPages: z.ZodNumber;
660
660
  }, "strip", z.ZodTypeAny, {
661
661
  size: number;
662
662
  page: number;
@@ -708,7 +708,7 @@ export declare const TokenSchema: z.ZodObject<{
708
708
  }>;
709
709
  export declare const UpdateSortingOrderSchema: z.ZodObject<{
710
710
  _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>]>;
711
- newPosition: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
711
+ newPosition: z.ZodNumber;
712
712
  }, "strip", z.ZodTypeAny, {
713
713
  _id: import("mongoose").Types.ObjectId;
714
714
  newPosition: number;
@@ -827,10 +827,10 @@ export declare const ShareableLinkResponseSchema: z.ZodObject<{
827
827
  message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
828
828
  data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
829
829
  metadata: z.ZodOptional<z.ZodObject<{
830
- page: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
831
- size: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
832
- totalElements: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
833
- totalPages: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
830
+ page: z.ZodNumber;
831
+ size: z.ZodNumber;
832
+ totalElements: z.ZodNumber;
833
+ totalPages: z.ZodNumber;
834
834
  }, "strip", z.ZodTypeAny, {
835
835
  size: number;
836
836
  page: number;
@@ -965,9 +965,9 @@ export declare const PaymentInformationSchema: z.ZodObject<{
965
965
  }>;
966
966
  export type PaymentInformationDTO = DTO<typeof PaymentInformationSchema>;
967
967
  export declare const VatSchema: z.ZodObject<{
968
- vatPercentage: z.ZodOptional<z.ZodDefault<z.ZodEffects<z.ZodNumber, number, number>>> | z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
969
- companyVat: z.ZodOptional<z.ZodDefault<z.ZodEffects<z.ZodNumber, number, number>>> | z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
970
- secondaryCompanyVat: z.ZodOptional<z.ZodDefault<z.ZodEffects<z.ZodNumber, number, number>>> | z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
968
+ vatPercentage: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
969
+ companyVat: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
970
+ secondaryCompanyVat: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
971
971
  }, "strip", z.ZodTypeAny, {
972
972
  vatPercentage?: number | undefined;
973
973
  companyVat?: number | undefined;
@@ -979,9 +979,9 @@ export declare const VatSchema: z.ZodObject<{
979
979
  }>;
980
980
  export type VatDTO = DTO<typeof VatSchema>;
981
981
  export declare const CashBackAmountSchema: z.ZodObject<{
982
- cashbackRate: z.ZodOptional<z.ZodDefault<z.ZodEffects<z.ZodNumber, number, number>>> | z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
983
- amount: z.ZodOptional<z.ZodDefault<z.ZodEffects<z.ZodNumber, number, number>>> | z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
984
- secondaryAmount: z.ZodOptional<z.ZodDefault<z.ZodEffects<z.ZodNumber, number, number>>> | z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
982
+ cashbackRate: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
983
+ amount: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
984
+ secondaryAmount: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
985
985
  }, "strip", z.ZodTypeAny, {
986
986
  cashbackRate?: number | undefined;
987
987
  amount?: number | undefined;
@@ -997,8 +997,8 @@ export declare const PaymentRecordSchema: z.ZodObject<{
997
997
  paymentIntentId: z.ZodOptional<z.ZodNullable<z.ZodString>> | z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>>;
998
998
  orderId: z.ZodOptional<z.ZodNullable<z.ZodString>> | z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>>;
999
999
  transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>> | z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>>;
1000
- amount: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
1001
- authorizedAmount: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
1000
+ amount: z.ZodNumber;
1001
+ authorizedAmount: z.ZodNumber;
1002
1002
  externalId: z.ZodOptional<z.ZodNullable<z.ZodString>> | z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>>;
1003
1003
  }, "strip", z.ZodTypeAny, {
1004
1004
  amount: number;
@@ -14,6 +14,15 @@ export declare class ZodValidation {
14
14
  isNonpositive?: boolean;
15
15
  isNegative?: boolean;
16
16
  isNonnegative?: boolean;
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;
17
26
  decimalPlaces?: number;
18
27
  }): z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number>;
19
28
  static string(field?: string, options?: {
@@ -73,6 +73,10 @@ class ZodValidation {
73
73
  if (options?.isNonnegative) {
74
74
  schema = schema.nonnegative({ message: `${field} must be non-negative` });
75
75
  }
76
+ return schema;
77
+ }
78
+ static numberWithRefinement(field = 'Field', options) {
79
+ let schema = ZodValidation.number(field, options);
76
80
  if (options?.decimalPlaces !== undefined) {
77
81
  const multiplier = 10 ** options.decimalPlaces;
78
82
  schema = schema.refine(value => Math.abs(value * multiplier - Math.round(value * multiplier)) < Number.EPSILON, {
@@ -1 +1 @@
1
- {"version":3,"file":"global-validation.js","sourceRoot":"/","sources":["utilities/validation/global-validation.ts"],"names":[],"mappings":";;;AA42BA,kDAMC;AAl3BD,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,GAA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gB,CAAC,YAA4B,EAAE,UAAqB;QACnE,IAAI,MAAM,GAAqB,IAAI,CAAC,UAAU,CAAC;QAE/C,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,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\tdecimalPlaces?: number;\n\t\t}\n\t) {\n\t\tlet schema: z.ZodNumber | z.ZodEffects<z.ZodNumber, number, number> = 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\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"]}
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,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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C;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"]}