@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.
- package/.turbo/turbo-build$colon$watch.log +12 -410
- package/CHANGELOG.md +17 -0
- package/__tests__/.drizzle/migrations/0000_skinny_harrier.sql +22 -0
- package/__tests__/.drizzle/migrations/meta/0000_snapshot.json +156 -0
- package/__tests__/.drizzle/migrations/meta/_journal.json +13 -0
- package/__tests__/.drizzle/schema.ts +35 -0
- package/__tests__/drizzle.config.ts +11 -0
- package/__tests__/eslint.config.js +10 -0
- package/__tests__/manage.ts +5 -0
- package/__tests__/node_modules/.bin/drizzle-kit +17 -0
- package/__tests__/node_modules/.bin/esbuild +14 -0
- package/__tests__/node_modules/.bin/tsc +17 -0
- package/__tests__/node_modules/.bin/tsserver +17 -0
- package/__tests__/node_modules/.bin/tsx +17 -0
- package/__tests__/package.json +36 -0
- package/__tests__/sqlite.db +0 -0
- package/__tests__/src/core/array.test.ts +130 -0
- package/__tests__/src/core/boolean.test.ts +66 -0
- package/__tests__/src/core/datetime.test.ts +102 -0
- package/__tests__/src/core/index.ts +35 -0
- package/__tests__/src/core/model.test.ts +260 -0
- package/__tests__/src/core/models.ts +50 -0
- package/__tests__/src/core/numbers.test.ts +177 -0
- package/__tests__/src/core/object.test.ts +198 -0
- package/__tests__/src/core/string.test.ts +222 -0
- package/__tests__/src/core/test.test.ts +59 -0
- package/__tests__/src/core/types.test.ts +97 -0
- package/__tests__/src/core/union.test.ts +99 -0
- package/__tests__/src/settings.ts +71 -0
- package/__tests__/tsconfig.json +11 -0
- package/dist/cjs/src/adapter/fields/index.js +2 -2
- package/dist/cjs/src/adapter/fields/object.js +9 -0
- package/dist/cjs/src/adapter/index.js +1 -0
- package/dist/cjs/src/constants.js +1 -7
- package/dist/cjs/src/domain.js +146 -1
- package/dist/cjs/src/index.js +69 -74
- package/dist/cjs/src/model.js +206 -206
- package/dist/cjs/src/schema/array.js +185 -58
- package/dist/cjs/src/schema/boolean.js +105 -44
- package/dist/cjs/src/schema/datetime.js +104 -38
- package/dist/cjs/src/schema/number.js +134 -114
- package/dist/cjs/src/schema/object.js +106 -43
- package/dist/cjs/src/schema/schema.js +123 -75
- package/dist/cjs/src/schema/string.js +152 -58
- package/dist/cjs/src/schema/union.js +412 -290
- package/dist/cjs/src/utils.js +42 -15
- package/dist/cjs/src/validators/array.js +6 -1
- package/dist/cjs/src/validators/boolean.js +2 -0
- package/dist/cjs/src/validators/datetime.js +4 -0
- package/dist/cjs/src/validators/number.js +12 -40
- package/dist/cjs/src/validators/object.js +1 -0
- package/dist/cjs/src/validators/schema.js +5 -1
- package/dist/cjs/src/validators/string.js +30 -2
- package/dist/cjs/src/validators/union.js +5 -4
- package/dist/cjs/src/validators/utils.js +99 -27
- package/dist/cjs/tsconfig.types.tsbuildinfo +1 -1
- package/dist/cjs/types/adapter/fields/array.d.ts +2 -2
- package/dist/cjs/types/adapter/fields/array.d.ts.map +1 -1
- package/dist/cjs/types/adapter/fields/boolean.d.ts.map +1 -1
- package/dist/cjs/types/adapter/fields/datetime.d.ts.map +1 -1
- package/dist/cjs/types/adapter/fields/index.d.ts +2 -2
- package/dist/cjs/types/adapter/fields/index.d.ts.map +1 -1
- package/dist/cjs/types/adapter/fields/number.d.ts.map +1 -1
- package/dist/cjs/types/adapter/fields/object.d.ts +2 -1
- package/dist/cjs/types/adapter/fields/object.d.ts.map +1 -1
- package/dist/cjs/types/adapter/fields/string.d.ts.map +1 -1
- package/dist/cjs/types/adapter/fields/union.d.ts.map +1 -1
- package/dist/cjs/types/adapter/index.d.ts +1 -0
- package/dist/cjs/types/adapter/index.d.ts.map +1 -1
- package/dist/cjs/types/adapter/types.d.ts +28 -18
- package/dist/cjs/types/adapter/types.d.ts.map +1 -1
- package/dist/cjs/types/constants.d.ts +0 -1
- package/dist/cjs/types/constants.d.ts.map +1 -1
- package/dist/cjs/types/domain.d.ts +5 -4
- package/dist/cjs/types/domain.d.ts.map +1 -1
- package/dist/cjs/types/index.d.ts +78 -55
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/model.d.ts +17 -17
- package/dist/cjs/types/model.d.ts.map +1 -1
- package/dist/cjs/types/schema/array.d.ts +168 -47
- package/dist/cjs/types/schema/array.d.ts.map +1 -1
- package/dist/cjs/types/schema/boolean.d.ts +103 -44
- package/dist/cjs/types/schema/boolean.d.ts.map +1 -1
- package/dist/cjs/types/schema/datetime.d.ts +90 -30
- package/dist/cjs/types/schema/datetime.d.ts.map +1 -1
- package/dist/cjs/types/schema/number.d.ts +133 -125
- package/dist/cjs/types/schema/number.d.ts.map +1 -1
- package/dist/cjs/types/schema/object.d.ts +104 -35
- package/dist/cjs/types/schema/object.d.ts.map +1 -1
- package/dist/cjs/types/schema/schema.d.ts +62 -44
- package/dist/cjs/types/schema/schema.d.ts.map +1 -1
- package/dist/cjs/types/schema/string.d.ts +152 -65
- package/dist/cjs/types/schema/string.d.ts.map +1 -1
- package/dist/cjs/types/schema/types.d.ts +11 -2
- package/dist/cjs/types/schema/types.d.ts.map +1 -1
- package/dist/cjs/types/schema/union.d.ts +133 -40
- package/dist/cjs/types/schema/union.d.ts.map +1 -1
- package/dist/cjs/types/types.d.ts +35 -0
- package/dist/cjs/types/types.d.ts.map +1 -1
- package/dist/cjs/types/utils.d.ts +41 -27
- package/dist/cjs/types/utils.d.ts.map +1 -1
- package/dist/cjs/types/validators/array.d.ts.map +1 -1
- package/dist/cjs/types/validators/boolean.d.ts.map +1 -1
- package/dist/cjs/types/validators/datetime.d.ts.map +1 -1
- package/dist/cjs/types/validators/number.d.ts +5 -6
- package/dist/cjs/types/validators/number.d.ts.map +1 -1
- package/dist/cjs/types/validators/object.d.ts.map +1 -1
- package/dist/cjs/types/validators/schema.d.ts +2 -2
- package/dist/cjs/types/validators/schema.d.ts.map +1 -1
- package/dist/cjs/types/validators/string.d.ts +9 -9
- package/dist/cjs/types/validators/string.d.ts.map +1 -1
- package/dist/cjs/types/validators/utils.d.ts +44 -27
- package/dist/cjs/types/validators/utils.d.ts.map +1 -1
- package/dist/esm/src/adapter/fields/index.js +2 -2
- package/dist/esm/src/adapter/fields/object.js +6 -0
- package/dist/esm/src/adapter/index.js +1 -0
- package/dist/esm/src/constants.js +1 -2
- package/dist/esm/src/domain.js +11 -1
- package/dist/esm/src/index.js +38 -73
- package/dist/esm/src/model.js +83 -78
- package/dist/esm/src/schema/array.js +136 -54
- package/dist/esm/src/schema/boolean.js +98 -44
- package/dist/esm/src/schema/datetime.js +91 -38
- package/dist/esm/src/schema/number.js +127 -110
- package/dist/esm/src/schema/object.js +98 -43
- package/dist/esm/src/schema/schema.js +102 -67
- package/dist/esm/src/schema/string.js +147 -59
- package/dist/esm/src/schema/union.js +119 -40
- package/dist/esm/src/types.js +14 -1
- package/dist/esm/src/utils.js +56 -27
- package/dist/esm/src/validators/array.js +6 -1
- package/dist/esm/src/validators/boolean.js +2 -0
- package/dist/esm/src/validators/datetime.js +4 -0
- package/dist/esm/src/validators/number.js +9 -23
- package/dist/esm/src/validators/object.js +1 -0
- package/dist/esm/src/validators/schema.js +5 -1
- package/dist/esm/src/validators/string.js +30 -2
- package/dist/esm/src/validators/union.js +5 -4
- package/dist/esm/src/validators/utils.js +62 -36
- package/package.json +3 -3
- package/src/adapter/fields/array.ts +2 -2
- package/src/adapter/fields/boolean.ts +3 -8
- package/src/adapter/fields/datetime.ts +3 -9
- package/src/adapter/fields/index.ts +11 -11
- package/src/adapter/fields/number.ts +3 -9
- package/src/adapter/fields/object.ts +13 -10
- package/src/adapter/fields/string.ts +3 -9
- package/src/adapter/fields/union.ts +3 -9
- package/src/adapter/index.ts +1 -0
- package/src/adapter/types.ts +60 -45
- package/src/constants.ts +1 -3
- package/src/domain.ts +15 -1
- package/src/index.ts +189 -211
- package/src/model.ts +119 -115
- package/src/schema/array.ts +274 -90
- package/src/schema/boolean.ts +145 -60
- package/src/schema/datetime.ts +133 -49
- package/src/schema/number.ts +210 -173
- package/src/schema/object.ts +167 -74
- package/src/schema/schema.ts +205 -126
- package/src/schema/string.ts +221 -94
- package/src/schema/types.ts +44 -16
- package/src/schema/union.ts +193 -68
- package/src/types.ts +53 -0
- package/src/utils.ts +115 -57
- package/src/validators/array.ts +46 -27
- package/src/validators/boolean.ts +13 -7
- package/src/validators/datetime.ts +24 -16
- package/src/validators/number.ts +53 -63
- package/src/validators/object.ts +6 -5
- package/src/validators/schema.ts +33 -25
- package/src/validators/string.ts +122 -59
- package/src/validators/union.ts +8 -8
- package/src/validators/utils.ts +67 -42
@@ -1,11 +1,14 @@
|
|
1
1
|
import Schema from './schema';
|
2
|
-
import { getDefaultAdapter } from '../conf';
|
3
2
|
import { defaultTransform, defaultTransformToAdapter, transformSchemaAndCheckIfShouldBeHandledByFallbackOnComplexSchemas } from '../utils';
|
4
3
|
import { objectValidation } from '../validators/object';
|
5
4
|
import Validator from '../validators/utils';
|
6
5
|
export default class ObjectSchema extends Schema {
|
7
6
|
__data;
|
8
7
|
__cachedDataAsEntries;
|
8
|
+
__type = {
|
9
|
+
message: 'Invalid type',
|
10
|
+
check: (value)=>typeof value === 'object' && value !== null
|
11
|
+
};
|
9
12
|
constructor(data){
|
10
13
|
super();
|
11
14
|
this.__data = data;
|
@@ -64,6 +67,7 @@ export default class ObjectSchema extends Schema {
|
|
64
67
|
data: isStringVersion ? asString : transformed,
|
65
68
|
nullable: this.__nullable,
|
66
69
|
optional: this.__optional,
|
70
|
+
type: this.__type,
|
67
71
|
parsers: {
|
68
72
|
nullable: this.__nullable.allow,
|
69
73
|
optional: this.__optional.allow
|
@@ -71,11 +75,13 @@ export default class ObjectSchema extends Schema {
|
|
71
75
|
}), {}, {
|
72
76
|
shouldAddStringVersion: options.shouldAddStringVersion
|
73
77
|
})))).flat();
|
74
|
-
}, this.__transformedSchemas, options, 'object');
|
78
|
+
}, this, this.__transformedSchemas, options, 'object');
|
75
79
|
}
|
76
80
|
/**
|
77
|
-
* Transform the data to the representation without validating it. This is useful when you want to return a data
|
78
|
-
* from
|
81
|
+
* Transform the data to the representation without validating it. This is useful when you want to return a data
|
82
|
+
* from a query directly to the user. The core idea of this is that you can join the data from the database "by hand".
|
83
|
+
* In other words, you can do the joins by yourself directly on code. For more complex cases, this can be really
|
84
|
+
* helpful.
|
79
85
|
*
|
80
86
|
* @param value - The value to be transformed.
|
81
87
|
*
|
@@ -96,7 +102,8 @@ export default class ObjectSchema extends Schema {
|
|
96
102
|
return parsedValue;
|
97
103
|
}
|
98
104
|
/**
|
99
|
-
* This let's you refine the schema with custom validations. This is useful when you want to validate something
|
105
|
+
* This let's you refine the schema with custom validations. This is useful when you want to validate something
|
106
|
+
* that is not supported by default by the schema adapter.
|
100
107
|
*
|
101
108
|
* @example
|
102
109
|
* ```typescript
|
@@ -108,7 +115,8 @@ export default class ObjectSchema extends Schema {
|
|
108
115
|
*
|
109
116
|
* const { errors, parsed } = await numberSchema.parse(-1);
|
110
117
|
*
|
111
|
-
*
|
118
|
+
* // [{ isValid: false, code: 'invalid_number', message: 'The number should be greater than 0', path: [] }]
|
119
|
+
* console.log(errors);
|
112
120
|
* ```
|
113
121
|
*
|
114
122
|
* @param refinementCallback - The callback that will be called to validate the value.
|
@@ -118,9 +126,10 @@ export default class ObjectSchema extends Schema {
|
|
118
126
|
return super.refine(refinementCallback);
|
119
127
|
}
|
120
128
|
/**
|
121
|
-
* Allows the value to be either undefined or null. Different from the `optional` method on other schemas, You can
|
122
|
-
* This will allow you to pass `null` or `undefined` as a value on the
|
123
|
-
* This is useful for
|
129
|
+
* Allows the value to be either undefined or null. Different from the `optional` method on other schemas, You can
|
130
|
+
* pass `outputOnly` as `true` to this method. This will allow you to pass `null` or `undefined` as a value on the
|
131
|
+
* {@link Schema.data} method, but it will not allow the value to be `null` or `undefined`. This is useful for
|
132
|
+
* typing purposes
|
124
133
|
*
|
125
134
|
* @example
|
126
135
|
* ```typescript
|
@@ -148,8 +157,11 @@ export default class ObjectSchema extends Schema {
|
|
148
157
|
* company: companySchema.optional({ outputOnly: true })
|
149
158
|
* });
|
150
159
|
*
|
151
|
-
*
|
152
|
-
* const
|
160
|
+
* // Will not allow the company to be null or undefined on a typing level.
|
161
|
+
* const { errors, parsed } = await userSchema.data({ id: 1, name: 'John Doe' });
|
162
|
+
*
|
163
|
+
* // Will allow the company to be null or undefined on a typing level
|
164
|
+
* const value = await userSchema.data({ id: 1, name: 'John Doe' });
|
153
165
|
* ```
|
154
166
|
*
|
155
167
|
* @returns - The schema we are working with.
|
@@ -157,7 +169,25 @@ export default class ObjectSchema extends Schema {
|
|
157
169
|
return options?.outputOnly ? this : super.optional(options);
|
158
170
|
}
|
159
171
|
/**
|
160
|
-
*
|
172
|
+
* Just adds a message when the value is undefined. It's just a syntax sugar for
|
173
|
+
*
|
174
|
+
* ```typescript
|
175
|
+
* p.datetime().optional({ message: 'This value should be defined', allow: false })
|
176
|
+
* ```
|
177
|
+
*
|
178
|
+
* @param options - The options of nonOptional function
|
179
|
+
* @param options.message - A custom message if the value is undefined.
|
180
|
+
*
|
181
|
+
* @returns - The schema.
|
182
|
+
*/ nonOptional(options) {
|
183
|
+
return super.optional({
|
184
|
+
message: options?.message,
|
185
|
+
allow: false
|
186
|
+
});
|
187
|
+
}
|
188
|
+
/**
|
189
|
+
* Allows the value to be null and ONLY null. You can also use this function to set a custom message when the value
|
190
|
+
* is NULL by setting
|
161
191
|
* the { message: 'Your custom message', allow: false } on the options.
|
162
192
|
*
|
163
193
|
* @example
|
@@ -184,14 +214,34 @@ export default class ObjectSchema extends Schema {
|
|
184
214
|
return super.nullable(options);
|
185
215
|
}
|
186
216
|
/**
|
187
|
-
*
|
188
|
-
*
|
217
|
+
* Just adds a message when the value is null. It's just a syntax sugar for
|
218
|
+
*
|
219
|
+
* ```typescript
|
220
|
+
* p.datetime().nullable({ message: 'This value cannot be null', allow: false })
|
221
|
+
* ```
|
222
|
+
*
|
223
|
+
* @param options - The options of nonNullable function
|
224
|
+
* @param options.message - A custom message if the value is null.
|
225
|
+
*
|
226
|
+
* @returns - The schema.
|
227
|
+
*/ nonNullable(options) {
|
228
|
+
return super.nullable({
|
229
|
+
message: options?.message || '',
|
230
|
+
allow: false
|
231
|
+
});
|
232
|
+
}
|
233
|
+
/**
|
234
|
+
* This method will remove the value from the representation of the schema. If the value is undefined it will keep
|
235
|
+
* that way otherwise it will set the value to undefined after it's validated.
|
189
236
|
* This is used in conjunction with the {@link data} function, the {@link parse} function or {@link validate}
|
190
237
|
* function. This will remove the value from the representation of the schema.
|
191
238
|
*
|
192
|
-
* By default, the value will be removed just from the representation, in other words, when you call the {@link data}
|
193
|
-
*
|
194
|
-
*
|
239
|
+
* By default, the value will be removed just from the representation, in other words, when you call the {@link data}
|
240
|
+
* function.
|
241
|
+
* But if you want to remove the value from the internal representation, you can pass the argument `toInternal`
|
242
|
+
* as true.
|
243
|
+
* Then if you still want to remove the value from the representation, you will need to pass the argument
|
244
|
+
* `toRepresentation` as true as well.
|
195
245
|
*
|
196
246
|
* @example
|
197
247
|
* ```typescript
|
@@ -213,18 +263,21 @@ export default class ObjectSchema extends Schema {
|
|
213
263
|
* ```
|
214
264
|
*
|
215
265
|
*
|
216
|
-
* @param args - By default, the value will be removed just from the representation, in other words, when you call
|
217
|
-
*
|
218
|
-
*
|
266
|
+
* @param args - By default, the value will be removed just from the representation, in other words, when you call
|
267
|
+
* the {@link data} function.
|
268
|
+
* But if you want to remove the value from the internal representation, you can pass the argument `toInternal`
|
269
|
+
* as true.
|
270
|
+
* Then if you still want to remove the value from the representation, you will need to pass the argument
|
271
|
+
* `toRepresentation` as true as well.
|
219
272
|
*
|
220
273
|
* @returns The schema.
|
221
274
|
*/ omit(args) {
|
222
275
|
return super.omit(args);
|
223
276
|
}
|
224
277
|
/**
|
225
|
-
* This function is used in conjunction with the {@link validate} function. It's used to save a value to an external
|
226
|
-
* like a database. You should always return the schema after you save the value, that way we will always have
|
227
|
-
* of the schema after the save operation.
|
278
|
+
* This function is used in conjunction with the {@link validate} function. It's used to save a value to an external
|
279
|
+
* source like a database. You should always return the schema after you save the value, that way we will always have
|
280
|
+
* the correct type of the schema after the save operation.
|
228
281
|
*
|
229
282
|
* You can use the {@link toRepresentation} function to transform and clean the value it returns after the save.
|
230
283
|
*
|
@@ -266,7 +319,8 @@ export default class ObjectSchema extends Schema {
|
|
266
319
|
return super.onSave(callback);
|
267
320
|
}
|
268
321
|
/**
|
269
|
-
* This function is used to add a default value to the schema. If the value is either undefined or null, the default
|
322
|
+
* This function is used to add a default value to the schema. If the value is either undefined or null, the default
|
323
|
+
* value will be used.
|
270
324
|
*
|
271
325
|
* @example
|
272
326
|
* ```typescript
|
@@ -282,8 +336,9 @@ export default class ObjectSchema extends Schema {
|
|
282
336
|
return super.default(defaultValueOrFunction);
|
283
337
|
}
|
284
338
|
/**
|
285
|
-
* This function let's you customize the schema your own way. After we translate the schema on the adapter we call
|
286
|
-
* the custom schema your own way. Our API does not support passthrough?
|
339
|
+
* This function let's you customize the schema your own way. After we translate the schema on the adapter we call
|
340
|
+
* this function to let you customize the custom schema your own way. Our API does not support passthrough?
|
341
|
+
* No problem, you can use this function to customize the zod schema.
|
287
342
|
*
|
288
343
|
* @example
|
289
344
|
* ```typescript
|
@@ -295,20 +350,22 @@ export default class ObjectSchema extends Schema {
|
|
295
350
|
*
|
296
351
|
* const { errors, parsed } = await numberSchema.parse(-1);
|
297
352
|
*
|
298
|
-
*
|
353
|
+
* // [{ isValid: false, code: 'nonnegative', message: 'The number should be nonnegative', path: [] }]
|
354
|
+
* console.log(errors);
|
299
355
|
* ```
|
300
356
|
*
|
301
357
|
* @param callback - The callback that will be called to customize the schema.
|
302
|
-
* @param toStringCallback - The callback that will be called to transform the schema to a string when you want to
|
303
|
-
* to a string so you can save it for future runs.
|
358
|
+
* @param toStringCallback - The callback that will be called to transform the schema to a string when you want to
|
359
|
+
* compile the underlying schema to a string so you can save it for future runs.
|
304
360
|
*
|
305
361
|
* @returns The schema.
|
306
362
|
*/ extends(callback, toStringCallback) {
|
307
363
|
return super.extends(callback, toStringCallback);
|
308
364
|
}
|
309
365
|
/**
|
310
|
-
* This function is used to transform the value to the representation of the schema. When using the {@link data}
|
311
|
-
* control to add data cleaning for example, transforming the data and
|
366
|
+
* This function is used to transform the value to the representation of the schema. When using the {@link data}
|
367
|
+
* function. With this function you have full control to add data cleaning for example, transforming the data and
|
368
|
+
* whatever. Another use case is when you want to return deeply nested recursive data.
|
312
369
|
* The schema maps to itself.
|
313
370
|
*
|
314
371
|
* @example
|
@@ -347,16 +404,19 @@ export default class ObjectSchema extends Schema {
|
|
347
404
|
* ```
|
348
405
|
* @param toRepresentationCallback - The callback that will be called to transform the value to the representation.
|
349
406
|
* @param options - Options for the toRepresentation function.
|
350
|
-
* @param options.after - Whether the toRepresentationCallback should be called after the existing
|
351
|
-
*
|
407
|
+
* @param options.after - Whether the toRepresentationCallback should be called after the existing
|
408
|
+
* toRepresentationCallback. Defaults to true.
|
409
|
+
* @param options.before - Whether the toRepresentationCallback should be called before the existing
|
410
|
+
* toRepresentationCallback. Defaults to true.
|
352
411
|
*
|
353
412
|
* @returns The schema with a new return type
|
354
413
|
*/ toRepresentation(toRepresentationCallback, options) {
|
355
414
|
return super.toRepresentation(toRepresentationCallback, options);
|
356
415
|
}
|
357
416
|
/**
|
358
|
-
* This function is used to transform the value to the internal representation of the schema. This is useful when
|
359
|
-
* to a type that the schema adapter can understand. For example, you might want
|
417
|
+
* This function is used to transform the value to the internal representation of the schema. This is useful when
|
418
|
+
* you want to transform the value to a type that the schema adapter can understand. For example, you might want
|
419
|
+
* to transform a string to a date. This is the function you use.
|
360
420
|
*
|
361
421
|
* @example
|
362
422
|
* ```typescript
|
@@ -389,8 +449,9 @@ export default class ObjectSchema extends Schema {
|
|
389
449
|
return super.toInternal(toInternalCallback);
|
390
450
|
}
|
391
451
|
/**
|
392
|
-
* Called before the validation of the schema. Let's say that you want to validate a date that might receive a string,
|
393
|
-
* here BEFORE the validation. This pretty much transforms the value to a type
|
452
|
+
* Called before the validation of the schema. Let's say that you want to validate a date that might receive a string,
|
453
|
+
* you can convert that string to a date here BEFORE the validation. This pretty much transforms the value to a type
|
454
|
+
* that the schema adapter can understand.
|
394
455
|
*
|
395
456
|
* @example
|
396
457
|
* ```
|
@@ -452,12 +513,6 @@ export default class ObjectSchema extends Schema {
|
|
452
513
|
}
|
453
514
|
static new(data) {
|
454
515
|
const returnValue = new ObjectSchema(data);
|
455
|
-
const adapterInstance = getDefaultAdapter();
|
456
|
-
returnValue.__transformedSchemas[adapterInstance.constructor.name] = {
|
457
|
-
transformed: false,
|
458
|
-
adapter: adapterInstance,
|
459
|
-
schemas: []
|
460
|
-
};
|
461
516
|
return returnValue;
|
462
517
|
}
|
463
518
|
}
|