@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,29 +1,34 @@
|
|
1
1
|
import Schema from './schema';
|
2
|
-
import type { DefinitionsOfSchemaType } from './types';
|
2
|
+
import type { DefinitionsOfSchemaType, ExtractTypeFromUnionOfSchemas } from './types';
|
3
3
|
import type FieldAdapter from '../adapter/fields';
|
4
4
|
import type { Narrow } from '@palmares/core';
|
5
5
|
export default class UnionSchema<TType extends {
|
6
|
-
input:
|
7
|
-
validate:
|
8
|
-
internal:
|
9
|
-
representation:
|
10
|
-
output:
|
6
|
+
input: unknown;
|
7
|
+
validate: unknown;
|
8
|
+
internal: unknown;
|
9
|
+
representation: unknown;
|
10
|
+
output: unknown;
|
11
11
|
} = {
|
12
|
-
input:
|
13
|
-
output:
|
14
|
-
validate:
|
15
|
-
internal:
|
16
|
-
representation:
|
12
|
+
input: unknown;
|
13
|
+
output: unknown;
|
14
|
+
validate: unknown;
|
15
|
+
internal: unknown;
|
16
|
+
representation: unknown;
|
17
17
|
}, TDefinitions extends DefinitionsOfSchemaType = DefinitionsOfSchemaType, TSchemas extends readonly [Schema<any, any>, Schema<any, any>, ...Schema<any, any>[]] = [
|
18
18
|
Schema<any, any>,
|
19
19
|
Schema<any, any>,
|
20
20
|
...Schema<any, any>[]
|
21
21
|
]> extends Schema<TType, TDefinitions> {
|
22
|
+
protected __type: {
|
23
|
+
message: string;
|
24
|
+
check: (value: TType['input']) => boolean;
|
25
|
+
};
|
22
26
|
protected __schemas: Set<Schema<any, DefinitionsOfSchemaType>>;
|
23
27
|
constructor(schemas: TSchemas);
|
24
|
-
protected
|
28
|
+
protected __transformToAdapter(options: Parameters<Schema['__transformToAdapter']>[0]): Promise<ReturnType<FieldAdapter['translate']>>;
|
25
29
|
/**
|
26
|
-
* This let's you refine the schema with custom validations. This is useful when you want to validate something that
|
30
|
+
* This let's you refine the schema with custom validations. This is useful when you want to validate something that
|
31
|
+
* is not supported by default by the schema adapter.
|
27
32
|
*
|
28
33
|
* @example
|
29
34
|
* ```typescript
|
@@ -35,7 +40,8 @@ export default class UnionSchema<TType extends {
|
|
35
40
|
*
|
36
41
|
* const { errors, parsed } = await numberSchema.parse(-1);
|
37
42
|
*
|
38
|
-
*
|
43
|
+
* // [{ isValid: false, code: 'invalid_number', message: 'The number should be greater than 0', path: [] }]
|
44
|
+
* console.log(errors);
|
39
45
|
* ```
|
40
46
|
*
|
41
47
|
* @param refinementCallback - The callback that will be called to validate the value.
|
@@ -90,8 +96,29 @@ export default class UnionSchema<TType extends {
|
|
90
96
|
representation: TType["representation"] | undefined | null;
|
91
97
|
}, TDefinitions, TSchemas>;
|
92
98
|
/**
|
93
|
-
*
|
94
|
-
*
|
99
|
+
* Just adds a message when the value is undefined. It's just a syntax sugar for
|
100
|
+
*
|
101
|
+
* ```typescript
|
102
|
+
* p.string().optional({ message: 'This value cannot be null', allow: false })
|
103
|
+
* ```
|
104
|
+
*
|
105
|
+
* @param options - The options of nonOptional function
|
106
|
+
* @param options.message - A custom message if the value is undefined.
|
107
|
+
*
|
108
|
+
* @returns - The schema.
|
109
|
+
*/
|
110
|
+
nonOptional(options?: {
|
111
|
+
message: string;
|
112
|
+
}): UnionSchema<{
|
113
|
+
input: TType["input"];
|
114
|
+
validate: TType["validate"];
|
115
|
+
internal: TType["internal"];
|
116
|
+
output: TType["output"];
|
117
|
+
representation: TType["representation"];
|
118
|
+
}, TDefinitions>;
|
119
|
+
/**
|
120
|
+
* Allows the value to be null and ONLY null. You can also use this function to set a custom message when the value
|
121
|
+
* is NULL by setting the { message: 'Your custom message', allow: false } on the options.
|
95
122
|
*
|
96
123
|
* @example
|
97
124
|
* ```typescript
|
@@ -125,14 +152,37 @@ export default class UnionSchema<TType extends {
|
|
125
152
|
representation: TType["representation"] | null;
|
126
153
|
}, TDefinitions, TSchemas>;
|
127
154
|
/**
|
128
|
-
*
|
155
|
+
* Just adds a message when the value is null. It's just a syntax sugar for
|
156
|
+
*
|
157
|
+
* ```typescript
|
158
|
+
* p.string().nullable({ message: 'This value cannot be null', allow: false })
|
159
|
+
* ```
|
160
|
+
*
|
161
|
+
* @param options - The options of nonNullable function
|
162
|
+
* @param options.message - A custom message if the value is null.
|
163
|
+
*
|
164
|
+
* @returns - The schema.
|
165
|
+
*/
|
166
|
+
nonNullable(options?: {
|
167
|
+
message: string;
|
168
|
+
}): UnionSchema<{
|
169
|
+
input: TType["input"];
|
170
|
+
validate: TType["validate"];
|
171
|
+
internal: TType["internal"];
|
172
|
+
output: TType["output"];
|
173
|
+
representation: TType["representation"];
|
174
|
+
}, TDefinitions>;
|
175
|
+
/**
|
176
|
+
* This method will remove the value from the representation of the schema. If the value is undefined it will keep
|
177
|
+
* that way
|
129
178
|
* otherwise it will set the value to undefined after it's validated.
|
130
179
|
* This is used in conjunction with the {@link data} function, the {@link parse} function or {@link validate}
|
131
180
|
* function. This will remove the value from the representation of the schema.
|
132
181
|
*
|
133
|
-
* By default, the value will be removed just from the representation, in other words, when you call the {@link data}
|
134
|
-
* But if you want to remove the value from the internal representation, you can pass the argument
|
135
|
-
* Then if you still want to remove the value from the representation, you will need to pass
|
182
|
+
* By default, the value will be removed just from the representation, in other words, when you call the {@link data}
|
183
|
+
* function. But if you want to remove the value from the internal representation, you can pass the argument
|
184
|
+
* `toInternal` as true. Then if you still want to remove the value from the representation, you will need to pass
|
185
|
+
* the argument `toRepresentation` as true as well.
|
136
186
|
*
|
137
187
|
* @example
|
138
188
|
* ```typescript
|
@@ -154,9 +204,10 @@ export default class UnionSchema<TType extends {
|
|
154
204
|
* ```
|
155
205
|
*
|
156
206
|
*
|
157
|
-
* @param args - By default, the value will be removed just from the representation, in other words, when you call
|
158
|
-
* But if you want to remove the value from the internal representation, you can pass
|
159
|
-
* Then if you still want to remove the value from the representation, you
|
207
|
+
* @param args - By default, the value will be removed just from the representation, in other words, when you call
|
208
|
+
* the {@link data} function. But if you want to remove the value from the internal representation, you can pass
|
209
|
+
* the argument `toInternal` as true. Then if you still want to remove the value from the representation, you
|
210
|
+
* will need to pass the argument `toRepresentation` as true as well.
|
160
211
|
*
|
161
212
|
* @returns The schema.
|
162
213
|
*/
|
@@ -171,9 +222,9 @@ export default class UnionSchema<TType extends {
|
|
171
222
|
representation: TToRepresentation extends true ? undefined : TType["representation"];
|
172
223
|
}, TDefinitions, TSchemas>;
|
173
224
|
/**
|
174
|
-
* This function is used in conjunction with the {@link validate} function. It's used to save a value to an external
|
175
|
-
* like a database. You should always return the schema after you save the value, that way we will always
|
176
|
-
* of the schema after the save operation.
|
225
|
+
* This function is used in conjunction with the {@link validate} function. It's used to save a value to an external
|
226
|
+
* source like a database. You should always return the schema after you save the value, that way we will always
|
227
|
+
* have the correct type of the schema after the save operation.
|
177
228
|
*
|
178
229
|
* You can use the {@link toRepresentation} function to transform and clean the value it returns after the save.
|
179
230
|
*
|
@@ -222,7 +273,8 @@ export default class UnionSchema<TType extends {
|
|
222
273
|
hasSave: true;
|
223
274
|
}, TSchemas>;
|
224
275
|
/**
|
225
|
-
* This function is used to add a default value to the schema. If the value is either undefined or null, the default
|
276
|
+
* This function is used to add a default value to the schema. If the value is either undefined or null, the default
|
277
|
+
* value will be used.
|
226
278
|
*
|
227
279
|
* @example
|
228
280
|
* ```typescript
|
@@ -243,8 +295,40 @@ export default class UnionSchema<TType extends {
|
|
243
295
|
representation: TType["representation"];
|
244
296
|
}, TDefinitions, TSchemas>;
|
245
297
|
/**
|
246
|
-
* This function
|
247
|
-
*
|
298
|
+
* This function is used to transform the value to the representation without validating it.
|
299
|
+
* This is useful when you want to return a data from a query directly to the user. But for example
|
300
|
+
* you are returning the data of a user, you can clean the password or any other sensitive data.
|
301
|
+
*
|
302
|
+
* @example
|
303
|
+
* ```typescript
|
304
|
+
* import * as p from '@palmares/schemas';
|
305
|
+
*
|
306
|
+
* const userSchema = p.object({
|
307
|
+
* id: p.number().optional(),
|
308
|
+
* name: p.string(),
|
309
|
+
* email: p.string().email(),
|
310
|
+
* password: p.string().optional()
|
311
|
+
* }).toRepresentation(async (value) => {
|
312
|
+
* return {
|
313
|
+
* id: value.id,
|
314
|
+
* name: value.name,
|
315
|
+
* email: value.email
|
316
|
+
* }
|
317
|
+
* });
|
318
|
+
*
|
319
|
+
* const user = await userSchema.data({
|
320
|
+
* id: 1,
|
321
|
+
* name: 'John Doe',
|
322
|
+
* email: 'john@gmail.com',
|
323
|
+
* password: '123456'
|
324
|
+
* });
|
325
|
+
* ```
|
326
|
+
*/
|
327
|
+
data(value: TType['output']): Promise<TType['representation']>;
|
328
|
+
/**
|
329
|
+
* This function let's you customize the schema your own way. After we translate the schema on the adapter we call
|
330
|
+
* this function to let you customize the custom schema your own way. Our API does not support passthrough?
|
331
|
+
* No problem, you can use this function to customize the zod schema.
|
248
332
|
*
|
249
333
|
* @example
|
250
334
|
* ```typescript
|
@@ -256,20 +340,21 @@ export default class UnionSchema<TType extends {
|
|
256
340
|
*
|
257
341
|
* const { errors, parsed } = await numberSchema.parse(-1);
|
258
342
|
*
|
259
|
-
*
|
343
|
+
* // [{ isValid: false, code: 'nonnegative', message: 'The number should be nonnegative', path: [] }]
|
344
|
+
* console.log(errors);
|
260
345
|
* ```
|
261
346
|
*
|
262
347
|
* @param callback - The callback that will be called to customize the schema.
|
263
|
-
* @param toStringCallback - The callback that will be called to transform the schema to a string when you want
|
264
|
-
* to a string so you can save it for future runs.
|
348
|
+
* @param toStringCallback - The callback that will be called to transform the schema to a string when you want
|
349
|
+
* to compile the underlying schema to a string so you can save it for future runs.
|
265
350
|
*
|
266
351
|
* @returns The schema.
|
267
352
|
*/
|
268
353
|
extends(callback: (schema: Awaited<ReturnType<NonNullable<TDefinitions['schemaAdapter']['union']>['translate']>>) => Awaited<ReturnType<NonNullable<TDefinitions['schemaAdapter']['field']>['translate']>> | any, toStringCallback?: (schemaAsString: string) => string): this;
|
269
354
|
/**
|
270
|
-
* This function is used to transform the value to the representation of the schema. When using the {@link data}
|
271
|
-
* control to add data cleaning for example, transforming the data and
|
272
|
-
* The schema maps to itself.
|
355
|
+
* This function is used to transform the value to the representation of the schema. When using the {@link data}
|
356
|
+
* function. With this function you have full control to add data cleaning for example, transforming the data and
|
357
|
+
* whatever. Another use case is when you want to return deeply nested recursive data. The schema maps to itself.
|
273
358
|
*
|
274
359
|
* @example
|
275
360
|
* ```typescript
|
@@ -317,8 +402,9 @@ export default class UnionSchema<TType extends {
|
|
317
402
|
representation: TRepresentation;
|
318
403
|
}, TDefinitions, TSchemas>;
|
319
404
|
/**
|
320
|
-
* This function is used to transform the value to the internal representation of the schema. This is useful when you
|
321
|
-
* to a type that the schema adapter can understand. For example, you might want to
|
405
|
+
* This function is used to transform the value to the internal representation of the schema. This is useful when you
|
406
|
+
* want to transform the value to a type that the schema adapter can understand. For example, you might want to
|
407
|
+
* transform a string to a date. This is the function you use.
|
322
408
|
*
|
323
409
|
* @example
|
324
410
|
* ```typescript
|
@@ -356,8 +442,9 @@ export default class UnionSchema<TType extends {
|
|
356
442
|
representation: TType["representation"];
|
357
443
|
}, TDefinitions, TSchemas>;
|
358
444
|
/**
|
359
|
-
* Called before the validation of the schema. Let's say that you want to validate a date that might receive a string,
|
360
|
-
* here BEFORE the validation. This pretty much transforms the value to a type
|
445
|
+
* Called before the validation of the schema. Let's say that you want to validate a date that might receive a string,
|
446
|
+
* you can convert that string to a date here BEFORE the validation. This pretty much transforms the value to a type
|
447
|
+
* that the schema adapter can understand.
|
361
448
|
*
|
362
449
|
* @example
|
363
450
|
* ```
|
@@ -382,7 +469,13 @@ export default class UnionSchema<TType extends {
|
|
382
469
|
output: TType["output"];
|
383
470
|
representation: TType["representation"];
|
384
471
|
}, TDefinitions, TSchemas>;
|
385
|
-
static new<TSchemas extends readonly [Schema<any, any>, Schema<any, any>, ...Schema<any, any>[]], TDefinitions extends DefinitionsOfSchemaType = DefinitionsOfSchemaType>(schemas: Narrow<TSchemas>): UnionSchema<
|
472
|
+
static new<TSchemas extends readonly [Schema<any, any>, Schema<any, any>, ...Schema<any, any>[]], TDefinitions extends DefinitionsOfSchemaType = DefinitionsOfSchemaType>(schemas: Narrow<TSchemas>): UnionSchema<{
|
473
|
+
input: ExtractTypeFromUnionOfSchemas<TSchemas, 'input'>;
|
474
|
+
internal: ExtractTypeFromUnionOfSchemas<TSchemas, 'internal'>;
|
475
|
+
output: ExtractTypeFromUnionOfSchemas<TSchemas, 'output'>;
|
476
|
+
representation: ExtractTypeFromUnionOfSchemas<TSchemas, 'representation'>;
|
477
|
+
validate: ExtractTypeFromUnionOfSchemas<TSchemas, 'validate'>;
|
478
|
+
}>;
|
386
479
|
}
|
387
480
|
export declare const union: typeof UnionSchema.new;
|
388
481
|
//# sourceMappingURL=union.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"union.d.ts","sourceRoot":"","sources":["../../../../src/schema/union.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,UAAU,CAAC;
|
1
|
+
{"version":3,"file":"union.d.ts","sourceRoot":"","sources":["../../../../src/schema/union.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,UAAU,CAAC;AAW9B,OAAO,KAAK,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAEtF,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,WAAW,CAC9B,KAAK,SAAS;IACZ,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB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CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,EACrF,YAAY,SAAS,uBAAuB,GAAG,uBAAuB,EAEtE,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,GACxB,WAAW,CAAC;QACb,KAAK,EAAE,6BAA6B,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACxD,QAAQ,EAAE,6BAA6B,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC9D,MAAM,EAAE,6BAA6B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC1D,cAAc,EAAE,6BAA6B,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAC1E,QAAQ,EAAE,6BAA6B,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;KAC/D,CAAC;CASH;AACD,eAAO,MAAM,KAAK,wBAAkB,CAAC"}
|
@@ -1,6 +1,10 @@
|
|
1
|
+
import type SchemaAdapter from './adapter';
|
1
2
|
import type Schema from './schema/schema';
|
2
3
|
import type { ValidatorTypes } from './validators/types';
|
3
4
|
export type MaybePromise<T> = T | Promise<T>;
|
5
|
+
export type SchemasSettingsType = {
|
6
|
+
schemaAdapter: typeof SchemaAdapter;
|
7
|
+
};
|
4
8
|
export type FallbackFunctionsType<TArguments> = {
|
5
9
|
[TKey in keyof TArguments]?: (args: NonNullable<TArguments[TKey]>) => {
|
6
10
|
type: ValidatorTypes;
|
@@ -8,4 +12,35 @@ export type FallbackFunctionsType<TArguments> = {
|
|
8
12
|
};
|
9
13
|
};
|
10
14
|
export type SupportedSchemas = 'number' | 'object' | 'union' | 'string' | 'array' | 'boolean' | 'datetime';
|
15
|
+
/**
|
16
|
+
* Retrieve the typescript type of a schema.
|
17
|
+
*
|
18
|
+
* First generic is `typeof myCustomSchema`.
|
19
|
+
*
|
20
|
+
* Second generic is:
|
21
|
+
* - 'input' - The data passed to `.parse` and `.validate` functions. Defaults to this.
|
22
|
+
* - 'output' - (use `'representation'` to get the data format you are
|
23
|
+
* passing to the user) The data passed to `.data` function to return to the
|
24
|
+
* user.
|
25
|
+
* - 'representation' - The data after `toRepresentation`, usually, use this over 'output'
|
26
|
+
* - 'internal' - The data after it's transformed for the `toSave` callback.
|
27
|
+
* - 'validate' - The data for `toValidate` callback.
|
28
|
+
*/
|
29
|
+
export type Infer<TSchema extends Schema<any, any>,
|
30
|
+
/**
|
31
|
+
* - 'input' - The data passed to `.parse` and `.validate` functions.
|
32
|
+
* - 'output' - (use `'representation'` to get the data format you are
|
33
|
+
* passing to the user) The data passed to `.data` function to return to the
|
34
|
+
* user.
|
35
|
+
* - 'representation' - The data after `toRepresentation`, usually, use this over 'output'
|
36
|
+
* - 'internal' - The data after it's transformed for the `toSave` callback.
|
37
|
+
* - 'validate' - The data for `toValidate` callback.
|
38
|
+
*/
|
39
|
+
TType extends 'input' | 'output' | 'representation' | 'internal' | 'validate' = 'input'> = TSchema extends Schema<{
|
40
|
+
input: infer TInput;
|
41
|
+
internal: infer TInternal;
|
42
|
+
output: infer TOutput;
|
43
|
+
representation: infer TRepresentation;
|
44
|
+
validate: infer TValidate;
|
45
|
+
}, any> ? TType extends 'output' ? TOutput : TType extends 'representation' ? TRepresentation : TType extends 'internal' ? TInternal : TType extends 'validate' ? TValidate : TInput : never;
|
11
46
|
//# sourceMappingURL=types.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7C,MAAM,MAAM,qBAAqB,CAAC,UAAU,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;;;;GAaG;AACH,MAAM,MAAM,KAAK,CACf,OAAO,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC;AAChC;;;;;;;;GAQG;AACH,KAAK,SAAS,OAAO,GAAG,QAAQ,GAAG,gBAAgB,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,IAEvF,OAAO,SAAS,MAAM,CACpB;IACE,KAAK,EAAE,MAAM,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,SAAS,CAAC;IAC1B,MAAM,EAAE,MAAM,OAAO,CAAC;IACtB,cAAc,EAAE,MAAM,eAAe,CAAC;IACtC,QAAQ,EAAE,MAAM,SAAS,CAAC;CAC3B,EACD,GAAG,CACJ,GACG,KAAK,SAAS,QAAQ,GACpB,OAAO,GACP,KAAK,SAAS,gBAAgB,GAC5B,eAAe,GACf,KAAK,SAAS,UAAU,GACtB,SAAS,GACT,KAAK,SAAS,UAAU,GACtB,SAAS,GACT,MAAM,GACd,KAAK,CAAC"}
|
@@ -1,12 +1,13 @@
|
|
1
|
-
import
|
1
|
+
import SchemaAdapter from './adapter';
|
2
2
|
import type FieldAdapter from './adapter/fields';
|
3
3
|
import type { ValidationDataBasedOnType } from './adapter/types';
|
4
4
|
import type Schema from './schema/schema';
|
5
5
|
import type { ValidationFallbackCallbackReturnType, ValidationFallbackReturnType } from './schema/types';
|
6
6
|
import type { FallbackFunctionsType, SupportedSchemas } from './types';
|
7
7
|
/**
|
8
|
-
* The usage of this is that imagine that the library doesn't support a specific feature that we support on
|
9
|
-
* of this class and with this instance we are able to
|
8
|
+
* The usage of this is that imagine that the library doesn't support a specific feature that we support on
|
9
|
+
* our schema definition, it can return an instance of this class and with this instance we are able to
|
10
|
+
* fallback to our default implementation of the schema validation.
|
10
11
|
*/
|
11
12
|
export default class WithFallback<TType extends SupportedSchemas> {
|
12
13
|
fallbackFor: Set<keyof Omit<ValidationDataBasedOnType<TType>, 'withFallback' | 'parsers'> | keyof ValidationDataBasedOnType<TType>['parsers']>;
|
@@ -15,8 +16,9 @@ export default class WithFallback<TType extends SupportedSchemas> {
|
|
15
16
|
constructor(adapterType: TType, fallbackFor: (keyof Omit<ValidationDataBasedOnType<TType>, 'withFallback' | 'parsers'> | keyof ValidationDataBasedOnType<TType>['parsers'])[], transformedSchema: any);
|
16
17
|
}
|
17
18
|
/**
|
18
|
-
* Factory function for creating a new instance of WithFallback. We call that function when parsing the
|
19
|
-
* to create a new
|
19
|
+
* Factory function for creating a new instance of WithFallback. We call that function when parsing the
|
20
|
+
* schema adapter, and then, inside of the adapter the user will can the inner function to create a new
|
21
|
+
* instance of WithFallback.
|
20
22
|
*
|
21
23
|
* @param adapterType - The type of the adapter that we are using.
|
22
24
|
*
|
@@ -25,55 +27,67 @@ export default class WithFallback<TType extends SupportedSchemas> {
|
|
25
27
|
export declare function withFallbackFactory<TType extends SupportedSchemas>(adapterType: TType): (fallbackFor: (keyof Omit<ValidationDataBasedOnType<TType>, "withFallback" | "parsers"> | keyof ValidationDataBasedOnType<TType>["parsers"])[], transformedSchema: WithFallback<SupportedSchemas>["transformedSchema"]) => WithFallback<TType>;
|
26
28
|
export declare function parseErrorsFactory(schemaAdapter: SchemaAdapter): (errorOrErrors: any | any[], metadata?: any) => Promise<Awaited<ReturnType<SchemaAdapter["formatError"]>>[]>;
|
27
29
|
/**
|
28
|
-
* The default transform function that we use for the schema adapters. This function tries to abstract away
|
30
|
+
* The default transform function that we use for the schema adapters. This function tries to abstract away
|
31
|
+
* the complexity of translating the schema to the adapter.
|
29
32
|
*
|
30
|
-
* So first things first, WHAT IS a fallback? A fallback is a function that we call when the user defines a
|
31
|
-
*
|
32
|
-
*
|
33
|
+
* So first things first, WHAT IS a fallback? A fallback is a function that we call when the user defines a
|
34
|
+
* validation that is not supported by the adapter. For example, imagine that for some reason the adapter
|
35
|
+
* doesn't support the `max` validation, we can define a fallback for that validation and then, when the
|
36
|
+
* user defines that validation, we call the fallback function. So, even if the adapter doesn't support that
|
37
|
+
* validation our schema will still be able to validate that.
|
33
38
|
*
|
34
|
-
* @param type - The type of the adapter that we are using, can be a number, an object, all of the possible
|
39
|
+
* @param type - The type of the adapter that we are using, can be a number, an object, all of the possible
|
40
|
+
* schema adapters.
|
35
41
|
* @param schema - The schema that we are translating.
|
36
|
-
* @param validationData - The data that we are using to validate the schema. This means for example, the
|
37
|
-
* it is not valid, etc.
|
38
|
-
* @param fallbackFunctions - The fallback functions that we are using to validate the schema. Those are
|
39
|
-
* supported by the adapter.
|
42
|
+
* @param validationData - The data that we are using to validate the schema. This means for example, the
|
43
|
+
* `max` validation, the `min` validation, etc. The message of the validation when it is not valid, etc.
|
44
|
+
* @param fallbackFunctions - The fallback functions that we are using to validate the schema. Those are
|
45
|
+
* the functions we fallback to when the user defines a validation that is not supported by the adapter.
|
40
46
|
*
|
41
47
|
* @returns - The translated schema for something that the adapter is able to understand.
|
42
48
|
*/
|
43
49
|
export declare function defaultTransform<TType extends SupportedSchemas>(type: TType, schema: Schema<any, any>, adapter: SchemaAdapter, fieldAdapter: FieldAdapter | undefined, getValidationData: (isStringVersion: boolean) => ValidationDataBasedOnType<TType>, fallbackFunctions: FallbackFunctionsType<Omit<Awaited<ReturnType<typeof getValidationData>>, 'parsers'>>, options: {
|
44
50
|
validatorsIfFallbackOrNotSupported?: ValidationFallbackReturnType | ValidationFallbackReturnType[];
|
45
51
|
/**
|
46
|
-
* If the schema is not supported by the adapter, this means, that the adapter hasn't defined an adapter
|
52
|
+
* If the schema is not supported by the adapter, this means, that the adapter hasn't defined an adapter
|
53
|
+
* for that field type, we can fallback to a custom implementation.
|
47
54
|
* The problem is that, for example: Unions,
|
48
55
|
*
|
49
|
-
* Let's say we have a schema like this:
|
56
|
+
* Let's say we have a schema like this:
|
57
|
+
* ObjectSchema.new({ age: UnionSchema.new([NumberSchema.new(), StringSchema.new()] )});
|
50
58
|
*
|
51
|
-
* The root object will be validated by the adapter so what we need to do is create two schemas on the
|
52
|
-
* value of `age` key is a number and another where the value of `age` key is
|
53
|
-
*
|
54
|
-
*
|
59
|
+
* The root object will be validated by the adapter so what we need to do is create two schemas on the
|
60
|
+
* root object, one where the value of `age` key is a number and another where the value of `age` key is
|
61
|
+
* a string. Now the root object has two schemas memoized on __transformedSchemas, nice, what's the logic
|
62
|
+
* on that case? The ObjectSchema shouldn't take care of that logic. So the Union schema takes control of
|
63
|
+
* validating through the adapter. Is adapter 1 without errors? If yes, return the result, if not, try
|
64
|
+
* the second adapter. If the second adapter is without errors, return the result, if not, return the
|
65
|
+
* errors.
|
55
66
|
*
|
56
|
-
* In other words, the `fallbackIfNotSupported` function on Unions should return the two schemas saved on
|
57
|
-
* create those two schemas on the array.
|
67
|
+
* In other words, the `fallbackIfNotSupported` function on Unions should return the two schemas saved on
|
68
|
+
* it on that case, that way the root ObjectSchema will create those two schemas on the array.
|
58
69
|
*/
|
59
70
|
fallbackIfNotSupported?: () => ReturnType<Schema['__transformToAdapter']>;
|
60
71
|
} & Pick<Parameters<Schema['__transformToAdapter']>[0], 'shouldAddStringVersion'>): Promise<any[]>;
|
61
72
|
/**
|
62
|
-
* This function is used to transform the schema to the adapter. By default it caches the transformed schemas on
|
63
|
-
* to transform to the schema again.
|
73
|
+
* This function is used to transform the schema to the adapter. By default it caches the transformed schemas on
|
74
|
+
* the schema instance. So on subsequent validations we don't need to transform to the schema again.
|
64
75
|
*/
|
65
|
-
export declare function defaultTransformToAdapter(callback: (adapter: SchemaAdapter) => ReturnType<FieldAdapter['translate']>, transformedSchemas: Schema['__transformedSchemas'], options: Parameters<Schema['__transformToAdapter']>[0], type: string): Promise<any[]>;
|
66
|
-
export declare function formatErrorFromParseMethod(adapter: SchemaAdapter, fieldAdapter: FieldAdapter, error: any, path: ValidationFallbackCallbackReturnType['errors'][number]['path'], errorsAsHashedSet: Set<string>): Promise<{
|
76
|
+
export declare function defaultTransformToAdapter(callback: (adapter: SchemaAdapter) => ReturnType<FieldAdapter['translate']>, schema: Schema<any, any>, transformedSchemas: Schema['__transformedSchemas'], options: Parameters<Schema['__transformToAdapter']>[0], type: string): Promise<any[]>;
|
77
|
+
export declare function formatErrorFromParseMethod(adapter: SchemaAdapter, fieldAdapter: FieldAdapter, error: any, received: any, schema: any, path: ValidationFallbackCallbackReturnType['errors'][number]['path'], errorsAsHashedSet: Set<string>): Promise<{
|
78
|
+
received: any;
|
67
79
|
isValid: boolean;
|
68
80
|
code: import("./adapter/types").ErrorCodes;
|
69
81
|
message: string;
|
70
82
|
path: (string | number)[];
|
71
83
|
}>;
|
72
84
|
/**
|
73
|
-
* Transform the schema and check if we should add a fallback validation for that schema. This is used for complex
|
85
|
+
* Transform the schema and check if we should add a fallback validation for that schema. This is used for complex
|
86
|
+
* schemas like Objects, arrays, unions, etc.
|
74
87
|
*/
|
75
88
|
export declare function transformSchemaAndCheckIfShouldBeHandledByFallbackOnComplexSchemas(schema: Schema, options: Parameters<Schema['__transformToAdapter']>[0]): Promise<readonly [{
|
76
89
|
transformed: ReturnType<FieldAdapter["translate"]>;
|
77
90
|
asString: string;
|
78
91
|
}[], boolean]>;
|
92
|
+
export declare function shouldRunDataOnComplexSchemas(schema: Schema<any, any>): boolean;
|
79
93
|
//# sourceMappingURL=utils.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,WAAW,CAAC;AAKtC,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAC1C,OAAO,KAAK,EAAE,oCAAoC,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AACzG,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEvE;;;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MAAM,EACd,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC;;;eAkCvD;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,WAOrE"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../../src/validators/array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,KAAK,EAAwC,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAE1G,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,4BAA4B,
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../../src/validators/array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,KAAK,EAAwC,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAE1G,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,4BAA4B,CAwF3G;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,aAAa,CAAC,GAAG,4BAA4B,CA4BxF;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,aAAa,CAAC,GAAG,4BAA4B,CA4BxF;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,GAAG,4BAA4B,CA4BtF"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../../../src/validators/boolean.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAEpE,wBAAgB,iBAAiB,IAAI,4BAA4B,
|
1
|
+
{"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../../../src/validators/boolean.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAEpE,wBAAgB,iBAAiB,IAAI,4BAA4B,CA6BhE;AAED,wBAAgB,iBAAiB,IAAI,4BAA4B,CAiBhE"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"datetime.d.ts","sourceRoot":"","sources":["../../../../src/validators/datetime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAEpE,wBAAgB,kBAAkB,IAAI,4BAA4B,
|
1
|
+
{"version":3,"file":"datetime.d.ts","sourceRoot":"","sources":["../../../../src/validators/datetime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAEpE,wBAAgB,kBAAkB,IAAI,4BAA4B,CA6BjE;AAED,wBAAgB,iBAAiB,IAAI,4BAA4B,CAyBhE;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,cAAc,CAAC,SAAS,CAAC,GAAG,4BAA4B,CA4BnF;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,cAAc,CAAC,SAAS,CAAC,GAAG,4BAA4B,CA4BnF"}
|
@@ -1,10 +1,9 @@
|
|
1
1
|
import type NumberSchema from '../schema/number';
|
2
2
|
import type { ValidationFallbackReturnType } from '../schema/types';
|
3
3
|
export declare function numberValidation(): ValidationFallbackReturnType;
|
4
|
-
export declare function max(args: NumberSchema['__max']): ValidationFallbackReturnType;
|
5
|
-
export declare function min(args: NumberSchema['__min']): ValidationFallbackReturnType;
|
6
|
-
export declare function
|
7
|
-
export declare function
|
8
|
-
export declare function
|
9
|
-
export declare function decimalPlaces(args: NumberSchema['__decimalPlaces']): ValidationFallbackReturnType;
|
4
|
+
export declare function max(args: NonNullable<NumberSchema['__max']>): ValidationFallbackReturnType;
|
5
|
+
export declare function min(args: NonNullable<NumberSchema['__min']>): ValidationFallbackReturnType;
|
6
|
+
export declare function integer(args: NonNullable<NumberSchema['__integer']>): ValidationFallbackReturnType;
|
7
|
+
export declare function maxDigits(args: NonNullable<NumberSchema['__maxDigits']>): ValidationFallbackReturnType;
|
8
|
+
export declare function decimalPlaces(args: NonNullable<NumberSchema['__decimalPlaces']>): ValidationFallbackReturnType;
|
10
9
|
//# sourceMappingURL=number.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../../../src/validators/number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAEpE,wBAAgB,gBAAgB,IAAI,4BAA4B,
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../../../src/validators/number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAEpE,wBAAgB,gBAAgB,IAAI,4BAA4B,CAwB/D;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,4BAA4B,CAsC1F;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,4BAA4B,CAgC1F;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,GAAG,4BAA4B,CAuBlG;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,GAAG,4BAA4B,CAuBtG;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC,GAAG,4BAA4B,CAuB9G"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../../../src/validators/object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,KAAK,EAAwC,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAE1G,wBAAgB,gBAAgB,CAAC,cAAc,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAAG,4BAA4B,
|
1
|
+
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../../../src/validators/object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,KAAK,EAAwC,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAE1G,wBAAgB,gBAAgB,CAAC,cAAc,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAAG,4BAA4B,CAoDxG"}
|
@@ -5,6 +5,6 @@ import type StringSchema from '../schema/string';
|
|
5
5
|
import type { ValidationFallbackReturnType } from '../schema/types';
|
6
6
|
export declare function optional(args: Schema['__optional']): ValidationFallbackReturnType;
|
7
7
|
export declare function nullable(args: Schema['__nullable']): ValidationFallbackReturnType;
|
8
|
-
export declare function checkType(args: Schema['__type']): ValidationFallbackReturnType;
|
9
|
-
export declare function is(args: BooleanSchema['__is'] | NumberSchema['__is'] | StringSchema['__is']): ValidationFallbackReturnType;
|
8
|
+
export declare function checkType(args: NonNullable<Schema['__type']>): ValidationFallbackReturnType;
|
9
|
+
export declare function is(args: NonNullable<BooleanSchema['__is']> | NonNullable<NumberSchema['__is']> | NonNullable<StringSchema['__is']>): ValidationFallbackReturnType;
|
10
10
|
//# sourceMappingURL=schema.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/validators/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,aAAa,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAEpE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,YAAY,CAAC,GAAG,4BAA4B,
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/validators/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,aAAa,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAEpE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,YAAY,CAAC,GAAG,4BAA4B,CAmCjF;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,YAAY,CAAC,GAAG,4BAA4B,CAmCjF;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,4BAA4B,CA4B3F;AAED,wBAAgB,EAAE,CAChB,IAAI,EAAE,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,GAC/G,4BAA4B,CA4B9B"}
|
@@ -1,12 +1,12 @@
|
|
1
|
-
import type StringSchema from '../schema/string';
|
2
1
|
import { type ValidationFallbackReturnType } from '../schema/types';
|
2
|
+
import type StringSchema from '../schema/string';
|
3
3
|
export declare function stringValidation(): ValidationFallbackReturnType;
|
4
|
-
export declare function maxLength(args: StringSchema['__maxLength']): ValidationFallbackReturnType;
|
5
|
-
export declare function minLength(args: StringSchema['__maxLength']): ValidationFallbackReturnType;
|
6
|
-
export declare function endsWith(args: StringSchema['__endsWith']): ValidationFallbackReturnType;
|
7
|
-
export declare function startsWith(args: StringSchema['__startsWith']): ValidationFallbackReturnType;
|
8
|
-
export declare function includes(args: StringSchema['__includes']): ValidationFallbackReturnType;
|
9
|
-
export declare function regex(args: StringSchema['__regex']): ValidationFallbackReturnType;
|
10
|
-
export declare function uuid(args: StringSchema['__uuid']): ValidationFallbackReturnType;
|
11
|
-
export declare function email(args: StringSchema['__email']): ValidationFallbackReturnType;
|
4
|
+
export declare function maxLength(args: NonNullable<StringSchema['__maxLength']>): ValidationFallbackReturnType;
|
5
|
+
export declare function minLength(args: NonNullable<StringSchema['__maxLength']>): ValidationFallbackReturnType;
|
6
|
+
export declare function endsWith(args: NonNullable<StringSchema['__endsWith']>): ValidationFallbackReturnType;
|
7
|
+
export declare function startsWith(args: NonNullable<StringSchema['__startsWith']>): ValidationFallbackReturnType;
|
8
|
+
export declare function includes(args: NonNullable<StringSchema['__includes']>): ValidationFallbackReturnType;
|
9
|
+
export declare function regex(args: NonNullable<StringSchema['__regex']>): ValidationFallbackReturnType;
|
10
|
+
export declare function uuid(args: NonNullable<StringSchema['__uuid']>): ValidationFallbackReturnType;
|
11
|
+
export declare function email(args: NonNullable<StringSchema['__email']>): ValidationFallbackReturnType;
|
12
12
|
//# sourceMappingURL=string.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../../src/validators/string.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../../src/validators/string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAGpE,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAEjD,wBAAgB,gBAAgB,IAAI,4BAA4B,CA2B/D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,GAAG,4BAA4B,CA4BtG;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,GAAG,4BAA4B,CA4BtG;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,GAAG,4BAA4B,CA4BpG;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,GAAG,4BAA4B,CA4BxG;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,GAAG,4BAA4B,CA4BpG;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,GAAG,4BAA4B,CA4B9F;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,GAAG,4BAA4B,CA+B5F;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,GAAG,4BAA4B,CA8B9F"}
|