@palmares/schemas 0.0.1 → 0.1.1

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 (175) hide show
  1. package/.turbo/turbo-build$colon$watch.log +12 -410
  2. package/.turbo/turbo-build.log +13 -4
  3. package/CHANGELOG.md +26 -0
  4. package/__tests__/.drizzle/migrations/0000_skinny_harrier.sql +22 -0
  5. package/__tests__/.drizzle/migrations/meta/0000_snapshot.json +156 -0
  6. package/__tests__/.drizzle/migrations/meta/_journal.json +13 -0
  7. package/__tests__/.drizzle/schema.ts +35 -0
  8. package/__tests__/drizzle.config.ts +11 -0
  9. package/__tests__/eslint.config.js +10 -0
  10. package/__tests__/manage.ts +5 -0
  11. package/__tests__/node_modules/.bin/drizzle-kit +17 -0
  12. package/__tests__/node_modules/.bin/esbuild +14 -0
  13. package/__tests__/node_modules/.bin/tsc +17 -0
  14. package/__tests__/node_modules/.bin/tsserver +17 -0
  15. package/__tests__/node_modules/.bin/tsx +17 -0
  16. package/__tests__/package.json +36 -0
  17. package/__tests__/sqlite.db +0 -0
  18. package/__tests__/src/core/array.test.ts +130 -0
  19. package/__tests__/src/core/boolean.test.ts +66 -0
  20. package/__tests__/src/core/datetime.test.ts +102 -0
  21. package/__tests__/src/core/index.ts +35 -0
  22. package/__tests__/src/core/model.test.ts +260 -0
  23. package/__tests__/src/core/models.ts +50 -0
  24. package/__tests__/src/core/numbers.test.ts +177 -0
  25. package/__tests__/src/core/object.test.ts +198 -0
  26. package/__tests__/src/core/string.test.ts +222 -0
  27. package/__tests__/src/core/test.test.ts +59 -0
  28. package/__tests__/src/core/types.test.ts +97 -0
  29. package/__tests__/src/core/union.test.ts +99 -0
  30. package/__tests__/src/settings.ts +71 -0
  31. package/__tests__/tsconfig.json +11 -0
  32. package/dist/cjs/src/adapter/fields/index.js +2 -2
  33. package/dist/cjs/src/adapter/fields/object.js +9 -0
  34. package/dist/cjs/src/adapter/index.js +1 -0
  35. package/dist/cjs/src/constants.js +1 -7
  36. package/dist/cjs/src/domain.js +146 -1
  37. package/dist/cjs/src/index.js +69 -74
  38. package/dist/cjs/src/model.js +206 -206
  39. package/dist/cjs/src/schema/array.js +185 -58
  40. package/dist/cjs/src/schema/boolean.js +105 -44
  41. package/dist/cjs/src/schema/datetime.js +104 -38
  42. package/dist/cjs/src/schema/number.js +134 -114
  43. package/dist/cjs/src/schema/object.js +106 -43
  44. package/dist/cjs/src/schema/schema.js +123 -75
  45. package/dist/cjs/src/schema/string.js +152 -58
  46. package/dist/cjs/src/schema/union.js +412 -290
  47. package/dist/cjs/src/utils.js +42 -15
  48. package/dist/cjs/src/validators/array.js +6 -1
  49. package/dist/cjs/src/validators/boolean.js +2 -0
  50. package/dist/cjs/src/validators/datetime.js +4 -0
  51. package/dist/cjs/src/validators/number.js +12 -40
  52. package/dist/cjs/src/validators/object.js +1 -0
  53. package/dist/cjs/src/validators/schema.js +5 -1
  54. package/dist/cjs/src/validators/string.js +30 -2
  55. package/dist/cjs/src/validators/union.js +5 -4
  56. package/dist/cjs/src/validators/utils.js +99 -27
  57. package/dist/cjs/tsconfig.types.tsbuildinfo +1 -1
  58. package/dist/cjs/types/adapter/fields/array.d.ts +2 -2
  59. package/dist/cjs/types/adapter/fields/array.d.ts.map +1 -1
  60. package/dist/cjs/types/adapter/fields/boolean.d.ts.map +1 -1
  61. package/dist/cjs/types/adapter/fields/datetime.d.ts.map +1 -1
  62. package/dist/cjs/types/adapter/fields/index.d.ts +2 -2
  63. package/dist/cjs/types/adapter/fields/index.d.ts.map +1 -1
  64. package/dist/cjs/types/adapter/fields/number.d.ts.map +1 -1
  65. package/dist/cjs/types/adapter/fields/object.d.ts +2 -1
  66. package/dist/cjs/types/adapter/fields/object.d.ts.map +1 -1
  67. package/dist/cjs/types/adapter/fields/string.d.ts.map +1 -1
  68. package/dist/cjs/types/adapter/fields/union.d.ts.map +1 -1
  69. package/dist/cjs/types/adapter/index.d.ts +1 -0
  70. package/dist/cjs/types/adapter/index.d.ts.map +1 -1
  71. package/dist/cjs/types/adapter/types.d.ts +28 -18
  72. package/dist/cjs/types/adapter/types.d.ts.map +1 -1
  73. package/dist/cjs/types/constants.d.ts +0 -1
  74. package/dist/cjs/types/constants.d.ts.map +1 -1
  75. package/dist/cjs/types/domain.d.ts +5 -4
  76. package/dist/cjs/types/domain.d.ts.map +1 -1
  77. package/dist/cjs/types/index.d.ts +78 -55
  78. package/dist/cjs/types/index.d.ts.map +1 -1
  79. package/dist/cjs/types/model.d.ts +17 -17
  80. package/dist/cjs/types/model.d.ts.map +1 -1
  81. package/dist/cjs/types/schema/array.d.ts +168 -47
  82. package/dist/cjs/types/schema/array.d.ts.map +1 -1
  83. package/dist/cjs/types/schema/boolean.d.ts +103 -44
  84. package/dist/cjs/types/schema/boolean.d.ts.map +1 -1
  85. package/dist/cjs/types/schema/datetime.d.ts +90 -30
  86. package/dist/cjs/types/schema/datetime.d.ts.map +1 -1
  87. package/dist/cjs/types/schema/number.d.ts +133 -125
  88. package/dist/cjs/types/schema/number.d.ts.map +1 -1
  89. package/dist/cjs/types/schema/object.d.ts +104 -35
  90. package/dist/cjs/types/schema/object.d.ts.map +1 -1
  91. package/dist/cjs/types/schema/schema.d.ts +62 -44
  92. package/dist/cjs/types/schema/schema.d.ts.map +1 -1
  93. package/dist/cjs/types/schema/string.d.ts +152 -65
  94. package/dist/cjs/types/schema/string.d.ts.map +1 -1
  95. package/dist/cjs/types/schema/types.d.ts +11 -2
  96. package/dist/cjs/types/schema/types.d.ts.map +1 -1
  97. package/dist/cjs/types/schema/union.d.ts +133 -40
  98. package/dist/cjs/types/schema/union.d.ts.map +1 -1
  99. package/dist/cjs/types/types.d.ts +35 -0
  100. package/dist/cjs/types/types.d.ts.map +1 -1
  101. package/dist/cjs/types/utils.d.ts +41 -27
  102. package/dist/cjs/types/utils.d.ts.map +1 -1
  103. package/dist/cjs/types/validators/array.d.ts.map +1 -1
  104. package/dist/cjs/types/validators/boolean.d.ts.map +1 -1
  105. package/dist/cjs/types/validators/datetime.d.ts.map +1 -1
  106. package/dist/cjs/types/validators/number.d.ts +5 -6
  107. package/dist/cjs/types/validators/number.d.ts.map +1 -1
  108. package/dist/cjs/types/validators/object.d.ts.map +1 -1
  109. package/dist/cjs/types/validators/schema.d.ts +2 -2
  110. package/dist/cjs/types/validators/schema.d.ts.map +1 -1
  111. package/dist/cjs/types/validators/string.d.ts +9 -9
  112. package/dist/cjs/types/validators/string.d.ts.map +1 -1
  113. package/dist/cjs/types/validators/utils.d.ts +44 -27
  114. package/dist/cjs/types/validators/utils.d.ts.map +1 -1
  115. package/dist/esm/src/adapter/fields/index.js +2 -2
  116. package/dist/esm/src/adapter/fields/object.js +6 -0
  117. package/dist/esm/src/adapter/index.js +1 -0
  118. package/dist/esm/src/constants.js +1 -2
  119. package/dist/esm/src/domain.js +11 -1
  120. package/dist/esm/src/index.js +38 -73
  121. package/dist/esm/src/model.js +83 -78
  122. package/dist/esm/src/schema/array.js +136 -54
  123. package/dist/esm/src/schema/boolean.js +98 -44
  124. package/dist/esm/src/schema/datetime.js +91 -38
  125. package/dist/esm/src/schema/number.js +127 -110
  126. package/dist/esm/src/schema/object.js +98 -43
  127. package/dist/esm/src/schema/schema.js +102 -67
  128. package/dist/esm/src/schema/string.js +147 -59
  129. package/dist/esm/src/schema/union.js +119 -40
  130. package/dist/esm/src/types.js +14 -1
  131. package/dist/esm/src/utils.js +56 -27
  132. package/dist/esm/src/validators/array.js +6 -1
  133. package/dist/esm/src/validators/boolean.js +2 -0
  134. package/dist/esm/src/validators/datetime.js +4 -0
  135. package/dist/esm/src/validators/number.js +9 -23
  136. package/dist/esm/src/validators/object.js +1 -0
  137. package/dist/esm/src/validators/schema.js +5 -1
  138. package/dist/esm/src/validators/string.js +30 -2
  139. package/dist/esm/src/validators/union.js +5 -4
  140. package/dist/esm/src/validators/utils.js +62 -36
  141. package/package.json +3 -3
  142. package/src/adapter/fields/array.ts +2 -2
  143. package/src/adapter/fields/boolean.ts +3 -8
  144. package/src/adapter/fields/datetime.ts +3 -9
  145. package/src/adapter/fields/index.ts +11 -11
  146. package/src/adapter/fields/number.ts +3 -9
  147. package/src/adapter/fields/object.ts +13 -10
  148. package/src/adapter/fields/string.ts +3 -9
  149. package/src/adapter/fields/union.ts +3 -9
  150. package/src/adapter/index.ts +1 -0
  151. package/src/adapter/types.ts +60 -45
  152. package/src/constants.ts +1 -3
  153. package/src/domain.ts +15 -1
  154. package/src/index.ts +189 -211
  155. package/src/model.ts +119 -115
  156. package/src/schema/array.ts +274 -90
  157. package/src/schema/boolean.ts +145 -60
  158. package/src/schema/datetime.ts +133 -49
  159. package/src/schema/number.ts +210 -173
  160. package/src/schema/object.ts +167 -74
  161. package/src/schema/schema.ts +205 -126
  162. package/src/schema/string.ts +221 -94
  163. package/src/schema/types.ts +44 -16
  164. package/src/schema/union.ts +193 -68
  165. package/src/types.ts +53 -0
  166. package/src/utils.ts +115 -57
  167. package/src/validators/array.ts +46 -27
  168. package/src/validators/boolean.ts +13 -7
  169. package/src/validators/datetime.ts +24 -16
  170. package/src/validators/number.ts +53 -63
  171. package/src/validators/object.ts +6 -5
  172. package/src/validators/schema.ts +33 -25
  173. package/src/validators/string.ts +122 -59
  174. package/src/validators/union.ts +8 -8
  175. package/src/validators/utils.ts +67 -42
@@ -1,5 +1,4 @@
1
1
  import Schema from './schema';
2
- import { getDefaultAdapter } from '../conf';
3
2
  import convertFromStringBuilder from '../parsers/convert-from-string';
4
3
  import { defaultTransform, defaultTransformToAdapter } from '../utils';
5
4
  import { booleanValidation } from '../validators/boolean';
@@ -21,7 +20,7 @@ export default class BooleanSchema<
21
20
  representation: boolean;
22
21
  validate: boolean;
23
22
  },
24
- TDefinitions extends DefinitionsOfSchemaType = DefinitionsOfSchemaType,
23
+ TDefinitions extends DefinitionsOfSchemaType = DefinitionsOfSchemaType
25
24
  > extends Schema<TType, TDefinitions> {
26
25
  protected __allowString!: boolean;
27
26
  protected __allowNumber!: boolean;
@@ -33,6 +32,20 @@ export default class BooleanSchema<
33
32
  message: string;
34
33
  };
35
34
 
35
+ protected __type: {
36
+ message: string;
37
+ check: (value: TType['input']) => boolean;
38
+ } = {
39
+ message: 'Invalid type',
40
+ check: (value: any) => {
41
+ if (typeof value === 'string' && this.__allowString) return true;
42
+ if (typeof value === 'number' && this.__allowNumber) return true;
43
+ if (Array.isArray(this.__trueValues) && this.__trueValues.includes(value)) return true;
44
+ if (Array.isArray(this.__falseValues) && this.__falseValues.includes(value)) return true;
45
+ return typeof value === 'boolean';
46
+ }
47
+ };
48
+
36
49
  protected async __transformToAdapter(options: Parameters<Schema['__transformToAdapter']>[0]): Promise<any> {
37
50
  return defaultTransformToAdapter(
38
51
  async (adapter) => {
@@ -45,30 +58,32 @@ export default class BooleanSchema<
45
58
  parsers: {
46
59
  allowString: this.__allowString,
47
60
  allowNumber: this.__allowNumber,
48
- is: this.__is.value,
61
+ // eslint-disable-next-line ts/no-unnecessary-condition
62
+ is: this.__is?.value,
49
63
  trueValues: this.__trueValues,
50
64
  falseValues: this.__falseValues,
51
65
  nullable: this.__nullable.allow,
52
- optional: this.__optional.allow,
66
+ optional: this.__optional.allow
53
67
  },
68
+ type: this.__type,
54
69
  is: this.__is,
55
70
  nullable: this.__nullable,
56
- optional: this.__optional,
71
+ optional: this.__optional
57
72
  }),
58
73
  {
59
-
60
74
  optional,
61
75
  nullable,
62
- is,
76
+ is
63
77
  },
64
78
  {
65
79
  validatorsIfFallbackOrNotSupported: booleanValidation(),
66
80
  shouldAddStringVersion: options.shouldAddStringVersion,
67
81
  // eslint-disable-next-line ts/require-await
68
- fallbackIfNotSupported: async () => [],
82
+ fallbackIfNotSupported: async () => []
69
83
  }
70
84
  );
71
85
  },
86
+ this,
72
87
  this.__transformedSchemas,
73
88
  options,
74
89
  'boolean'
@@ -76,7 +91,8 @@ export default class BooleanSchema<
76
91
  }
77
92
 
78
93
  /**
79
- * 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.
94
+ * This let's you refine the schema with custom validations. This is useful when you want to validate something that
95
+ * is not supported by default by the schema adapter.
80
96
  *
81
97
  * @example
82
98
  * ```typescript
@@ -88,7 +104,8 @@ export default class BooleanSchema<
88
104
  *
89
105
  * const { errors, parsed } = await numberSchema.parse(-1);
90
106
  *
91
- * console.log(errors); // [{ isValid: false, code: 'invalid_number', message: 'The number should be greater than 0', path: [] }]
107
+ * // [{ isValid: false, code: 'invalid_number', message: 'The number should be greater than 0', path: [] }]
108
+ * console.log(errors);
92
109
  * ```
93
110
  *
94
111
  * @param refinementCallback - The callback that will be called to validate the value.
@@ -98,7 +115,13 @@ export default class BooleanSchema<
98
115
  * @returns The schema.
99
116
  */
100
117
  refine(
101
- refinementCallback: (value: TType['input']) => Promise<void | undefined | { code: string; message: string }> | void | undefined | { code: string; message: string }
118
+ refinementCallback: (
119
+ value: TType['input']
120
+ ) =>
121
+ | Promise<void | undefined | { code: string; message: string }>
122
+ | void
123
+ | undefined
124
+ | { code: string; message: string }
102
125
  ) {
103
126
  return super.refine(refinementCallback) as unknown as BooleanSchema<
104
127
  {
@@ -107,7 +130,8 @@ export default class BooleanSchema<
107
130
  internal: TType['internal'];
108
131
  output: TType['output'];
109
132
  representation: TType['representation'];
110
- }, TDefinitions
133
+ },
134
+ TDefinitions
111
135
  >;
112
136
  }
113
137
 
@@ -149,8 +173,36 @@ export default class BooleanSchema<
149
173
  }
150
174
 
151
175
  /**
152
- * 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
153
- * the { message: 'Your custom message', allow: false } on the options.
176
+ * Just adds a message when the value is undefined. It's just a syntax sugar for
177
+ *
178
+ * ```typescript
179
+ * p.string().optional({ message: 'This value cannot be null', allow: false })
180
+ * ```
181
+ *
182
+ * @param options - The options of nonOptional function
183
+ * @param options.message - A custom message if the value is undefined.
184
+ *
185
+ * @returns - The schema.
186
+ */
187
+ nonOptional(options?: { message: string }) {
188
+ return super.optional({
189
+ message: options?.message,
190
+ allow: false
191
+ }) as unknown as BooleanSchema<
192
+ {
193
+ input: TType['input'];
194
+ validate: TType['validate'];
195
+ internal: TType['internal'];
196
+ output: TType['output'];
197
+ representation: TType['representation'];
198
+ },
199
+ TDefinitions
200
+ >;
201
+ }
202
+
203
+ /**
204
+ * Allows the value to be null and ONLY null. You can also use this function to set a custom message when the value is
205
+ * NULL by setting the { message: 'Your custom message', allow: false } on the options.
154
206
  *
155
207
  * @example
156
208
  * ```typescript
@@ -187,14 +239,43 @@ export default class BooleanSchema<
187
239
  }
188
240
 
189
241
  /**
190
- * This method will remove the value from the representation of the schema. If the value is undefined it will keep that way
191
- * otherwise it will set the value to undefined after it's validated.
242
+ * Just adds a message when the value is null. It's just a syntax sugar for
243
+ *
244
+ * ```typescript
245
+ * p.string().nullable({ message: 'This value cannot be null', allow: false })
246
+ * ```
247
+ *
248
+ * @param options - The options of nonNullable function
249
+ * @param options.message - A custom message if the value is null.
250
+ *
251
+ * @returns - The schema.
252
+ */
253
+ nonNullable(options?: { message: string }) {
254
+ return super.nullable({
255
+ message: options?.message || '',
256
+ allow: false
257
+ }) as unknown as BooleanSchema<
258
+ {
259
+ input: TType['input'];
260
+ validate: TType['validate'];
261
+ internal: TType['internal'];
262
+ output: TType['output'];
263
+ representation: TType['representation'];
264
+ },
265
+ TDefinitions
266
+ >;
267
+ }
268
+
269
+ /**
270
+ * This method will remove the value from the representation of the schema. If the value is undefined it will keep
271
+ * that way otherwise it will set the value to undefined after it's validated.
192
272
  * This is used in conjunction with the {@link data} function, the {@link parse} function or {@link validate}
193
273
  * function. This will remove the value from the representation of the schema.
194
274
  *
195
- * By default, the value will be removed just from the representation, in other words, when you call the {@link data} function.
196
- * But if you want to remove the value from the internal representation, you can pass the argument `toInternal` as true.
197
- * Then if you still want to remove the value from the representation, you will need to pass the argument `toRepresentation` as true as well.
275
+ * By default, the value will be removed just from the representation, in other words, when you call the {@link data}
276
+ * function.But if you want to remove the value from the internal representation, you can pass the argument
277
+ * `toInternal` as true. Then if you still want to remove the value from the representation, you will need to pass
278
+ * the argument `toRepresentation` as true as well.
198
279
  *
199
280
  * @example
200
281
  * ```typescript
@@ -216,16 +297,18 @@ export default class BooleanSchema<
216
297
  * ```
217
298
  *
218
299
  *
219
- * @param args - By default, the value will be removed just from the representation, in other words, when you call the {@link data} function.
220
- * But if you want to remove the value from the internal representation, you can pass the argument `toInternal` as true.
221
- * Then if you still want to remove the value from the representation, you will need to pass the argument `toRepresentation` as true as well.
300
+ * @param args - By default, the value will be removed just from the representation, in other words, when you call
301
+ * the {@link data} function. But if you want to remove the value from the internal representation, you can pass the
302
+ * argument `toInternal` as true.
303
+ * Then if you still want to remove the value from the representation, you will need to pass the argument
304
+ * `toRepresentation` as true as well.
222
305
  *
223
306
  * @returns The schema.
224
307
  */
225
308
  omit<
226
309
  TToInternal extends boolean,
227
310
  TToRepresentation extends boolean = boolean extends TToInternal ? true : false
228
- >(args?: { toInternal?: TToInternal, toRepresentation?: TToRepresentation }) {
311
+ >(args?: { toInternal?: TToInternal; toRepresentation?: TToRepresentation }) {
229
312
  return super.omit(args) as unknown as BooleanSchema<
230
313
  {
231
314
  input: TToInternal extends true ? TType['input'] | undefined : TType['input'];
@@ -239,9 +322,9 @@ export default class BooleanSchema<
239
322
  }
240
323
 
241
324
  /**
242
- * This function is used in conjunction with the {@link validate} function. It's used to save a value to an external source
243
- * like a database. You should always return the schema after you save the value, that way we will always have the correct type
244
- * of the schema after the save operation.
325
+ * This function is used in conjunction with the {@link validate} function. It's used to save a value to an external
326
+ * source like a database. You should always return the schema after you save the value, that way we will always have
327
+ * the correct type of the schema after the save operation.
245
328
  *
246
329
  * You can use the {@link toRepresentation} function to transform and clean the value it returns after the save.
247
330
  *
@@ -295,9 +378,9 @@ export default class BooleanSchema<
295
378
  >;
296
379
  }
297
380
 
298
-
299
381
  /**
300
- * 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.
382
+ * This function is used to add a default value to the schema. If the value is either undefined or null, the default
383
+ * value will be used.
301
384
  *
302
385
  * @example
303
386
  * ```typescript
@@ -326,8 +409,9 @@ export default class BooleanSchema<
326
409
  }
327
410
 
328
411
  /**
329
- * 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
330
- * the custom schema your own way. Our API does not support passthrough? No problem, you can use this function to customize the zod schema.
412
+ * This function let's you customize the schema your own way. After we translate the schema on the adapter we call
413
+ * this function to let you customize the custom schema your own way. Our API does not support passthrough?
414
+ * No problem, you can use this function to customize the zod schema.
331
415
  *
332
416
  * @example
333
417
  * ```typescript
@@ -338,13 +422,13 @@ export default class BooleanSchema<
338
422
  * });
339
423
  *
340
424
  * const { errors, parsed } = await numberSchema.parse(-1);
341
- *
342
- * console.log(errors); // [{ isValid: false, code: 'nonnegative', message: 'The number should be nonnegative', path: [] }]
425
+ * // [{ isValid: false, code: 'nonnegative', message: 'The number should be nonnegative', path: [] }]
426
+ * console.log(errors);
343
427
  * ```
344
428
  *
345
429
  * @param callback - The callback that will be called to customize the schema.
346
- * @param toStringCallback - The callback that will be called to transform the schema to a string when you want to compile the underlying schema
347
- * to a string so you can save it for future runs.
430
+ * @param toStringCallback - The callback that will be called to transform the schema to a string when you want to
431
+ * compile the underlying schema to a string so you can save it for future runs.
348
432
  *
349
433
  * @returns The schema.
350
434
  */
@@ -358,9 +442,9 @@ export default class BooleanSchema<
358
442
  }
359
443
 
360
444
  /**
361
- * 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
362
- * 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.
363
- * The schema maps to itself.
445
+ * This function is used to transform the value to the representation of the schema. When using the {@link data}
446
+ * function. With this function you have full control to add data cleaning for example, transforming the data and
447
+ * whatever. Another use case is when you want to return deeply nested recursive data. The schema maps to itself.
364
448
  *
365
449
  * @example
366
450
  * ```typescript
@@ -416,8 +500,9 @@ export default class BooleanSchema<
416
500
  }
417
501
 
418
502
  /**
419
- * 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
420
- * 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.
503
+ * This function is used to transform the value to the internal representation of the schema. This is useful when
504
+ * you want to transform the value to a type that the schema adapter can understand. For example, you might want
505
+ * to transform a string to a date. This is the function you use.
421
506
  *
422
507
  * @example
423
508
  * ```typescript
@@ -461,8 +546,9 @@ export default class BooleanSchema<
461
546
  }
462
547
 
463
548
  /**
464
- * 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
465
- * here BEFORE the validation. This pretty much transforms the value to a type that the schema adapter can understand.
549
+ * Called before the validation of the schema. Let's say that you want to validate a date that might receive a string,
550
+ * you can convert that string to a date here BEFORE the validation. This pretty much transforms the value to a type
551
+ * that the schema adapter can understand.
466
552
  *
467
553
  * @example
468
554
  * ```
@@ -494,7 +580,8 @@ export default class BooleanSchema<
494
580
  }
495
581
 
496
582
  /**
497
- * This will allow the value to be a string, it does not validate, it just parses inputs as strings and allows the result to be a string as well.
583
+ * This will allow the value to be a string, it does not validate, it just parses inputs as strings and allows the
584
+ * result to be a string as well.
498
585
  *
499
586
  * @example
500
587
  * ```ts
@@ -511,7 +598,7 @@ export default class BooleanSchema<
511
598
  convertFromStringBuilder((value) => {
512
599
  return {
513
600
  value: Boolean(value),
514
- preventNextParsers: false,
601
+ preventNextParsers: false
515
602
  };
516
603
  })
517
604
  );
@@ -529,7 +616,8 @@ export default class BooleanSchema<
529
616
  }
530
617
 
531
618
  /**
532
- * Allows you to set the values that will be considered as true. This is useful when you have a string that can be 'T' or 'F' for example.
619
+ * Allows you to set the values that will be considered as true. This is useful when you have a string that can be
620
+ * 'T' or 'F' for example.
533
621
  *
534
622
  * @example
535
623
  * ```ts
@@ -546,9 +634,11 @@ export default class BooleanSchema<
546
634
 
547
635
  this.__parsers.medium.set('trueValues', (value) => {
548
636
  const valueExistsInList = values.includes(value);
637
+ console.log('trueValues', valueExistsInList);
638
+
549
639
  return {
550
640
  preventNextParsers: valueExistsInList,
551
- value: valueExistsInList,
641
+ value: valueExistsInList ? true : value
552
642
  };
553
643
  });
554
644
  return this as any as BooleanSchema<
@@ -563,8 +653,9 @@ export default class BooleanSchema<
563
653
  >;
564
654
  }
565
655
 
566
- /**
567
- * Allows you to set the values that will be considered as false. This is useful when you have a string that can be 'N' or 0 for example.
656
+ /**
657
+ * Allows you to set the values that will be considered as false. This is useful when you have a string that can
658
+ * be 'N' or 0 for example.
568
659
  *
569
660
  * @example
570
661
  * ```ts
@@ -581,9 +672,10 @@ export default class BooleanSchema<
581
672
 
582
673
  this.__parsers.medium.set('falseValues', (value) => {
583
674
  const valueExistsInList = values.includes(value);
675
+ console.log('falseValues', valueExistsInList);
584
676
  return {
585
677
  preventNextParsers: valueExistsInList,
586
- value: !valueExistsInList,
678
+ value: valueExistsInList ? false : value
587
679
  };
588
680
  });
589
681
 
@@ -600,7 +692,8 @@ export default class BooleanSchema<
600
692
  }
601
693
 
602
694
  /**
603
- * This will allow the value to be a number, it does not validate, it just parses inputs as number and allows the result to be a string as well.
695
+ * This will allow the value to be a number, it does not validate, it just parses inputs as number and allows the
696
+ * result to be a string as well.
604
697
  *
605
698
  * @example
606
699
  * ```ts
@@ -615,7 +708,7 @@ export default class BooleanSchema<
615
708
  this.__parsers.low.set('allowNumber', (value) => {
616
709
  return {
617
710
  value: typeof value === 'number' ? Boolean(value) : value,
618
- preventNextParsers: typeof value === 'number',
711
+ preventNextParsers: typeof value === 'number'
619
712
  };
620
713
  });
621
714
 
@@ -650,14 +743,14 @@ export default class BooleanSchema<
650
743
  is<TValue extends true | false>(value: TValue, options?: { message?: string }) {
651
744
  this.__is = {
652
745
  value,
653
- message: typeof options?.message === 'string' ? options.message : `The value should be equal to ${value}`,
746
+ message: typeof options?.message === 'string' ? options.message : `The value should be equal to ${value}`
654
747
  };
655
748
 
656
749
  this.__parsers.high.set('is', (valueFromParser) => {
657
750
  const isSetValue = value === valueFromParser;
658
751
  return {
659
752
  value: isSetValue ? valueFromParser : undefined,
660
- preventNextParsers: true,
753
+ preventNextParsers: true
661
754
  };
662
755
  });
663
756
 
@@ -685,14 +778,6 @@ export default class BooleanSchema<
685
778
  TDefinitions
686
779
  >();
687
780
 
688
- const adapterInstance = getDefaultAdapter();
689
-
690
- returnValue.__transformedSchemas[adapterInstance.constructor.name] = {
691
- transformed: false,
692
- adapter: adapterInstance,
693
- schemas: [],
694
- };
695
-
696
781
  return returnValue;
697
782
  }
698
783
  }