@palmares/schemas 0.0.1 → 0.1.0

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.
Files changed (174) hide show
  1. package/.turbo/turbo-build$colon$watch.log +12 -410
  2. package/CHANGELOG.md +17 -0
  3. package/__tests__/.drizzle/migrations/0000_skinny_harrier.sql +22 -0
  4. package/__tests__/.drizzle/migrations/meta/0000_snapshot.json +156 -0
  5. package/__tests__/.drizzle/migrations/meta/_journal.json +13 -0
  6. package/__tests__/.drizzle/schema.ts +35 -0
  7. package/__tests__/drizzle.config.ts +11 -0
  8. package/__tests__/eslint.config.js +10 -0
  9. package/__tests__/manage.ts +5 -0
  10. package/__tests__/node_modules/.bin/drizzle-kit +17 -0
  11. package/__tests__/node_modules/.bin/esbuild +14 -0
  12. package/__tests__/node_modules/.bin/tsc +17 -0
  13. package/__tests__/node_modules/.bin/tsserver +17 -0
  14. package/__tests__/node_modules/.bin/tsx +17 -0
  15. package/__tests__/package.json +36 -0
  16. package/__tests__/sqlite.db +0 -0
  17. package/__tests__/src/core/array.test.ts +130 -0
  18. package/__tests__/src/core/boolean.test.ts +66 -0
  19. package/__tests__/src/core/datetime.test.ts +102 -0
  20. package/__tests__/src/core/index.ts +35 -0
  21. package/__tests__/src/core/model.test.ts +260 -0
  22. package/__tests__/src/core/models.ts +50 -0
  23. package/__tests__/src/core/numbers.test.ts +177 -0
  24. package/__tests__/src/core/object.test.ts +198 -0
  25. package/__tests__/src/core/string.test.ts +222 -0
  26. package/__tests__/src/core/test.test.ts +59 -0
  27. package/__tests__/src/core/types.test.ts +97 -0
  28. package/__tests__/src/core/union.test.ts +99 -0
  29. package/__tests__/src/settings.ts +71 -0
  30. package/__tests__/tsconfig.json +11 -0
  31. package/dist/cjs/src/adapter/fields/index.js +2 -2
  32. package/dist/cjs/src/adapter/fields/object.js +9 -0
  33. package/dist/cjs/src/adapter/index.js +1 -0
  34. package/dist/cjs/src/constants.js +1 -7
  35. package/dist/cjs/src/domain.js +146 -1
  36. package/dist/cjs/src/index.js +69 -74
  37. package/dist/cjs/src/model.js +206 -206
  38. package/dist/cjs/src/schema/array.js +185 -58
  39. package/dist/cjs/src/schema/boolean.js +105 -44
  40. package/dist/cjs/src/schema/datetime.js +104 -38
  41. package/dist/cjs/src/schema/number.js +134 -114
  42. package/dist/cjs/src/schema/object.js +106 -43
  43. package/dist/cjs/src/schema/schema.js +123 -75
  44. package/dist/cjs/src/schema/string.js +152 -58
  45. package/dist/cjs/src/schema/union.js +412 -290
  46. package/dist/cjs/src/utils.js +42 -15
  47. package/dist/cjs/src/validators/array.js +6 -1
  48. package/dist/cjs/src/validators/boolean.js +2 -0
  49. package/dist/cjs/src/validators/datetime.js +4 -0
  50. package/dist/cjs/src/validators/number.js +12 -40
  51. package/dist/cjs/src/validators/object.js +1 -0
  52. package/dist/cjs/src/validators/schema.js +5 -1
  53. package/dist/cjs/src/validators/string.js +30 -2
  54. package/dist/cjs/src/validators/union.js +5 -4
  55. package/dist/cjs/src/validators/utils.js +99 -27
  56. package/dist/cjs/tsconfig.types.tsbuildinfo +1 -1
  57. package/dist/cjs/types/adapter/fields/array.d.ts +2 -2
  58. package/dist/cjs/types/adapter/fields/array.d.ts.map +1 -1
  59. package/dist/cjs/types/adapter/fields/boolean.d.ts.map +1 -1
  60. package/dist/cjs/types/adapter/fields/datetime.d.ts.map +1 -1
  61. package/dist/cjs/types/adapter/fields/index.d.ts +2 -2
  62. package/dist/cjs/types/adapter/fields/index.d.ts.map +1 -1
  63. package/dist/cjs/types/adapter/fields/number.d.ts.map +1 -1
  64. package/dist/cjs/types/adapter/fields/object.d.ts +2 -1
  65. package/dist/cjs/types/adapter/fields/object.d.ts.map +1 -1
  66. package/dist/cjs/types/adapter/fields/string.d.ts.map +1 -1
  67. package/dist/cjs/types/adapter/fields/union.d.ts.map +1 -1
  68. package/dist/cjs/types/adapter/index.d.ts +1 -0
  69. package/dist/cjs/types/adapter/index.d.ts.map +1 -1
  70. package/dist/cjs/types/adapter/types.d.ts +28 -18
  71. package/dist/cjs/types/adapter/types.d.ts.map +1 -1
  72. package/dist/cjs/types/constants.d.ts +0 -1
  73. package/dist/cjs/types/constants.d.ts.map +1 -1
  74. package/dist/cjs/types/domain.d.ts +5 -4
  75. package/dist/cjs/types/domain.d.ts.map +1 -1
  76. package/dist/cjs/types/index.d.ts +78 -55
  77. package/dist/cjs/types/index.d.ts.map +1 -1
  78. package/dist/cjs/types/model.d.ts +17 -17
  79. package/dist/cjs/types/model.d.ts.map +1 -1
  80. package/dist/cjs/types/schema/array.d.ts +168 -47
  81. package/dist/cjs/types/schema/array.d.ts.map +1 -1
  82. package/dist/cjs/types/schema/boolean.d.ts +103 -44
  83. package/dist/cjs/types/schema/boolean.d.ts.map +1 -1
  84. package/dist/cjs/types/schema/datetime.d.ts +90 -30
  85. package/dist/cjs/types/schema/datetime.d.ts.map +1 -1
  86. package/dist/cjs/types/schema/number.d.ts +133 -125
  87. package/dist/cjs/types/schema/number.d.ts.map +1 -1
  88. package/dist/cjs/types/schema/object.d.ts +104 -35
  89. package/dist/cjs/types/schema/object.d.ts.map +1 -1
  90. package/dist/cjs/types/schema/schema.d.ts +62 -44
  91. package/dist/cjs/types/schema/schema.d.ts.map +1 -1
  92. package/dist/cjs/types/schema/string.d.ts +152 -65
  93. package/dist/cjs/types/schema/string.d.ts.map +1 -1
  94. package/dist/cjs/types/schema/types.d.ts +11 -2
  95. package/dist/cjs/types/schema/types.d.ts.map +1 -1
  96. package/dist/cjs/types/schema/union.d.ts +133 -40
  97. package/dist/cjs/types/schema/union.d.ts.map +1 -1
  98. package/dist/cjs/types/types.d.ts +35 -0
  99. package/dist/cjs/types/types.d.ts.map +1 -1
  100. package/dist/cjs/types/utils.d.ts +41 -27
  101. package/dist/cjs/types/utils.d.ts.map +1 -1
  102. package/dist/cjs/types/validators/array.d.ts.map +1 -1
  103. package/dist/cjs/types/validators/boolean.d.ts.map +1 -1
  104. package/dist/cjs/types/validators/datetime.d.ts.map +1 -1
  105. package/dist/cjs/types/validators/number.d.ts +5 -6
  106. package/dist/cjs/types/validators/number.d.ts.map +1 -1
  107. package/dist/cjs/types/validators/object.d.ts.map +1 -1
  108. package/dist/cjs/types/validators/schema.d.ts +2 -2
  109. package/dist/cjs/types/validators/schema.d.ts.map +1 -1
  110. package/dist/cjs/types/validators/string.d.ts +9 -9
  111. package/dist/cjs/types/validators/string.d.ts.map +1 -1
  112. package/dist/cjs/types/validators/utils.d.ts +44 -27
  113. package/dist/cjs/types/validators/utils.d.ts.map +1 -1
  114. package/dist/esm/src/adapter/fields/index.js +2 -2
  115. package/dist/esm/src/adapter/fields/object.js +6 -0
  116. package/dist/esm/src/adapter/index.js +1 -0
  117. package/dist/esm/src/constants.js +1 -2
  118. package/dist/esm/src/domain.js +11 -1
  119. package/dist/esm/src/index.js +38 -73
  120. package/dist/esm/src/model.js +83 -78
  121. package/dist/esm/src/schema/array.js +136 -54
  122. package/dist/esm/src/schema/boolean.js +98 -44
  123. package/dist/esm/src/schema/datetime.js +91 -38
  124. package/dist/esm/src/schema/number.js +127 -110
  125. package/dist/esm/src/schema/object.js +98 -43
  126. package/dist/esm/src/schema/schema.js +102 -67
  127. package/dist/esm/src/schema/string.js +147 -59
  128. package/dist/esm/src/schema/union.js +119 -40
  129. package/dist/esm/src/types.js +14 -1
  130. package/dist/esm/src/utils.js +56 -27
  131. package/dist/esm/src/validators/array.js +6 -1
  132. package/dist/esm/src/validators/boolean.js +2 -0
  133. package/dist/esm/src/validators/datetime.js +4 -0
  134. package/dist/esm/src/validators/number.js +9 -23
  135. package/dist/esm/src/validators/object.js +1 -0
  136. package/dist/esm/src/validators/schema.js +5 -1
  137. package/dist/esm/src/validators/string.js +30 -2
  138. package/dist/esm/src/validators/union.js +5 -4
  139. package/dist/esm/src/validators/utils.js +62 -36
  140. package/package.json +3 -3
  141. package/src/adapter/fields/array.ts +2 -2
  142. package/src/adapter/fields/boolean.ts +3 -8
  143. package/src/adapter/fields/datetime.ts +3 -9
  144. package/src/adapter/fields/index.ts +11 -11
  145. package/src/adapter/fields/number.ts +3 -9
  146. package/src/adapter/fields/object.ts +13 -10
  147. package/src/adapter/fields/string.ts +3 -9
  148. package/src/adapter/fields/union.ts +3 -9
  149. package/src/adapter/index.ts +1 -0
  150. package/src/adapter/types.ts +60 -45
  151. package/src/constants.ts +1 -3
  152. package/src/domain.ts +15 -1
  153. package/src/index.ts +189 -211
  154. package/src/model.ts +119 -115
  155. package/src/schema/array.ts +274 -90
  156. package/src/schema/boolean.ts +145 -60
  157. package/src/schema/datetime.ts +133 -49
  158. package/src/schema/number.ts +210 -173
  159. package/src/schema/object.ts +167 -74
  160. package/src/schema/schema.ts +205 -126
  161. package/src/schema/string.ts +221 -94
  162. package/src/schema/types.ts +44 -16
  163. package/src/schema/union.ts +193 -68
  164. package/src/types.ts +53 -0
  165. package/src/utils.ts +115 -57
  166. package/src/validators/array.ts +46 -27
  167. package/src/validators/boolean.ts +13 -7
  168. package/src/validators/datetime.ts +24 -16
  169. package/src/validators/number.ts +53 -63
  170. package/src/validators/object.ts +6 -5
  171. package/src/validators/schema.ts +33 -25
  172. package/src/validators/string.ts +122 -59
  173. package/src/validators/union.ts +8 -8
  174. package/src/validators/utils.ts +67 -42
@@ -1,6 +1,5 @@
1
1
  import Schema from './schema';
2
2
  import type { DefinitionsOfSchemaType } from './types';
3
- import type { Narrow } from '@palmares/core';
4
3
  export default class StringSchema<TType extends {
5
4
  input: any;
6
5
  validate: any;
@@ -14,45 +13,48 @@ export default class StringSchema<TType extends {
14
13
  representation: string;
15
14
  validate: string;
16
15
  }, TDefinitions extends DefinitionsOfSchemaType = DefinitionsOfSchemaType> extends Schema<TType, TDefinitions> {
17
- protected __is: {
18
- value: Narrow<TType['input'] | TType['input'][]>;
16
+ protected __is?: {
17
+ value: TType['input'] | TType['input'][];
19
18
  message: string;
20
19
  };
21
- protected __email: {
20
+ protected __email?: {
22
21
  message: string;
23
22
  };
24
- protected __uuid: {
23
+ protected __uuid?: {
25
24
  message: string;
26
25
  };
27
- protected __minLength: {
26
+ protected __minLength?: {
28
27
  value: number;
29
- inclusive: boolean;
30
28
  message: string;
31
29
  };
32
- protected __maxLength: {
30
+ protected __maxLength?: {
33
31
  value: number;
34
- inclusive: boolean;
35
32
  message: string;
36
33
  };
37
- protected __regex: {
34
+ protected __regex?: {
38
35
  value: RegExp;
39
36
  message: string;
40
37
  };
41
- protected __endsWith: {
38
+ protected __endsWith?: {
42
39
  value: string;
43
40
  message: string;
44
41
  };
45
- protected __startsWith: {
42
+ protected __startsWith?: {
46
43
  value: string;
47
44
  message: string;
48
45
  };
49
- protected __includes: {
46
+ protected __includes?: {
50
47
  value: string;
51
48
  message: string;
52
49
  };
50
+ protected __type: {
51
+ message: string;
52
+ check: (value: TType['input']) => boolean;
53
+ };
53
54
  protected __transformToAdapter(options: Parameters<Schema['__transformToAdapter']>[0]): Promise<any>;
54
55
  /**
55
- * This let's you refine the schema with custom validations. This is useful when you want to validate something that is not supported by default by the schema adapter.
56
+ * This let's you refine the schema with custom validations. This is useful when you want to validate something that
57
+ * is not supported by default by the schema adapter.
56
58
  *
57
59
  * @example
58
60
  * ```typescript
@@ -64,7 +66,8 @@ export default class StringSchema<TType extends {
64
66
  *
65
67
  * const { errors, parsed } = await numberSchema.parse(-1);
66
68
  *
67
- * console.log(errors); // [{ isValid: false, code: 'invalid_number', message: 'The number should be greater than 0', path: [] }]
69
+ * // [{ isValid: false, code: 'invalid_number', message: 'The number should be greater than 0', path: [] }]
70
+ * console.log(errors);
68
71
  * ```
69
72
  *
70
73
  * @param refinementCallback - The callback that will be called to validate the value.
@@ -108,10 +111,7 @@ export default class StringSchema<TType extends {
108
111
  *
109
112
  * @returns - The schema we are working with.
110
113
  */
111
- optional(options?: {
112
- message: string;
113
- allow: false;
114
- }): StringSchema<{
114
+ optional(): StringSchema<{
115
115
  input: TType["input"] | undefined | null;
116
116
  validate: TType["validate"] | undefined | null;
117
117
  internal: TType["internal"] | undefined | null;
@@ -119,8 +119,29 @@ export default class StringSchema<TType extends {
119
119
  representation: TType["representation"] | undefined | null;
120
120
  }, TDefinitions>;
121
121
  /**
122
- * Allows the value to be null and ONLY null. You can also use this function to set a custom message when the value is NULL by setting
123
- * the { message: 'Your custom message', allow: false } on the options.
122
+ * Just adds a message when the value is undefined. It's just a syntax sugar for
123
+ *
124
+ * ```typescript
125
+ * p.string().optional({ message: 'This value cannot be null', allow: false })
126
+ * ```
127
+ *
128
+ * @param options - The options of nonOptional function
129
+ * @param options.message - A custom message if the value is undefined.
130
+ *
131
+ * @returns - The schema.
132
+ */
133
+ nonOptional(options?: {
134
+ message: string;
135
+ }): StringSchema<{
136
+ input: TType["input"];
137
+ validate: TType["validate"];
138
+ internal: TType["internal"];
139
+ output: TType["output"];
140
+ representation: TType["representation"];
141
+ }, TDefinitions>;
142
+ /**
143
+ * Allows the value to be null and ONLY null. You can also use this function to set a custom message when the value
144
+ * is NULL by setting the { message: 'Your custom message', allow: false } on the options.
124
145
  *
125
146
  * @example
126
147
  * ```typescript
@@ -154,14 +175,36 @@ export default class StringSchema<TType extends {
154
175
  representation: TType["representation"] | null;
155
176
  }, TDefinitions>;
156
177
  /**
157
- * This method will remove the value from the representation of the schema. If the value is undefined it will keep that way
158
- * otherwise it will set the value to undefined after it's validated.
178
+ * Just adds a message when the value is null. It's just a syntax sugar for
179
+ *
180
+ * ```typescript
181
+ * p.string().nullable({ message: 'This value cannot be null', allow: false })
182
+ * ```
183
+ *
184
+ * @param options - The options of nonNullable function
185
+ * @param options.message - A custom message if the value is null.
186
+ *
187
+ * @returns - The schema.
188
+ */
189
+ nonNullable(options?: {
190
+ message: string;
191
+ }): StringSchema<{
192
+ input: TType["input"];
193
+ validate: TType["validate"];
194
+ internal: TType["internal"];
195
+ output: TType["output"];
196
+ representation: TType["representation"];
197
+ }, TDefinitions>;
198
+ /**
199
+ * This method will remove the value from the representation of the schema. If the value is undefined it will keep
200
+ * that way otherwise it will set the value to undefined after it's validated.
159
201
  * This is used in conjunction with the {@link data} function, the {@link parse} function or {@link validate}
160
202
  * function. This will remove the value from the representation of the schema.
161
203
  *
162
- * By default, the value will be removed just from the representation, in other words, when you call the {@link data} function.
163
- * But if you want to remove the value from the internal representation, you can pass the argument `toInternal` as true.
164
- * Then if you still want to remove the value from the representation, you will need to pass the argument `toRepresentation` as true as well.
204
+ * By default, the value will be removed just from the representation, in other words, when you call the {@link data}
205
+ * function. But if you want to remove the value from the internal representation, you can pass the argument
206
+ * `toInternal` as true. Then if you still want to remove the value from the representation, you will need to pass
207
+ * the argument `toRepresentation` as true as well.
165
208
  *
166
209
  * @example
167
210
  * ```typescript
@@ -183,9 +226,10 @@ export default class StringSchema<TType extends {
183
226
  * ```
184
227
  *
185
228
  *
186
- * @param args - By default, the value will be removed just from the representation, in other words, when you call the {@link data} function.
187
- * But if you want to remove the value from the internal representation, you can pass the argument `toInternal` as true.
188
- * Then if you still want to remove the value from the representation, you will need to pass the argument `toRepresentation` as true as well.
229
+ * @param args - By default, the value will be removed just from the representation, in other words, when you call
230
+ * the {@link data} function. But if you want to remove the value from the internal representation, you can pass the
231
+ * argument `toInternal` as true. Then if you still want to remove the value from the representation, you will need
232
+ * to pass the argument `toRepresentation` as true as well.
189
233
  *
190
234
  * @returns The schema.
191
235
  */
@@ -200,9 +244,9 @@ export default class StringSchema<TType extends {
200
244
  representation: TToRepresentation extends true ? undefined : TType["representation"];
201
245
  }, TDefinitions>;
202
246
  /**
203
- * This function is used in conjunction with the {@link validate} function. It's used to save a value to an external source
204
- * like a database. You should always return the schema after you save the value, that way we will always have the correct type
205
- * of the schema after the save operation.
247
+ * This function is used in conjunction with the {@link validate} function. It's used to save a value to an external
248
+ * source like a database. You should always return the schema after you save the value, that way we will always have
249
+ * the correct type of the schema after the save operation.
206
250
  *
207
251
  * You can use the {@link toRepresentation} function to transform and clean the value it returns after the save.
208
252
  *
@@ -251,7 +295,8 @@ export default class StringSchema<TType extends {
251
295
  hasSave: true;
252
296
  }>;
253
297
  /**
254
- * This function is used to add a default value to the schema. If the value is either undefined or null, the default value will be used.
298
+ * This function is used to add a default value to the schema. If the value is either undefined or null, the default
299
+ * value will be used.
255
300
  *
256
301
  * @example
257
302
  * ```typescript
@@ -272,8 +317,9 @@ export default class StringSchema<TType extends {
272
317
  representation: TType["representation"];
273
318
  }, TDefinitions>;
274
319
  /**
275
- * This function let's you customize the schema your own way. After we translate the schema on the adapter we call this function to let you customize
276
- * the custom schema your own way. Our API does not support passthrough? No problem, you can use this function to customize the zod schema.
320
+ * This function let's you customize the schema your own way. After we translate the schema on the adapter we call
321
+ * this function to let you customize the custom schema your own way. Our API does not support passthrough?
322
+ * No problem, you can use this function to customize the zod schema.
277
323
  *
278
324
  * @example
279
325
  * ```typescript
@@ -284,20 +330,21 @@ export default class StringSchema<TType extends {
284
330
  * });
285
331
  *
286
332
  * const { errors, parsed } = await numberSchema.parse(-1);
287
- *
288
- * console.log(errors); // [{ isValid: false, code: 'nonnegative', message: 'The number should be nonnegative', path: [] }]
333
+ * // [{ isValid: false, code: 'nonnegative', message: 'The number should be nonnegative', path: [] }]
334
+ * console.log(errors);
289
335
  * ```
290
336
  *
291
337
  * @param callback - The callback that will be called to customize the schema.
292
- * @param toStringCallback - The callback that will be called to transform the schema to a string when you want to compile the underlying schema
293
- * to a string so you can save it for future runs.
338
+ * @param toStringCallback - The callback that will be called to transform the schema to a string when you want to
339
+ * compile the underlying schema to a string so you can save it for future runs.
294
340
  *
295
341
  * @returns The schema.
296
342
  */
297
343
  extends(callback: (schema: Awaited<ReturnType<NonNullable<TDefinitions['schemaAdapter']['string']>['translate']>>) => Awaited<ReturnType<NonNullable<TDefinitions['schemaAdapter']['field']>['translate']>> | any, toStringCallback?: (schemaAsString: string) => string): this;
298
344
  /**
299
- * This function is used to transform the value to the representation of the schema. When using the {@link data} function. With this function you have full
300
- * control to add data cleaning for example, transforming the data and whatever. Another use case is when you want to return deeply nested recursive data.
345
+ * This function is used to transform the value to the representation of the schema. When using the {@link data}
346
+ * function. With this function you have full control to add data cleaning for example, transforming the data and
347
+ * whatever. Another use case is when you want to return deeply nested recursive data.
301
348
  * The schema maps to itself.
302
349
  *
303
350
  * @example
@@ -346,8 +393,9 @@ export default class StringSchema<TType extends {
346
393
  representation: TRepresentation;
347
394
  }, TDefinitions>;
348
395
  /**
349
- * This function is used to transform the value to the internal representation of the schema. This is useful when you want to transform the value
350
- * to a type that the schema adapter can understand. For example, you might want to transform a string to a date. This is the function you use.
396
+ * This function is used to transform the value to the internal representation of the schema. This is useful when
397
+ * you want to transform the value to a type that the schema adapter can understand. For example, you might want
398
+ * to transform a string to a date. This is the function you use.
351
399
  *
352
400
  * @example
353
401
  * ```typescript
@@ -385,8 +433,9 @@ export default class StringSchema<TType extends {
385
433
  representation: TType["representation"];
386
434
  }, TDefinitions>;
387
435
  /**
388
- * Called before the validation of the schema. Let's say that you want to validate a date that might receive a string, you can convert that string to a date
389
- * here BEFORE the validation. This pretty much transforms the value to a type that the schema adapter can understand.
436
+ * Called before the validation of the schema. Let's say that you want to validate a date that might receive a string,
437
+ * you can convert that string to a date here BEFORE the validation. This pretty much transforms the value to a
438
+ * type that the schema adapter can understand.
390
439
  *
391
440
  * @example
392
441
  * ```typescript
@@ -412,7 +461,8 @@ export default class StringSchema<TType extends {
412
461
  representation: TType["representation"];
413
462
  }, TDefinitions>;
414
463
  /**
415
- * Defines a list of strings that are allowed, it's useful when you want to restrict the values that are allowed. Like a selector or a Choice field.
464
+ * Defines a list of strings that are allowed, it's useful when you want to restrict the values that are allowed.
465
+ * Like a selector or a Choice field.
416
466
  *
417
467
  * @example
418
468
  * ```typescript
@@ -421,14 +471,18 @@ export default class StringSchema<TType extends {
421
471
  * const schema = p.string().is(['Argentina', 'Brazil', 'Chile']);
422
472
  *
423
473
  * schema.parse('Argentina'); // { errors: [], parsed: 'Argentina' }
424
- * schema.parse('Uruguay'); // { errors: [{ code: 'invalid_value', message: 'The value should be equal to Argentina, Brazil, Chile', path: [] }], parsed: 'Uruguay' }
474
+ * // { errors: [{
475
+ * // code: 'invalid_value',
476
+ * // message: 'The value should be equal to Argentina, Brazil, Chile',
477
+ * // path: [] }], parsed: 'Uruguay' }
478
+ * schema.parse('Uruguay');
425
479
  * ```
426
480
  *
427
481
  * @param value - The list of numbers that are allowed
428
482
  *
429
483
  * @returns - The schema instance
430
484
  */
431
- is<const TValue extends TType['input'][]>(value: TValue): Schema<{
485
+ is<const TValue extends TType['input'][]>(value: TValue, options?: Partial<Omit<NonNullable<StringSchema['__is']>, 'value'>>): Schema<{
432
486
  input: TValue[number];
433
487
  output: TValue[number];
434
488
  internal: TValue[number];
@@ -445,7 +499,9 @@ export default class StringSchema<TType extends {
445
499
  * const schema = p.string().endsWith('.com');
446
500
  *
447
501
  * schema.parse('example.com'); // { errors: [], parsed: 'example.com' }
448
- * schema.parse('example.org'); // { errors: [{ code: 'endsWith', message: 'The value should end with .com', path: [] }], parsed: 'example.org' }
502
+ *
503
+ * // { errors: [{ code: 'endsWith', message: 'The value should end with .com', path: [] }], parsed: 'example.org' }
504
+ * schema.parse('example.org');
449
505
  * ```
450
506
  *
451
507
  * @param value - The value that the string should end with.
@@ -454,7 +510,7 @@ export default class StringSchema<TType extends {
454
510
  *
455
511
  * @returns - The schema instance.
456
512
  */
457
- endsWith(value: string, options?: Partial<Omit<StringSchema['__endsWith'], 'value'>>): this;
513
+ endsWith(value: string, options?: Partial<Omit<NonNullable<StringSchema['__endsWith']>, 'value'>>): this;
458
514
  /**
459
515
  * Validates if the string starts with a specific value.
460
516
  *
@@ -465,7 +521,11 @@ export default class StringSchema<TType extends {
465
521
  * const schema = p.string().startsWith('https://');
466
522
  *
467
523
  * schema.parse('https://example.com'); // { errors: [], parsed: 'https://example.com' }
468
- * schema.parse('http://example.com'); // { errors: [{ code: 'startsWith', message: 'The value should start with https://', path: [] }], parsed: 'http://example.com' }
524
+ * // {
525
+ * // errors: [{ code: 'startsWith', message: 'The value should start with https://', path: [] }],
526
+ * // parsed: 'http://example.com'
527
+ * // }
528
+ * schema.parse('http://example.com');
469
529
  * ```
470
530
  *
471
531
  * @param value - The value that the string should start with.
@@ -474,7 +534,7 @@ export default class StringSchema<TType extends {
474
534
  *
475
535
  * @returns - The schema instance.
476
536
  */
477
- startsWith(value: string, options?: Partial<Omit<StringSchema['__startsWith'], 'value'>>): this;
537
+ startsWith(value: string, options?: Partial<Omit<NonNullable<StringSchema['__startsWith']>, 'value'>>): this;
478
538
  /**
479
539
  * Checks if the string includes a specific substring.
480
540
  *
@@ -485,7 +545,13 @@ export default class StringSchema<TType extends {
485
545
  * const schema = p.string().includes('for babies');
486
546
  *
487
547
  * schema.parse('Computer graphics for babies'); // { errors: [], parsed: 'Computer graphics for babies' }
488
- * schema.parse('Learn javascript as you were 5'); // { errors: [{ code: 'includes', message: 'The string value should include the following substring 'for babies', path: [] }], parsed: 'example.org' }
548
+ * // {
549
+ * // errors: [{
550
+ * // code: 'includes',
551
+ * // message: 'The string value should include the following substring 'for babies',
552
+ * // path: []
553
+ * // }], parsed: 'example.org' }
554
+ * schema.parse('Learn javascript as you were 5');
489
555
  * ```
490
556
  *
491
557
  * @param value - The value that the string should include.
@@ -494,7 +560,7 @@ export default class StringSchema<TType extends {
494
560
  *
495
561
  * @returns - The schema instance.
496
562
  */
497
- includes(value: string, options?: Partial<Omit<StringSchema['__includes'], 'value'>>): this;
563
+ includes(value: string, options?: Partial<Omit<NonNullable<StringSchema['__includes']>, 'value'>>): this;
498
564
  /**
499
565
  * Validates if the string matches a specific regex.
500
566
  *
@@ -505,7 +571,15 @@ export default class StringSchema<TType extends {
505
571
  * const schema = p.string().regex(/^[a-z]+$/);
506
572
  *
507
573
  * schema.parse('abc'); // { errors: [], parsed: 'abc' }
508
- * schema.parse('123'); // { errors: [{ code: 'regex', message: 'The value should match the following regex /^[a-z]+$/', path: [] }], parsed: '123' }
574
+ * // {
575
+ * // errors: [{
576
+ * // code: 'regex',
577
+ * // message: 'The value should match the following regex /^[a-z]+$/',
578
+ * // path: []
579
+ * // }],
580
+ * // parsed: '123'
581
+ * // }
582
+ * schema.parse('123');
509
583
  * ```
510
584
  *
511
585
  * @param value - The regex that the string should match.
@@ -514,9 +588,10 @@ export default class StringSchema<TType extends {
514
588
  *
515
589
  * @returns - The schema instance.
516
590
  */
517
- regex(value: RegExp, options?: Partial<Omit<StringSchema['__regex'], 'value'>>): this;
591
+ regex(value: RegExp, options?: Partial<Omit<NonNullable<StringSchema['__regex']>, 'value'>>): this;
518
592
  /**
519
- * Validates if the string has a maximum length. Use { inclusive: true } to allow the value to have the same length as the maximum length.
593
+ * Validates if the string has a maximum length. Use { inclusive: true } to allow the value to have the same length
594
+ * as the maximum length.
520
595
  *
521
596
  * @example
522
597
  * ```typescript
@@ -525,7 +600,11 @@ export default class StringSchema<TType extends {
525
600
  * const schema = p.string().maxLength(5);
526
601
  *
527
602
  * schema.parse('12345'); // { errors: [], parsed: '12345' }
528
- * schema.parse('123456'); // { errors: [{ code: 'maxLength', message: 'The value should have a maximum length of 5', path: [] }], parsed: '123
603
+ * // {
604
+ * // errors: [{ code: 'maxLength', message: 'The value should have a maximum length of 5', path: [] }],
605
+ * // parsed: '123
606
+ * // }
607
+ * schema.parse('123456');
529
608
  * ```
530
609
  *
531
610
  * @param value - The maximum length that the string should have.
@@ -535,9 +614,10 @@ export default class StringSchema<TType extends {
535
614
  *
536
615
  * @returns - The schema instance.
537
616
  */
538
- maxLength(value: number, options?: Partial<Omit<StringSchema['__maxLength'], 'value'>>): this;
617
+ maxLength(value: number, options?: Partial<Omit<NonNullable<StringSchema['__maxLength']>, 'value'>>): this;
539
618
  /**
540
- * Validates if the string has a minimum length. Use { inclusive: true } to allow the value to have the same length as the minimum length.
619
+ * Validates if the string has a minimum length. Use { inclusive: true } to allow the value to have the same length
620
+ * as the minimum length.
541
621
  *
542
622
  * @example
543
623
  * ```typescript
@@ -546,7 +626,11 @@ export default class StringSchema<TType extends {
546
626
  * const schema = p.string().minLength(5);
547
627
  *
548
628
  * schema.parse('12345'); // { errors: [], parsed: '12345' }
549
- * schema.parse('1234'); // { errors: [{ code: 'minLength', message: 'The value should have a minimum length of 5', path: [] }], parsed: '1234' }
629
+ * // {
630
+ * // errors: [{ code: 'minLength', message: 'The value should have a minimum length of 5', path: [] }],
631
+ * // parsed: '1234'
632
+ * // }
633
+ * schema.parse('1234');
550
634
  * ```
551
635
  *
552
636
  * @param value - The minimum length that the string should have.
@@ -556,7 +640,7 @@ export default class StringSchema<TType extends {
556
640
  *
557
641
  * @returns - The schema instance.
558
642
  */
559
- minLength(value: number, options?: Partial<Omit<StringSchema['__minLength'], 'value'>>): this;
643
+ minLength(value: number, options?: Partial<Omit<NonNullable<StringSchema['__minLength']>, 'value'>>): this;
560
644
  /**
561
645
  * Validates if the string is a valid UUID.
562
646
  *
@@ -566,11 +650,13 @@ export default class StringSchema<TType extends {
566
650
  *
567
651
  * const schema = p.string().uuid();
568
652
  *
569
- * schema.parse('550e8400-e29b-41d4-a716-446655440000'); // { errors: [], parsed: '550e8400-e29b-41d4-a716-446655440000' }
653
+ * // { errors: [], parsed: '550e8400-e29b-41d4-a716-446655440000' }
654
+ * schema.parse('550e8400-e29b-41d4-a716-446655440000');
570
655
  * ```
571
656
  *
572
657
  * @param options - The options for the uuid function.
573
- * @param options.message - The message to be shown when the value is not a valid UUID. Defaults to 'The value should be a valid UUID'.
658
+ * @param options.message - The message to be shown when the value is not a valid UUID. Defaults to
659
+ * 'The value should be a valid UUID'.
574
660
  *
575
661
  * @returns - The schema instance.
576
662
  */
@@ -589,7 +675,8 @@ export default class StringSchema<TType extends {
589
675
  * ```
590
676
  *
591
677
  * @param options - The options for the email function.
592
- * @param options.message - The message to be shown when the value is not a valid email. Defaults to 'The value should be a valid email'.
678
+ * @param options.message - The message to be shown when the value is not a valid email.
679
+ * Defaults to 'The value should be a valid email'.
593
680
  *
594
681
  * @returns - The schema instance.
595
682
  */
@@ -1 +1 @@
1
- {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../../src/schema/string.ts"],"names":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MAAM;gBACL,MAAM;kBACJ,MAAM;wBACA,MAAM;kBACZ,MAAM;;CAOvB;AAED,eAAO,MAAM,MAAM,yBAAmB,CAAC"}
@@ -19,6 +19,7 @@ export type ValidationFallbackCallbackType = Validator['fallbacks'][number];
19
19
  export type ValidationFallbackCallbackReturnType = {
20
20
  parsed: any;
21
21
  errors: {
22
+ received: any;
22
23
  isValid: boolean;
23
24
  code: ErrorCodes;
24
25
  message: string;
@@ -28,6 +29,7 @@ export type ValidationFallbackCallbackReturnType = {
28
29
  };
29
30
  export type ValidationFallbackReturnType = {
30
31
  type: ValidatorTypes;
32
+ name: string;
31
33
  callback: ValidationFallbackCallbackType;
32
34
  };
33
35
  type TypesOfSchema = Schema extends Schema<infer TType, any> ? TType : never;
@@ -61,10 +63,17 @@ export type ExtractTypeFromObjectOfSchemas<TData extends Record<string, Schema>,
61
63
  } & {
62
64
  [key in keyof TData as undefined extends ExtractTypeFromSchemaByTypeOfSchema<TData[key], TTypeToExtract> ? key : never]?: ExtractTypeFromSchemaByTypeOfSchema<TData[key], TTypeToExtract>;
63
65
  };
64
- export type ExtractTypeFromArrayOfSchemas<TSchemas extends readonly [Schema, ...Schema[]] | [Schema[]], TTypeToExtract extends keyof TypesOfSchema = 'input', TResult extends any[] = []> = TSchemas extends readonly [infer TSchema, ...infer TRestSchemas] ? TSchema extends Schema ? TRestSchemas extends readonly [Schema, ...Schema[]] ? ExtractTypeFromArrayOfSchemas<TRestSchemas, TTypeToExtract, [
66
+ export type ExtractTypeFromUnionOfSchemas<TSchemas extends readonly Schema[] = [], TType extends 'input' | 'output' | 'representation' | 'internal' | 'validate' = 'input'> = TSchemas extends readonly [infer TFirstSchema, ...infer TRestOfSchemas] ? TFirstSchema extends Schema<{
67
+ input: infer TInput;
68
+ internal: infer TInternal;
69
+ output: infer TOutput;
70
+ representation: infer TRepresentation;
71
+ validate: infer TValidate;
72
+ }> ? (TType extends 'output' ? TOutput : TType extends 'representation' ? TRepresentation : TType extends 'internal' ? TInternal : TType extends 'validate' ? TValidate : TInput) | ExtractTypeFromUnionOfSchemas<TRestOfSchemas extends readonly Schema[] ? TRestOfSchemas : [], TType> : unknown : never;
73
+ export type ExtractTypeFromArrayOfSchemas<TSchemas extends readonly [Schema, ...Schema[]] | [[Schema]], TTypeToExtract extends keyof TypesOfSchema = 'input', TResult extends any[] = []> = TSchemas extends readonly [infer TSchema, ...infer TRestSchemas] ? TSchema extends Schema ? TRestSchemas extends readonly [Schema, ...Schema[]] ? ExtractTypeFromArrayOfSchemas<TRestSchemas, TTypeToExtract, [
65
74
  ...TResult,
66
75
  ExtractTypeFromSchemaByTypeOfSchema<TSchema, TTypeToExtract>
67
- ]> : [...TResult, ExtractTypeFromSchemaByTypeOfSchema<TSchema, TTypeToExtract>] : TSchemas extends [infer TArraySchema] ? TArraySchema extends Schema[] ? ExtractTypeFromSchemaByTypeOfSchema<TArraySchema[number], TTypeToExtract>[] : never : never : never;
76
+ ]> : [...TResult, ExtractTypeFromSchemaByTypeOfSchema<TSchema, TTypeToExtract>] : TSchemas extends [[infer TSchema]] ? TSchema extends Schema ? ExtractTypeFromSchemaByTypeOfSchema<TSchema, TTypeToExtract>[] : never : never : never;
68
77
  export type ExtractUnionTypesFromSchemas<TSchemas extends readonly Schema<any, any>[]> = TSchemas[number] extends Schema<infer TType, any> ? TType : never;
69
78
  export {};
70
79
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/schema/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,YAAY,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,YAAY,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,aAAa,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAA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