@eslint-react/shared 1.15.0-next.9 → 1.15.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +849 -849
- package/dist/index.d.ts +849 -849
- package/dist/index.js +5 -3
- package/dist/index.mjs +5 -3
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -52,508 +52,364 @@ declare const REACT_BUILD_IN_HOOKS: readonly ["useActionState", "useCallback", "
|
|
|
52
52
|
declare const createRuleForPlugin: (pluginName: string) => <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, unknown>>) => ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
55
|
+
* Schema with pipe type.
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
type SchemaWithPipe<TPipe extends [
|
|
58
|
+
BaseSchema<unknown, unknown, BaseIssue<unknown>>,
|
|
59
|
+
...PipeItem<any, unknown, BaseIssue<unknown>>[]
|
|
60
|
+
]> = Omit<FirstTupleItem<TPipe>, '~types' | '~validate'> & {
|
|
58
61
|
/**
|
|
59
|
-
* The
|
|
62
|
+
* The pipe items.
|
|
60
63
|
*/
|
|
61
|
-
readonly
|
|
64
|
+
readonly pipe: TPipe;
|
|
62
65
|
/**
|
|
63
|
-
* The issue type.
|
|
66
|
+
* The input, output and issue type.
|
|
67
|
+
*
|
|
68
|
+
* @internal
|
|
64
69
|
*/
|
|
65
|
-
readonly
|
|
70
|
+
readonly '~types'?: {
|
|
71
|
+
readonly input: InferInput<FirstTupleItem<TPipe>>;
|
|
72
|
+
readonly output: InferOutput<LastTupleItem<TPipe>>;
|
|
73
|
+
readonly issue: InferIssue<TPipe[number]>;
|
|
74
|
+
} | undefined;
|
|
66
75
|
/**
|
|
67
|
-
*
|
|
76
|
+
* Parses unknown input values.
|
|
77
|
+
*
|
|
78
|
+
* @param dataset The input dataset.
|
|
79
|
+
* @param config The configuration.
|
|
80
|
+
*
|
|
81
|
+
* @returns The output dataset.
|
|
82
|
+
*
|
|
83
|
+
* @internal
|
|
68
84
|
*/
|
|
69
|
-
readonly
|
|
70
|
-
}
|
|
85
|
+
readonly '~validate': (dataset: UnknownDataset, config?: Config<BaseIssue<unknown>>) => OutputDataset<InferOutput<LastTupleItem<TPipe>>, InferIssue<TPipe[number]>>;
|
|
86
|
+
};
|
|
71
87
|
|
|
72
88
|
/**
|
|
73
|
-
*
|
|
89
|
+
* Schema with pipe async type.
|
|
74
90
|
*/
|
|
75
|
-
|
|
91
|
+
type SchemaWithPipeAsync<TPipe extends [
|
|
92
|
+
(BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>),
|
|
93
|
+
...(PipeItem<any, unknown, BaseIssue<unknown>> | PipeItemAsync<any, unknown, BaseIssue<unknown>>)[]
|
|
94
|
+
]> = Omit<FirstTupleItem<TPipe>, 'async' | '~types' | '~validate'> & {
|
|
76
95
|
/**
|
|
77
|
-
* The
|
|
96
|
+
* The pipe items.
|
|
78
97
|
*/
|
|
79
|
-
readonly
|
|
98
|
+
readonly pipe: TPipe;
|
|
80
99
|
/**
|
|
81
|
-
*
|
|
100
|
+
* Whether it's async.
|
|
82
101
|
*/
|
|
83
|
-
readonly
|
|
102
|
+
readonly async: true;
|
|
84
103
|
/**
|
|
85
|
-
* The
|
|
104
|
+
* The input, output and issue type.
|
|
105
|
+
*
|
|
106
|
+
* @internal
|
|
86
107
|
*/
|
|
87
|
-
readonly
|
|
108
|
+
readonly '~types'?: {
|
|
109
|
+
readonly input: InferInput<FirstTupleItem<TPipe>>;
|
|
110
|
+
readonly output: InferOutput<LastTupleItem<TPipe>>;
|
|
111
|
+
readonly issue: InferIssue<TPipe[number]>;
|
|
112
|
+
} | undefined;
|
|
88
113
|
/**
|
|
89
|
-
*
|
|
114
|
+
* Parses unknown input values.
|
|
115
|
+
*
|
|
116
|
+
* @param dataset The input dataset.
|
|
117
|
+
* @param config The configuration.
|
|
118
|
+
*
|
|
119
|
+
* @returns The output dataset.
|
|
120
|
+
*
|
|
121
|
+
* @internal
|
|
90
122
|
*/
|
|
91
|
-
readonly
|
|
123
|
+
readonly '~validate': (dataset: UnknownDataset, config?: Config<BaseIssue<unknown>>) => Promise<OutputDataset<InferOutput<LastTupleItem<TPipe>>, InferIssue<TPipe[number]>>>;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Base metadata type.
|
|
128
|
+
*/
|
|
129
|
+
interface BaseMetadata<TInput> {
|
|
92
130
|
/**
|
|
93
|
-
* The
|
|
131
|
+
* The object kind.
|
|
94
132
|
*/
|
|
95
|
-
readonly
|
|
133
|
+
readonly kind: 'metadata';
|
|
134
|
+
/**
|
|
135
|
+
* The metadata type.
|
|
136
|
+
*/
|
|
137
|
+
readonly type: string;
|
|
138
|
+
/**
|
|
139
|
+
* The metadata reference.
|
|
140
|
+
*/
|
|
141
|
+
readonly reference: (...args: any[]) => BaseMetadata<any>;
|
|
142
|
+
/**
|
|
143
|
+
* The input, output and issue type.
|
|
144
|
+
*
|
|
145
|
+
* @internal
|
|
146
|
+
*/
|
|
147
|
+
readonly '~types'?: {
|
|
148
|
+
readonly input: TInput;
|
|
149
|
+
readonly output: TInput;
|
|
150
|
+
readonly issue: never;
|
|
151
|
+
} | undefined;
|
|
96
152
|
}
|
|
97
|
-
/**
|
|
98
|
-
* Creates an array schema.
|
|
99
|
-
*
|
|
100
|
-
* @param item The item schema.
|
|
101
|
-
*
|
|
102
|
-
* @returns An array schema.
|
|
103
|
-
*/
|
|
104
|
-
declare function array<const TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(item: TItem): ArraySchema<TItem, undefined>;
|
|
105
|
-
/**
|
|
106
|
-
* Creates an array schema.
|
|
107
|
-
*
|
|
108
|
-
* @param item The item schema.
|
|
109
|
-
* @param message The error message.
|
|
110
|
-
*
|
|
111
|
-
* @returns An array schema.
|
|
112
|
-
*/
|
|
113
|
-
declare function array<const TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TMessage extends ErrorMessage<ArrayIssue> | undefined>(item: TItem, message: TMessage): ArraySchema<TItem, TMessage>;
|
|
114
153
|
|
|
115
154
|
/**
|
|
116
|
-
*
|
|
155
|
+
* Unknown dataset type.
|
|
117
156
|
*/
|
|
118
|
-
interface
|
|
157
|
+
interface UnknownDataset {
|
|
119
158
|
/**
|
|
120
|
-
*
|
|
159
|
+
* Whether is's typed.
|
|
121
160
|
*/
|
|
122
|
-
|
|
161
|
+
typed?: false;
|
|
123
162
|
/**
|
|
124
|
-
* The
|
|
163
|
+
* The dataset value.
|
|
125
164
|
*/
|
|
126
|
-
|
|
165
|
+
value: unknown;
|
|
127
166
|
/**
|
|
128
|
-
* The
|
|
167
|
+
* The dataset issues.
|
|
129
168
|
*/
|
|
130
|
-
|
|
169
|
+
issues?: undefined;
|
|
131
170
|
}
|
|
132
171
|
/**
|
|
133
|
-
*
|
|
172
|
+
* Success dataset type.
|
|
134
173
|
*/
|
|
135
|
-
interface
|
|
136
|
-
/**
|
|
137
|
-
* The schema type.
|
|
138
|
-
*/
|
|
139
|
-
readonly type: 'boolean';
|
|
174
|
+
interface SuccessDataset<TValue> {
|
|
140
175
|
/**
|
|
141
|
-
*
|
|
176
|
+
* Whether is's typed.
|
|
142
177
|
*/
|
|
143
|
-
|
|
178
|
+
typed: true;
|
|
144
179
|
/**
|
|
145
|
-
* The
|
|
180
|
+
* The dataset value.
|
|
146
181
|
*/
|
|
147
|
-
|
|
182
|
+
value: TValue;
|
|
148
183
|
/**
|
|
149
|
-
* The
|
|
184
|
+
* The dataset issues.
|
|
150
185
|
*/
|
|
151
|
-
|
|
186
|
+
issues?: undefined;
|
|
152
187
|
}
|
|
153
188
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* @returns A boolean schema.
|
|
157
|
-
*/
|
|
158
|
-
declare function boolean(): BooleanSchema<undefined>;
|
|
159
|
-
/**
|
|
160
|
-
* Creates a boolean schema.
|
|
161
|
-
*
|
|
162
|
-
* @param message The error message.
|
|
163
|
-
*
|
|
164
|
-
* @returns A boolean schema.
|
|
165
|
-
*/
|
|
166
|
-
declare function boolean<const TMessage extends ErrorMessage<BooleanIssue> | undefined>(message: TMessage): BooleanSchema<TMessage>;
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Class type.
|
|
170
|
-
*/
|
|
171
|
-
type Class = new (...args: any[]) => any;
|
|
172
|
-
/**
|
|
173
|
-
* Instance issue type.
|
|
189
|
+
* Partial dataset type.
|
|
174
190
|
*/
|
|
175
|
-
interface
|
|
191
|
+
interface PartialDataset<TValue, TIssue extends BaseIssue<unknown>> {
|
|
176
192
|
/**
|
|
177
|
-
*
|
|
193
|
+
* Whether is's typed.
|
|
178
194
|
*/
|
|
179
|
-
|
|
195
|
+
typed: true;
|
|
180
196
|
/**
|
|
181
|
-
* The
|
|
197
|
+
* The dataset value.
|
|
182
198
|
*/
|
|
183
|
-
|
|
199
|
+
value: TValue;
|
|
184
200
|
/**
|
|
185
|
-
* The
|
|
201
|
+
* The dataset issues.
|
|
186
202
|
*/
|
|
187
|
-
|
|
203
|
+
issues: [TIssue, ...TIssue[]];
|
|
188
204
|
}
|
|
189
205
|
/**
|
|
190
|
-
*
|
|
206
|
+
* Failure dataset type.
|
|
191
207
|
*/
|
|
192
|
-
interface
|
|
193
|
-
/**
|
|
194
|
-
* The schema type.
|
|
195
|
-
*/
|
|
196
|
-
readonly type: 'instance';
|
|
208
|
+
interface FailureDataset<TIssue extends BaseIssue<unknown>> {
|
|
197
209
|
/**
|
|
198
|
-
*
|
|
210
|
+
* Whether is's typed.
|
|
199
211
|
*/
|
|
200
|
-
|
|
212
|
+
typed: false;
|
|
201
213
|
/**
|
|
202
|
-
* The
|
|
214
|
+
* The dataset value.
|
|
203
215
|
*/
|
|
204
|
-
|
|
216
|
+
value: unknown;
|
|
205
217
|
/**
|
|
206
|
-
* The
|
|
218
|
+
* The dataset issues.
|
|
207
219
|
*/
|
|
208
|
-
|
|
220
|
+
issues: [TIssue, ...TIssue[]];
|
|
209
221
|
}
|
|
210
222
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
* @param class_ The class of the instance.
|
|
214
|
-
*
|
|
215
|
-
* @returns An instance schema.
|
|
216
|
-
*/
|
|
217
|
-
declare function instance<TClass extends Class>(class_: TClass): InstanceSchema<TClass, undefined>;
|
|
218
|
-
/**
|
|
219
|
-
* Creates an instance schema.
|
|
220
|
-
*
|
|
221
|
-
* @param class_ The class of the instance.
|
|
222
|
-
* @param message The error message.
|
|
223
|
-
*
|
|
224
|
-
* @returns An instance schema.
|
|
225
|
-
*/
|
|
226
|
-
declare function instance<TClass extends Class, const TMessage extends ErrorMessage<InstanceIssue> | undefined>(class_: TClass, message: TMessage): InstanceSchema<TClass, TMessage>;
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Infer nullish output type.
|
|
223
|
+
* Output dataset type.
|
|
230
224
|
*/
|
|
231
|
-
type
|
|
225
|
+
type OutputDataset<TValue, TIssue extends BaseIssue<unknown>> = SuccessDataset<TValue> | PartialDataset<TValue, TIssue> | FailureDataset<TIssue>;
|
|
232
226
|
|
|
233
227
|
/**
|
|
234
|
-
*
|
|
228
|
+
* Base schema type.
|
|
235
229
|
*/
|
|
236
|
-
interface
|
|
230
|
+
interface BaseSchema<TInput, TOutput, TIssue extends BaseIssue<unknown>> {
|
|
231
|
+
/**
|
|
232
|
+
* The object kind.
|
|
233
|
+
*/
|
|
234
|
+
readonly kind: 'schema';
|
|
237
235
|
/**
|
|
238
236
|
* The schema type.
|
|
239
237
|
*/
|
|
240
|
-
readonly type:
|
|
238
|
+
readonly type: string;
|
|
241
239
|
/**
|
|
242
240
|
* The schema reference.
|
|
243
241
|
*/
|
|
244
|
-
readonly reference:
|
|
242
|
+
readonly reference: (...args: any[]) => BaseSchema<unknown, unknown, BaseIssue<unknown>>;
|
|
245
243
|
/**
|
|
246
244
|
* The expected property.
|
|
247
245
|
*/
|
|
248
|
-
readonly expects:
|
|
246
|
+
readonly expects: string;
|
|
249
247
|
/**
|
|
250
|
-
*
|
|
248
|
+
* Whether it's async.
|
|
251
249
|
*/
|
|
252
|
-
readonly
|
|
250
|
+
readonly async: false;
|
|
253
251
|
/**
|
|
254
|
-
* The
|
|
252
|
+
* The Standard Schema version number.
|
|
253
|
+
*
|
|
254
|
+
* @internal
|
|
255
255
|
*/
|
|
256
|
-
readonly
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Creates a nullish schema.
|
|
260
|
-
*
|
|
261
|
-
* @param wrapped The wrapped schema.
|
|
262
|
-
*
|
|
263
|
-
* @returns A nullish schema.
|
|
264
|
-
*/
|
|
265
|
-
declare function nullish<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): NullishSchema<TWrapped, never>;
|
|
266
|
-
/**
|
|
267
|
-
* Creates a nullish schema.
|
|
268
|
-
*
|
|
269
|
-
* @param wrapped The wrapped schema.
|
|
270
|
-
* @param default_ The default value.
|
|
271
|
-
*
|
|
272
|
-
* @returns A nullish schema.
|
|
273
|
-
*/
|
|
274
|
-
declare function nullish<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TDefault extends Default<TWrapped, null | undefined>>(wrapped: TWrapped, default_: TDefault): NullishSchema<TWrapped, TDefault>;
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Nullish schema async type.
|
|
278
|
-
*/
|
|
279
|
-
interface NullishSchemaAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, null | undefined>> extends BaseSchemaAsync<InferInput<TWrapped> | null | undefined, InferNullishOutput<TWrapped, TDefault>, InferIssue<TWrapped>> {
|
|
280
|
-
/**
|
|
281
|
-
* The schema type.
|
|
282
|
-
*/
|
|
283
|
-
readonly type: 'nullish';
|
|
284
|
-
/**
|
|
285
|
-
* The schema reference.
|
|
286
|
-
*/
|
|
287
|
-
readonly reference: typeof nullishAsync;
|
|
256
|
+
readonly '~standard': 1;
|
|
288
257
|
/**
|
|
289
|
-
* The
|
|
258
|
+
* The vendor name of the schema.
|
|
259
|
+
*
|
|
260
|
+
* @internal
|
|
290
261
|
*/
|
|
291
|
-
readonly
|
|
262
|
+
readonly '~vendor': 'valibot';
|
|
292
263
|
/**
|
|
293
|
-
* The
|
|
264
|
+
* The input, output and issue type.
|
|
265
|
+
*
|
|
266
|
+
* @internal
|
|
294
267
|
*/
|
|
295
|
-
readonly
|
|
268
|
+
readonly '~types'?: {
|
|
269
|
+
readonly input: TInput;
|
|
270
|
+
readonly output: TOutput;
|
|
271
|
+
readonly issue: TIssue;
|
|
272
|
+
} | undefined;
|
|
296
273
|
/**
|
|
297
|
-
*
|
|
274
|
+
* Parses unknown input values.
|
|
275
|
+
*
|
|
276
|
+
* @param dataset The input dataset.
|
|
277
|
+
* @param config The configuration.
|
|
278
|
+
*
|
|
279
|
+
* @returns The output dataset.
|
|
280
|
+
*
|
|
281
|
+
* @internal
|
|
298
282
|
*/
|
|
299
|
-
readonly
|
|
283
|
+
readonly '~validate': (dataset: UnknownDataset, config?: Config<BaseIssue<unknown>>) => OutputDataset<TOutput, TIssue>;
|
|
300
284
|
}
|
|
301
285
|
/**
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
* @param wrapped The wrapped schema.
|
|
305
|
-
*
|
|
306
|
-
* @returns A nullish schema.
|
|
307
|
-
*/
|
|
308
|
-
declare function nullishAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): NullishSchemaAsync<TWrapped, never>;
|
|
309
|
-
/**
|
|
310
|
-
* Creates a nullish schema.
|
|
311
|
-
*
|
|
312
|
-
* @param wrapped The wrapped schema.
|
|
313
|
-
* @param default_ The default value.
|
|
314
|
-
*
|
|
315
|
-
* @returns A nullish schema.
|
|
316
|
-
*/
|
|
317
|
-
declare function nullishAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, const TDefault extends DefaultAsync<TWrapped, null | undefined>>(wrapped: TWrapped, default_: TDefault): NullishSchemaAsync<TWrapped, TDefault>;
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Object issue type.
|
|
286
|
+
* Base schema async type.
|
|
321
287
|
*/
|
|
322
|
-
interface
|
|
288
|
+
interface BaseSchemaAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> extends Omit<BaseSchema<TInput, TOutput, TIssue>, 'reference' | 'async' | '~validate'> {
|
|
323
289
|
/**
|
|
324
|
-
* The
|
|
290
|
+
* The schema reference.
|
|
325
291
|
*/
|
|
326
|
-
readonly
|
|
292
|
+
readonly reference: (...args: any[]) => BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>;
|
|
327
293
|
/**
|
|
328
|
-
*
|
|
294
|
+
* Whether it's async.
|
|
329
295
|
*/
|
|
330
|
-
readonly
|
|
296
|
+
readonly async: true;
|
|
331
297
|
/**
|
|
332
|
-
*
|
|
298
|
+
* Parses unknown input values.
|
|
299
|
+
*
|
|
300
|
+
* @param dataset The input dataset.
|
|
301
|
+
* @param config The configuration.
|
|
302
|
+
*
|
|
303
|
+
* @returns The output dataset.
|
|
304
|
+
*
|
|
305
|
+
* @internal
|
|
333
306
|
*/
|
|
334
|
-
readonly
|
|
307
|
+
readonly '~validate': (dataset: UnknownDataset, config?: Config<BaseIssue<unknown>>) => Promise<OutputDataset<TOutput, TIssue>>;
|
|
335
308
|
}
|
|
336
309
|
|
|
337
310
|
/**
|
|
338
|
-
*
|
|
311
|
+
* Base transformation type.
|
|
339
312
|
*/
|
|
340
|
-
interface
|
|
313
|
+
interface BaseTransformation<TInput, TOutput, TIssue extends BaseIssue<unknown>> {
|
|
341
314
|
/**
|
|
342
|
-
* The
|
|
315
|
+
* The object kind.
|
|
343
316
|
*/
|
|
344
|
-
readonly
|
|
317
|
+
readonly kind: 'transformation';
|
|
345
318
|
/**
|
|
346
|
-
* The
|
|
319
|
+
* The transformation type.
|
|
347
320
|
*/
|
|
348
|
-
readonly
|
|
321
|
+
readonly type: string;
|
|
349
322
|
/**
|
|
350
|
-
* The
|
|
323
|
+
* The transformation reference.
|
|
351
324
|
*/
|
|
352
|
-
readonly
|
|
325
|
+
readonly reference: (...args: any[]) => BaseTransformation<any, any, BaseIssue<unknown>>;
|
|
353
326
|
/**
|
|
354
|
-
*
|
|
327
|
+
* Whether it's async.
|
|
355
328
|
*/
|
|
356
|
-
readonly
|
|
329
|
+
readonly async: false;
|
|
357
330
|
/**
|
|
358
|
-
* The
|
|
331
|
+
* The input, output and issue type.
|
|
332
|
+
*
|
|
333
|
+
* @internal
|
|
359
334
|
*/
|
|
360
|
-
readonly
|
|
335
|
+
readonly '~types'?: {
|
|
336
|
+
readonly input: TInput;
|
|
337
|
+
readonly output: TOutput;
|
|
338
|
+
readonly issue: TIssue;
|
|
339
|
+
} | undefined;
|
|
340
|
+
/**
|
|
341
|
+
* Transforms known input values.
|
|
342
|
+
*
|
|
343
|
+
* @param dataset The input dataset.
|
|
344
|
+
* @param config The configuration.
|
|
345
|
+
*
|
|
346
|
+
* @returns The output dataset.
|
|
347
|
+
*
|
|
348
|
+
* @internal
|
|
349
|
+
*/
|
|
350
|
+
readonly '~validate': (dataset: SuccessDataset<TInput>, config: Config<BaseIssue<unknown>>) => OutputDataset<TOutput, BaseIssue<unknown> | TIssue>;
|
|
361
351
|
}
|
|
362
352
|
/**
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
* Hint: This schema removes unknown entries. The output will only include the
|
|
366
|
-
* entries you specify. To include unknown entries, use `looseObject`. To
|
|
367
|
-
* return an issue for unknown entries, use `strictObject`. To include and
|
|
368
|
-
* validate unknown entries, use `objectWithRest`.
|
|
369
|
-
*
|
|
370
|
-
* @param entries The entries schema.
|
|
371
|
-
*
|
|
372
|
-
* @returns An object schema.
|
|
373
|
-
*/
|
|
374
|
-
declare function object<const TEntries extends ObjectEntries>(entries: TEntries): ObjectSchema<TEntries, undefined>;
|
|
375
|
-
/**
|
|
376
|
-
* Creates an object schema.
|
|
377
|
-
*
|
|
378
|
-
* Hint: This schema removes unknown entries. The output will only include the
|
|
379
|
-
* entries you specify. To include unknown entries, use `looseObject`. To
|
|
380
|
-
* return an issue for unknown entries, use `strictObject`. To include and
|
|
381
|
-
* validate unknown entries, use `objectWithRest`.
|
|
382
|
-
*
|
|
383
|
-
* @param entries The entries schema.
|
|
384
|
-
* @param message The error message.
|
|
385
|
-
*
|
|
386
|
-
* @returns An object schema.
|
|
387
|
-
*/
|
|
388
|
-
declare function object<const TEntries extends ObjectEntries, const TMessage extends ErrorMessage<ObjectIssue> | undefined>(entries: TEntries, message: TMessage): ObjectSchema<TEntries, TMessage>;
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Infer optional output type.
|
|
392
|
-
*/
|
|
393
|
-
type InferOptionalOutput<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, undefined>> = [TDefault] extends [never] ? InferOutput<TWrapped> | undefined : NonOptional<InferOutput<TWrapped>> | Extract<DefaultValue<TDefault>, undefined>;
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* Optional schema type.
|
|
353
|
+
* Base transformation async type.
|
|
397
354
|
*/
|
|
398
|
-
interface
|
|
399
|
-
/**
|
|
400
|
-
* The schema type.
|
|
401
|
-
*/
|
|
402
|
-
readonly type: 'optional';
|
|
403
|
-
/**
|
|
404
|
-
* The schema reference.
|
|
405
|
-
*/
|
|
406
|
-
readonly reference: typeof optional;
|
|
355
|
+
interface BaseTransformationAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> extends Omit<BaseTransformation<TInput, TOutput, TIssue>, 'reference' | 'async' | '~validate'> {
|
|
407
356
|
/**
|
|
408
|
-
* The
|
|
357
|
+
* The transformation reference.
|
|
409
358
|
*/
|
|
410
|
-
readonly
|
|
359
|
+
readonly reference: (...args: any[]) => BaseTransformation<any, any, BaseIssue<unknown>> | BaseTransformationAsync<any, any, BaseIssue<unknown>>;
|
|
411
360
|
/**
|
|
412
|
-
*
|
|
361
|
+
* Whether it's async.
|
|
413
362
|
*/
|
|
414
|
-
readonly
|
|
363
|
+
readonly async: true;
|
|
415
364
|
/**
|
|
416
|
-
*
|
|
365
|
+
* Transforms known input values.
|
|
366
|
+
*
|
|
367
|
+
* @param dataset The input dataset.
|
|
368
|
+
* @param config The configuration.
|
|
369
|
+
*
|
|
370
|
+
* @returns The output dataset.
|
|
371
|
+
*
|
|
372
|
+
* @internal
|
|
417
373
|
*/
|
|
418
|
-
readonly
|
|
374
|
+
readonly '~validate': (dataset: SuccessDataset<TInput>, config: Config<BaseIssue<unknown>>) => Promise<OutputDataset<TOutput, BaseIssue<unknown> | TIssue>>;
|
|
419
375
|
}
|
|
420
|
-
/**
|
|
421
|
-
* Creates a optional schema.
|
|
422
|
-
*
|
|
423
|
-
* @param wrapped The wrapped schema.
|
|
424
|
-
*
|
|
425
|
-
* @returns A optional schema.
|
|
426
|
-
*/
|
|
427
|
-
declare function optional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): OptionalSchema<TWrapped, never>;
|
|
428
|
-
/**
|
|
429
|
-
* Creates a optional schema.
|
|
430
|
-
*
|
|
431
|
-
* @param wrapped The wrapped schema.
|
|
432
|
-
* @param default_ The default value.
|
|
433
|
-
*
|
|
434
|
-
* @returns A optional schema.
|
|
435
|
-
*/
|
|
436
|
-
declare function optional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TDefault extends Default<TWrapped, undefined>>(wrapped: TWrapped, default_: TDefault): OptionalSchema<TWrapped, TDefault>;
|
|
437
376
|
|
|
438
377
|
/**
|
|
439
|
-
*
|
|
378
|
+
* Base validation type.
|
|
440
379
|
*/
|
|
441
|
-
interface
|
|
380
|
+
interface BaseValidation<TInput, TOutput, TIssue extends BaseIssue<unknown>> {
|
|
442
381
|
/**
|
|
443
|
-
* The
|
|
382
|
+
* The object kind.
|
|
444
383
|
*/
|
|
445
|
-
readonly
|
|
384
|
+
readonly kind: 'validation';
|
|
446
385
|
/**
|
|
447
|
-
* The
|
|
386
|
+
* The validation type.
|
|
448
387
|
*/
|
|
449
|
-
readonly
|
|
388
|
+
readonly type: string;
|
|
389
|
+
/**
|
|
390
|
+
* The validation reference.
|
|
391
|
+
*/
|
|
392
|
+
readonly reference: (...args: any[]) => BaseValidation<any, any, BaseIssue<unknown>>;
|
|
450
393
|
/**
|
|
451
394
|
* The expected property.
|
|
452
395
|
*/
|
|
453
|
-
readonly expects:
|
|
396
|
+
readonly expects: string | null;
|
|
454
397
|
/**
|
|
455
|
-
*
|
|
398
|
+
* Whether it's async.
|
|
456
399
|
*/
|
|
457
|
-
readonly
|
|
400
|
+
readonly async: false;
|
|
458
401
|
/**
|
|
459
|
-
* The
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Creates an optional schema.
|
|
465
|
-
*
|
|
466
|
-
* @param wrapped The wrapped schema.
|
|
467
|
-
*
|
|
468
|
-
* @returns An optional schema.
|
|
469
|
-
*/
|
|
470
|
-
declare function optionalAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): OptionalSchemaAsync<TWrapped, never>;
|
|
471
|
-
/**
|
|
472
|
-
* Creates an optional schema.
|
|
473
|
-
*
|
|
474
|
-
* @param wrapped The wrapped schema.
|
|
475
|
-
* @param default_ The default value.
|
|
476
|
-
*
|
|
477
|
-
* @returns An optional schema.
|
|
478
|
-
*/
|
|
479
|
-
declare function optionalAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, const TDefault extends DefaultAsync<TWrapped, undefined>>(wrapped: TWrapped, default_: TDefault): OptionalSchemaAsync<TWrapped, TDefault>;
|
|
480
|
-
|
|
481
|
-
/**
|
|
482
|
-
* String issue type.
|
|
483
|
-
*/
|
|
484
|
-
interface StringIssue extends BaseIssue<unknown> {
|
|
485
|
-
/**
|
|
486
|
-
* The issue kind.
|
|
487
|
-
*/
|
|
488
|
-
readonly kind: 'schema';
|
|
489
|
-
/**
|
|
490
|
-
* The issue type.
|
|
491
|
-
*/
|
|
492
|
-
readonly type: 'string';
|
|
493
|
-
/**
|
|
494
|
-
* The expected property.
|
|
495
|
-
*/
|
|
496
|
-
readonly expected: 'string';
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* String schema type.
|
|
500
|
-
*/
|
|
501
|
-
interface StringSchema<TMessage extends ErrorMessage<StringIssue> | undefined> extends BaseSchema<string, string, StringIssue> {
|
|
502
|
-
/**
|
|
503
|
-
* The schema type.
|
|
504
|
-
*/
|
|
505
|
-
readonly type: 'string';
|
|
506
|
-
/**
|
|
507
|
-
* The schema reference.
|
|
508
|
-
*/
|
|
509
|
-
readonly reference: typeof string;
|
|
510
|
-
/**
|
|
511
|
-
* The expected property.
|
|
512
|
-
*/
|
|
513
|
-
readonly expects: 'string';
|
|
514
|
-
/**
|
|
515
|
-
* The error message.
|
|
516
|
-
*/
|
|
517
|
-
readonly message: TMessage;
|
|
518
|
-
}
|
|
519
|
-
/**
|
|
520
|
-
* Creates a string schema.
|
|
521
|
-
*
|
|
522
|
-
* @returns A string schema.
|
|
523
|
-
*/
|
|
524
|
-
declare function string(): StringSchema<undefined>;
|
|
525
|
-
/**
|
|
526
|
-
* Creates a string schema.
|
|
527
|
-
*
|
|
528
|
-
* @param message The error message.
|
|
529
|
-
*
|
|
530
|
-
* @returns A string schema.
|
|
531
|
-
*/
|
|
532
|
-
declare function string<const TMessage extends ErrorMessage<StringIssue> | undefined>(message: TMessage): StringSchema<TMessage>;
|
|
533
|
-
|
|
534
|
-
/**
|
|
535
|
-
* Schema with pipe type.
|
|
536
|
-
*/
|
|
537
|
-
type SchemaWithPipe<TPipe extends [
|
|
538
|
-
BaseSchema<unknown, unknown, BaseIssue<unknown>>,
|
|
539
|
-
...PipeItem<any, unknown, BaseIssue<unknown>>[]
|
|
540
|
-
]> = Omit<FirstTupleItem<TPipe>, '~types' | '~validate'> & {
|
|
541
|
-
/**
|
|
542
|
-
* The pipe items.
|
|
543
|
-
*/
|
|
544
|
-
readonly pipe: TPipe;
|
|
545
|
-
/**
|
|
546
|
-
* The input, output and issue type.
|
|
547
|
-
*
|
|
548
|
-
* @internal
|
|
402
|
+
* The input, output and issue type.
|
|
403
|
+
*
|
|
404
|
+
* @internal
|
|
549
405
|
*/
|
|
550
406
|
readonly '~types'?: {
|
|
551
|
-
readonly input:
|
|
552
|
-
readonly output:
|
|
553
|
-
readonly issue:
|
|
407
|
+
readonly input: TInput;
|
|
408
|
+
readonly output: TOutput;
|
|
409
|
+
readonly issue: TIssue;
|
|
554
410
|
} | undefined;
|
|
555
411
|
/**
|
|
556
|
-
*
|
|
412
|
+
* Validates known input values.
|
|
557
413
|
*
|
|
558
414
|
* @param dataset The input dataset.
|
|
559
415
|
* @param config The configuration.
|
|
@@ -562,36 +418,22 @@ type SchemaWithPipe<TPipe extends [
|
|
|
562
418
|
*
|
|
563
419
|
* @internal
|
|
564
420
|
*/
|
|
565
|
-
readonly '~validate': (dataset:
|
|
566
|
-
}
|
|
567
|
-
|
|
421
|
+
readonly '~validate': (dataset: OutputDataset<TInput, BaseIssue<unknown>>, config: Config<BaseIssue<unknown>>) => OutputDataset<TOutput, BaseIssue<unknown> | TIssue>;
|
|
422
|
+
}
|
|
568
423
|
/**
|
|
569
|
-
*
|
|
424
|
+
* Base validation async type.
|
|
570
425
|
*/
|
|
571
|
-
|
|
572
|
-
(BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>),
|
|
573
|
-
...(PipeItem<any, unknown, BaseIssue<unknown>> | PipeItemAsync<any, unknown, BaseIssue<unknown>>)[]
|
|
574
|
-
]> = Omit<FirstTupleItem<TPipe>, 'async' | '~types' | '~validate'> & {
|
|
426
|
+
interface BaseValidationAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> extends Omit<BaseValidation<TInput, TOutput, TIssue>, 'reference' | 'async' | '~validate'> {
|
|
575
427
|
/**
|
|
576
|
-
* The
|
|
428
|
+
* The validation reference.
|
|
577
429
|
*/
|
|
578
|
-
readonly
|
|
430
|
+
readonly reference: (...args: any[]) => BaseValidation<any, any, BaseIssue<unknown>> | BaseValidationAsync<any, any, BaseIssue<unknown>>;
|
|
579
431
|
/**
|
|
580
432
|
* Whether it's async.
|
|
581
433
|
*/
|
|
582
434
|
readonly async: true;
|
|
583
435
|
/**
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
* @internal
|
|
587
|
-
*/
|
|
588
|
-
readonly '~types'?: {
|
|
589
|
-
readonly input: InferInput<FirstTupleItem<TPipe>>;
|
|
590
|
-
readonly output: InferOutput<LastTupleItem<TPipe>>;
|
|
591
|
-
readonly issue: InferIssue<TPipe[number]>;
|
|
592
|
-
} | undefined;
|
|
593
|
-
/**
|
|
594
|
-
* Parses unknown input values.
|
|
436
|
+
* Validates known input values.
|
|
595
437
|
*
|
|
596
438
|
* @param dataset The input dataset.
|
|
597
439
|
* @param config The configuration.
|
|
@@ -600,702 +442,860 @@ type SchemaWithPipeAsync<TPipe extends [
|
|
|
600
442
|
*
|
|
601
443
|
* @internal
|
|
602
444
|
*/
|
|
603
|
-
readonly '~validate': (dataset:
|
|
604
|
-
}
|
|
445
|
+
readonly '~validate': (dataset: OutputDataset<TInput, BaseIssue<unknown>>, config: Config<BaseIssue<unknown>>) => Promise<OutputDataset<TOutput, BaseIssue<unknown> | TIssue>>;
|
|
446
|
+
}
|
|
605
447
|
|
|
606
448
|
/**
|
|
607
|
-
*
|
|
449
|
+
* Infer input type.
|
|
608
450
|
*/
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
451
|
+
type InferInput<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | BaseValidation<any, unknown, BaseIssue<unknown>> | BaseValidationAsync<any, unknown, BaseIssue<unknown>> | BaseTransformation<any, unknown, BaseIssue<unknown>> | BaseTransformationAsync<any, unknown, BaseIssue<unknown>> | BaseMetadata<any>> = NonNullable<TItem['~types']>['input'];
|
|
452
|
+
/**
|
|
453
|
+
* Infer output type.
|
|
454
|
+
*/
|
|
455
|
+
type InferOutput<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | BaseValidation<any, unknown, BaseIssue<unknown>> | BaseValidationAsync<any, unknown, BaseIssue<unknown>> | BaseTransformation<any, unknown, BaseIssue<unknown>> | BaseTransformationAsync<any, unknown, BaseIssue<unknown>> | BaseMetadata<any>> = NonNullable<TItem['~types']>['output'];
|
|
456
|
+
/**
|
|
457
|
+
* Infer issue type.
|
|
458
|
+
*/
|
|
459
|
+
type InferIssue<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | BaseValidation<any, unknown, BaseIssue<unknown>> | BaseValidationAsync<any, unknown, BaseIssue<unknown>> | BaseTransformation<any, unknown, BaseIssue<unknown>> | BaseTransformationAsync<any, unknown, BaseIssue<unknown>> | BaseMetadata<any>> = NonNullable<TItem['~types']>['issue'];
|
|
460
|
+
/**
|
|
461
|
+
* Extracts `null` and `undefined` from a type.
|
|
462
|
+
*/
|
|
463
|
+
type NonNullish<TValue> = TValue extends null | undefined ? never : TValue;
|
|
464
|
+
/**
|
|
465
|
+
* Extracts `undefined` from a type.
|
|
466
|
+
*/
|
|
467
|
+
type NonOptional<TValue> = TValue extends undefined ? never : TValue;
|
|
468
|
+
/**
|
|
469
|
+
* Constructs a type that is maybe readonly.
|
|
470
|
+
*/
|
|
471
|
+
type MaybeReadonly<TValue> = TValue | Readonly<TValue>;
|
|
472
|
+
/**
|
|
473
|
+
* Constructs a type that is maybe a promise.
|
|
474
|
+
*/
|
|
475
|
+
type MaybePromise<TValue> = TValue | Promise<TValue>;
|
|
476
|
+
/**
|
|
477
|
+
* Prettifies a type for better readability.
|
|
478
|
+
*
|
|
479
|
+
* Hint: This type has no effect and is only used so that TypeScript displays
|
|
480
|
+
* the final type in the preview instead of the utility types used.
|
|
481
|
+
*/
|
|
482
|
+
type Prettify<TObject> = {
|
|
483
|
+
[TKey in keyof TObject]: TObject[TKey];
|
|
484
|
+
} & {};
|
|
485
|
+
/**
|
|
486
|
+
* Marks specific keys as optional.
|
|
487
|
+
*/
|
|
488
|
+
type MarkOptional<TObject, TKeys extends keyof TObject> = Omit<TObject, TKeys> & Partial<Pick<TObject, TKeys>>;
|
|
489
|
+
/**
|
|
490
|
+
* Extracts first tuple item.
|
|
491
|
+
*/
|
|
492
|
+
type FirstTupleItem<TTuple extends [unknown, ...unknown[]]> = TTuple[0];
|
|
493
|
+
/**
|
|
494
|
+
* Extracts last tuple item.
|
|
495
|
+
*/
|
|
496
|
+
type LastTupleItem<TTuple extends [unknown, ...unknown[]]> = TTuple[TTuple extends [unknown, ...infer TRest] ? TRest['length'] : never];
|
|
633
497
|
|
|
634
498
|
/**
|
|
635
|
-
*
|
|
499
|
+
* Error message type.
|
|
636
500
|
*/
|
|
637
|
-
|
|
638
|
-
/**
|
|
639
|
-
* Whether is's typed.
|
|
640
|
-
*/
|
|
641
|
-
typed?: false;
|
|
642
|
-
/**
|
|
643
|
-
* The dataset value.
|
|
644
|
-
*/
|
|
645
|
-
value: unknown;
|
|
646
|
-
/**
|
|
647
|
-
* The dataset issues.
|
|
648
|
-
*/
|
|
649
|
-
issues?: undefined;
|
|
650
|
-
}
|
|
501
|
+
type ErrorMessage<TIssue extends BaseIssue<unknown>> = ((issue: TIssue) => string) | string;
|
|
651
502
|
/**
|
|
652
|
-
*
|
|
503
|
+
* Default type.
|
|
653
504
|
*/
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* Whether is's typed.
|
|
657
|
-
*/
|
|
658
|
-
typed: true;
|
|
659
|
-
/**
|
|
660
|
-
* The dataset value.
|
|
661
|
-
*/
|
|
662
|
-
value: TValue;
|
|
663
|
-
/**
|
|
664
|
-
* The dataset issues.
|
|
665
|
-
*/
|
|
666
|
-
issues?: undefined;
|
|
667
|
-
}
|
|
505
|
+
type Default<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TInput extends null | undefined> = MaybeReadonly<InferInput<TWrapped> | TInput> | ((dataset?: UnknownDataset, config?: Config<InferIssue<TWrapped>>) => MaybeReadonly<InferInput<TWrapped> | TInput>);
|
|
668
506
|
/**
|
|
669
|
-
*
|
|
507
|
+
* Default async type.
|
|
670
508
|
*/
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
*/
|
|
683
|
-
issues: [TIssue, ...TIssue[]];
|
|
509
|
+
type DefaultAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TInput extends null | undefined> = MaybeReadonly<InferInput<TWrapped> | TInput> | ((dataset?: UnknownDataset, config?: Config<InferIssue<TWrapped>>) => MaybePromise<MaybeReadonly<InferInput<TWrapped> | TInput>>);
|
|
510
|
+
/**
|
|
511
|
+
* Default value type.
|
|
512
|
+
*/
|
|
513
|
+
type DefaultValue<TDefault extends Default<BaseSchema<unknown, unknown, BaseIssue<unknown>>, null | undefined> | DefaultAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, null | undefined>> = TDefault extends DefaultAsync<infer TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, infer TInput> ? TDefault extends (dataset?: UnknownDataset, config?: Config<InferIssue<TWrapped>>) => MaybePromise<InferInput<TWrapped> | TInput> ? Awaited<ReturnType<TDefault>> : TDefault : never;
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Object entries type.
|
|
517
|
+
*/
|
|
518
|
+
interface ObjectEntries {
|
|
519
|
+
[key: string]: BaseSchema<unknown, unknown, BaseIssue<unknown>>;
|
|
684
520
|
}
|
|
685
521
|
/**
|
|
686
|
-
*
|
|
522
|
+
* Object entries async type.
|
|
687
523
|
*/
|
|
688
|
-
interface
|
|
689
|
-
|
|
690
|
-
* Whether is's typed.
|
|
691
|
-
*/
|
|
692
|
-
typed: false;
|
|
693
|
-
/**
|
|
694
|
-
* The dataset value.
|
|
695
|
-
*/
|
|
696
|
-
value: unknown;
|
|
697
|
-
/**
|
|
698
|
-
* The dataset issues.
|
|
699
|
-
*/
|
|
700
|
-
issues: [TIssue, ...TIssue[]];
|
|
524
|
+
interface ObjectEntriesAsync {
|
|
525
|
+
[key: string]: BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>;
|
|
701
526
|
}
|
|
702
527
|
/**
|
|
703
|
-
*
|
|
528
|
+
* Question mark schema type.
|
|
529
|
+
*
|
|
530
|
+
* TODO: Document that for simplicity and bundle size, we currently do not
|
|
531
|
+
* distinguish between `undefined` and missing keys when using `optional` and
|
|
532
|
+
* `nullish`.
|
|
704
533
|
*/
|
|
705
|
-
type
|
|
534
|
+
type QuestionMarkSchema = NullishSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | NullishSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown>;
|
|
535
|
+
/**
|
|
536
|
+
* Has default type.
|
|
537
|
+
*/
|
|
538
|
+
type HasDefault<TSchema extends QuestionMarkSchema> = [
|
|
539
|
+
TSchema['default']
|
|
540
|
+
] extends [never] ? false : true;
|
|
541
|
+
/**
|
|
542
|
+
* Exact optional input type.
|
|
543
|
+
*/
|
|
544
|
+
type ExactOptionalInput<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = TSchema extends OptionalSchema<infer TWrapped, never> | OptionalSchemaAsync<infer TWrapped, never> ? ExactOptionalInput<TWrapped> : InferInput<TSchema>;
|
|
545
|
+
/**
|
|
546
|
+
* Exact optional output type.
|
|
547
|
+
*/
|
|
548
|
+
type ExactOptionalOutput<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = TSchema extends OptionalSchema<infer TWrapped, never> | OptionalSchemaAsync<infer TWrapped, never> ? HasDefault<TSchema> extends true ? InferOutput<TSchema> : ExactOptionalOutput<TWrapped> : InferOutput<TSchema>;
|
|
549
|
+
/**
|
|
550
|
+
* Infer entries input type.
|
|
551
|
+
*/
|
|
552
|
+
type InferEntriesInput<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
553
|
+
-readonly [TKey in keyof TEntries]: ExactOptionalInput<TEntries[TKey]>;
|
|
554
|
+
};
|
|
555
|
+
/**
|
|
556
|
+
* Infer entries output type.
|
|
557
|
+
*/
|
|
558
|
+
type InferEntriesOutput<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
559
|
+
-readonly [TKey in keyof TEntries]: ExactOptionalOutput<TEntries[TKey]>;
|
|
560
|
+
};
|
|
561
|
+
/**
|
|
562
|
+
* Optional input keys type.
|
|
563
|
+
*/
|
|
564
|
+
type OptionalInputKeys<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
565
|
+
[TKey in keyof TEntries]: TEntries[TKey] extends QuestionMarkSchema ? TKey : never;
|
|
566
|
+
}[keyof TEntries];
|
|
567
|
+
/**
|
|
568
|
+
* Optional output keys type.
|
|
569
|
+
*/
|
|
570
|
+
type OptionalOutputKeys<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
571
|
+
[TKey in keyof TEntries]: TEntries[TKey] extends QuestionMarkSchema ? undefined extends InferOutput<TEntries[TKey]> ? HasDefault<TEntries[TKey]> extends false ? TKey : never : never : never;
|
|
572
|
+
}[keyof TEntries];
|
|
573
|
+
/**
|
|
574
|
+
* Input with question marks type.
|
|
575
|
+
*/
|
|
576
|
+
type InputWithQuestionMarks<TEntries extends ObjectEntries | ObjectEntriesAsync, TObject extends InferEntriesInput<TEntries> | InferEntriesOutput<TEntries>> = MarkOptional<TObject, OptionalInputKeys<TEntries>>;
|
|
577
|
+
/**
|
|
578
|
+
* Output with question marks type.
|
|
579
|
+
*/
|
|
580
|
+
type OutputWithQuestionMarks<TEntries extends ObjectEntries | ObjectEntriesAsync, TObject extends InferEntriesInput<TEntries> | InferEntriesOutput<TEntries>> = MarkOptional<TObject, OptionalOutputKeys<TEntries>>;
|
|
581
|
+
/**
|
|
582
|
+
* Readonly output keys type.
|
|
583
|
+
*/
|
|
584
|
+
type ReadonlyOutputKeys<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
585
|
+
[TKey in keyof TEntries]: TEntries[TKey] extends SchemaWithPipe<infer TPipe> | SchemaWithPipeAsync<infer TPipe> ? ReadonlyAction<any> extends TPipe[number] ? TKey : never : never;
|
|
586
|
+
}[keyof TEntries];
|
|
587
|
+
/**
|
|
588
|
+
* Output with readonly type.
|
|
589
|
+
*/
|
|
590
|
+
type OutputWithReadonly<TEntries extends ObjectEntries | ObjectEntriesAsync, TObject extends OutputWithQuestionMarks<TEntries, InferEntriesOutput<TEntries>>> = Readonly<TObject> & Pick<TObject, Exclude<keyof TObject, ReadonlyOutputKeys<TEntries>>>;
|
|
591
|
+
/**
|
|
592
|
+
* Infer object input type.
|
|
593
|
+
*/
|
|
594
|
+
type InferObjectInput<TEntries extends ObjectEntries | ObjectEntriesAsync> = Prettify<InputWithQuestionMarks<TEntries, InferEntriesInput<TEntries>>>;
|
|
595
|
+
/**
|
|
596
|
+
* Infer object output type.
|
|
597
|
+
*/
|
|
598
|
+
type InferObjectOutput<TEntries extends ObjectEntries | ObjectEntriesAsync> = Prettify<OutputWithReadonly<TEntries, OutputWithQuestionMarks<TEntries, InferEntriesOutput<TEntries>>>>;
|
|
599
|
+
/**
|
|
600
|
+
* Infer object issue type.
|
|
601
|
+
*/
|
|
602
|
+
type InferObjectIssue<TEntries extends ObjectEntries | ObjectEntriesAsync> = InferIssue<TEntries[keyof TEntries]>;
|
|
706
603
|
|
|
707
604
|
/**
|
|
708
|
-
*
|
|
605
|
+
* Array path item type.
|
|
709
606
|
*/
|
|
710
|
-
interface
|
|
607
|
+
interface ArrayPathItem {
|
|
711
608
|
/**
|
|
712
|
-
* The
|
|
609
|
+
* The path item type.
|
|
713
610
|
*/
|
|
714
|
-
readonly
|
|
611
|
+
readonly type: 'array';
|
|
715
612
|
/**
|
|
716
|
-
* The
|
|
613
|
+
* The path item origin.
|
|
717
614
|
*/
|
|
718
|
-
readonly
|
|
615
|
+
readonly origin: 'value';
|
|
719
616
|
/**
|
|
720
|
-
* The
|
|
617
|
+
* The path item input.
|
|
721
618
|
*/
|
|
722
|
-
readonly
|
|
619
|
+
readonly input: MaybeReadonly<unknown[]>;
|
|
723
620
|
/**
|
|
724
|
-
* The
|
|
621
|
+
* The path item key.
|
|
725
622
|
*/
|
|
726
|
-
readonly
|
|
623
|
+
readonly key: number;
|
|
727
624
|
/**
|
|
728
|
-
*
|
|
625
|
+
* The path item value.
|
|
729
626
|
*/
|
|
730
|
-
readonly
|
|
627
|
+
readonly value: unknown;
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Map path item type.
|
|
631
|
+
*/
|
|
632
|
+
interface MapPathItem {
|
|
731
633
|
/**
|
|
732
|
-
* The
|
|
733
|
-
*
|
|
734
|
-
* @internal
|
|
634
|
+
* The path item type.
|
|
735
635
|
*/
|
|
736
|
-
readonly '
|
|
636
|
+
readonly type: 'map';
|
|
737
637
|
/**
|
|
738
|
-
* The
|
|
739
|
-
*
|
|
740
|
-
* @internal
|
|
638
|
+
* The path item origin.
|
|
741
639
|
*/
|
|
742
|
-
readonly '
|
|
640
|
+
readonly origin: 'key' | 'value';
|
|
743
641
|
/**
|
|
744
|
-
* The
|
|
745
|
-
*
|
|
746
|
-
* @internal
|
|
642
|
+
* The path item input.
|
|
747
643
|
*/
|
|
748
|
-
readonly
|
|
749
|
-
readonly input: TInput;
|
|
750
|
-
readonly output: TOutput;
|
|
751
|
-
readonly issue: TIssue;
|
|
752
|
-
} | undefined;
|
|
644
|
+
readonly input: Map<unknown, unknown>;
|
|
753
645
|
/**
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
* @param dataset The input dataset.
|
|
757
|
-
* @param config The configuration.
|
|
758
|
-
*
|
|
759
|
-
* @returns The output dataset.
|
|
760
|
-
*
|
|
761
|
-
* @internal
|
|
646
|
+
* The path item key.
|
|
762
647
|
*/
|
|
763
|
-
readonly
|
|
648
|
+
readonly key: unknown;
|
|
649
|
+
/**
|
|
650
|
+
* The path item value.
|
|
651
|
+
*/
|
|
652
|
+
readonly value: unknown;
|
|
764
653
|
}
|
|
765
654
|
/**
|
|
766
|
-
*
|
|
655
|
+
* Object path item type.
|
|
767
656
|
*/
|
|
768
|
-
interface
|
|
657
|
+
interface ObjectPathItem {
|
|
658
|
+
/**
|
|
659
|
+
* The path item type.
|
|
660
|
+
*/
|
|
661
|
+
readonly type: 'object';
|
|
662
|
+
/**
|
|
663
|
+
* The path item origin.
|
|
664
|
+
*/
|
|
665
|
+
readonly origin: 'key' | 'value';
|
|
769
666
|
/**
|
|
770
|
-
* The
|
|
667
|
+
* The path item input.
|
|
771
668
|
*/
|
|
772
|
-
readonly
|
|
669
|
+
readonly input: Record<string, unknown>;
|
|
773
670
|
/**
|
|
774
|
-
*
|
|
671
|
+
* The path item key.
|
|
775
672
|
*/
|
|
776
|
-
readonly
|
|
673
|
+
readonly key: string;
|
|
777
674
|
/**
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
* @param dataset The input dataset.
|
|
781
|
-
* @param config The configuration.
|
|
782
|
-
*
|
|
783
|
-
* @returns The output dataset.
|
|
784
|
-
*
|
|
785
|
-
* @internal
|
|
675
|
+
* The path item value.
|
|
786
676
|
*/
|
|
787
|
-
readonly
|
|
677
|
+
readonly value: unknown;
|
|
788
678
|
}
|
|
789
|
-
|
|
790
679
|
/**
|
|
791
|
-
*
|
|
680
|
+
* Set path item type.
|
|
792
681
|
*/
|
|
793
|
-
interface
|
|
794
|
-
/**
|
|
795
|
-
* The object kind.
|
|
796
|
-
*/
|
|
797
|
-
readonly kind: 'transformation';
|
|
682
|
+
interface SetPathItem {
|
|
798
683
|
/**
|
|
799
|
-
* The
|
|
684
|
+
* The path item type.
|
|
800
685
|
*/
|
|
801
|
-
readonly type:
|
|
686
|
+
readonly type: 'set';
|
|
802
687
|
/**
|
|
803
|
-
* The
|
|
688
|
+
* The path item origin.
|
|
804
689
|
*/
|
|
805
|
-
readonly
|
|
690
|
+
readonly origin: 'value';
|
|
806
691
|
/**
|
|
807
|
-
*
|
|
692
|
+
* The path item input.
|
|
808
693
|
*/
|
|
809
|
-
readonly
|
|
694
|
+
readonly input: Set<unknown>;
|
|
810
695
|
/**
|
|
811
|
-
* The
|
|
812
|
-
*
|
|
813
|
-
* @internal
|
|
696
|
+
* The path item key.
|
|
814
697
|
*/
|
|
815
|
-
readonly
|
|
816
|
-
readonly input: TInput;
|
|
817
|
-
readonly output: TOutput;
|
|
818
|
-
readonly issue: TIssue;
|
|
819
|
-
} | undefined;
|
|
698
|
+
readonly key: null;
|
|
820
699
|
/**
|
|
821
|
-
*
|
|
822
|
-
*
|
|
823
|
-
* @param dataset The input dataset.
|
|
824
|
-
* @param config The configuration.
|
|
825
|
-
*
|
|
826
|
-
* @returns The output dataset.
|
|
827
|
-
*
|
|
828
|
-
* @internal
|
|
700
|
+
* The path item key.
|
|
829
701
|
*/
|
|
830
|
-
readonly
|
|
702
|
+
readonly value: unknown;
|
|
831
703
|
}
|
|
832
704
|
/**
|
|
833
|
-
*
|
|
705
|
+
* Unknown path item type.
|
|
834
706
|
*/
|
|
835
|
-
interface
|
|
707
|
+
interface UnknownPathItem {
|
|
836
708
|
/**
|
|
837
|
-
* The
|
|
709
|
+
* The path item type.
|
|
838
710
|
*/
|
|
839
|
-
readonly
|
|
711
|
+
readonly type: 'unknown';
|
|
840
712
|
/**
|
|
841
|
-
*
|
|
713
|
+
* The path item origin.
|
|
842
714
|
*/
|
|
843
|
-
readonly
|
|
715
|
+
readonly origin: 'key' | 'value';
|
|
844
716
|
/**
|
|
845
|
-
*
|
|
846
|
-
*
|
|
847
|
-
* @param dataset The input dataset.
|
|
848
|
-
* @param config The configuration.
|
|
849
|
-
*
|
|
850
|
-
* @returns The output dataset.
|
|
851
|
-
*
|
|
852
|
-
* @internal
|
|
717
|
+
* The path item input.
|
|
853
718
|
*/
|
|
854
|
-
readonly
|
|
719
|
+
readonly input: unknown;
|
|
720
|
+
/**
|
|
721
|
+
* The path item key.
|
|
722
|
+
*/
|
|
723
|
+
readonly key: unknown;
|
|
724
|
+
/**
|
|
725
|
+
* The path item value.
|
|
726
|
+
*/
|
|
727
|
+
readonly value: unknown;
|
|
855
728
|
}
|
|
856
|
-
|
|
857
729
|
/**
|
|
858
|
-
*
|
|
730
|
+
* Issue path item type.
|
|
731
|
+
*
|
|
732
|
+
* TODO: Document that the input of the path may be different from the input of
|
|
733
|
+
* the issue.
|
|
859
734
|
*/
|
|
860
|
-
|
|
735
|
+
type IssuePathItem = ArrayPathItem | MapPathItem | ObjectPathItem | SetPathItem | UnknownPathItem;
|
|
736
|
+
/**
|
|
737
|
+
* Base issue type.
|
|
738
|
+
*/
|
|
739
|
+
interface BaseIssue<TInput> extends Config<BaseIssue<TInput>> {
|
|
861
740
|
/**
|
|
862
|
-
* The
|
|
741
|
+
* The issue kind.
|
|
863
742
|
*/
|
|
864
|
-
readonly kind: 'validation';
|
|
743
|
+
readonly kind: 'schema' | 'validation' | 'transformation';
|
|
865
744
|
/**
|
|
866
|
-
* The
|
|
745
|
+
* The issue type.
|
|
867
746
|
*/
|
|
868
747
|
readonly type: string;
|
|
869
748
|
/**
|
|
870
|
-
* The
|
|
749
|
+
* The raw input data.
|
|
871
750
|
*/
|
|
872
|
-
readonly
|
|
751
|
+
readonly input: TInput;
|
|
873
752
|
/**
|
|
874
753
|
* The expected property.
|
|
875
754
|
*/
|
|
876
|
-
readonly
|
|
755
|
+
readonly expected: string | null;
|
|
877
756
|
/**
|
|
878
|
-
*
|
|
757
|
+
* The received property.
|
|
879
758
|
*/
|
|
880
|
-
readonly
|
|
759
|
+
readonly received: string;
|
|
881
760
|
/**
|
|
882
|
-
* The
|
|
883
|
-
*
|
|
884
|
-
* @internal
|
|
761
|
+
* The error message.
|
|
885
762
|
*/
|
|
886
|
-
readonly
|
|
887
|
-
readonly input: TInput;
|
|
888
|
-
readonly output: TOutput;
|
|
889
|
-
readonly issue: TIssue;
|
|
890
|
-
} | undefined;
|
|
763
|
+
readonly message: string;
|
|
891
764
|
/**
|
|
892
|
-
*
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
*
|
|
897
|
-
* @returns The output dataset.
|
|
765
|
+
* The input requirement.
|
|
766
|
+
*/
|
|
767
|
+
readonly requirement?: unknown | undefined;
|
|
768
|
+
/**
|
|
769
|
+
* The issue path.
|
|
898
770
|
*
|
|
899
|
-
*
|
|
771
|
+
* TODO: Investigate if it is possible to make the path type safe based on the
|
|
772
|
+
* input.
|
|
900
773
|
*/
|
|
901
|
-
readonly
|
|
774
|
+
readonly path?: [IssuePathItem, ...IssuePathItem[]] | undefined;
|
|
775
|
+
/**
|
|
776
|
+
* The sub issues.
|
|
777
|
+
*/
|
|
778
|
+
readonly issues?: [BaseIssue<TInput>, ...BaseIssue<TInput>[]] | undefined;
|
|
902
779
|
}
|
|
780
|
+
|
|
903
781
|
/**
|
|
904
|
-
*
|
|
782
|
+
* Config type.
|
|
905
783
|
*/
|
|
906
|
-
interface
|
|
784
|
+
interface Config<TIssue extends BaseIssue<unknown>> {
|
|
907
785
|
/**
|
|
908
|
-
* The
|
|
786
|
+
* The selected language.
|
|
909
787
|
*/
|
|
910
|
-
readonly
|
|
788
|
+
readonly lang?: string | undefined;
|
|
911
789
|
/**
|
|
912
|
-
*
|
|
790
|
+
* The error message.
|
|
913
791
|
*/
|
|
914
|
-
readonly
|
|
792
|
+
readonly message?: ErrorMessage<TIssue> | undefined;
|
|
915
793
|
/**
|
|
916
|
-
*
|
|
917
|
-
*
|
|
918
|
-
* @param dataset The input dataset.
|
|
919
|
-
* @param config The configuration.
|
|
920
|
-
*
|
|
921
|
-
* @returns The output dataset.
|
|
922
|
-
*
|
|
923
|
-
* @internal
|
|
794
|
+
* Whether it was abort early.
|
|
924
795
|
*/
|
|
925
|
-
readonly
|
|
796
|
+
readonly abortEarly?: boolean | undefined;
|
|
797
|
+
/**
|
|
798
|
+
* Whether the pipe was abort early.
|
|
799
|
+
*/
|
|
800
|
+
readonly abortPipeEarly?: boolean | undefined;
|
|
926
801
|
}
|
|
927
802
|
|
|
928
803
|
/**
|
|
929
|
-
*
|
|
930
|
-
*/
|
|
931
|
-
type InferInput<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | BaseValidation<any, unknown, BaseIssue<unknown>> | BaseValidationAsync<any, unknown, BaseIssue<unknown>> | BaseTransformation<any, unknown, BaseIssue<unknown>> | BaseTransformationAsync<any, unknown, BaseIssue<unknown>> | BaseMetadata<any>> = NonNullable<TItem['~types']>['input'];
|
|
932
|
-
/**
|
|
933
|
-
* Infer output type.
|
|
934
|
-
*/
|
|
935
|
-
type InferOutput<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | BaseValidation<any, unknown, BaseIssue<unknown>> | BaseValidationAsync<any, unknown, BaseIssue<unknown>> | BaseTransformation<any, unknown, BaseIssue<unknown>> | BaseTransformationAsync<any, unknown, BaseIssue<unknown>> | BaseMetadata<any>> = NonNullable<TItem['~types']>['output'];
|
|
936
|
-
/**
|
|
937
|
-
* Infer issue type.
|
|
938
|
-
*/
|
|
939
|
-
type InferIssue<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | BaseValidation<any, unknown, BaseIssue<unknown>> | BaseValidationAsync<any, unknown, BaseIssue<unknown>> | BaseTransformation<any, unknown, BaseIssue<unknown>> | BaseTransformationAsync<any, unknown, BaseIssue<unknown>> | BaseMetadata<any>> = NonNullable<TItem['~types']>['issue'];
|
|
940
|
-
/**
|
|
941
|
-
* Extracts `null` and `undefined` from a type.
|
|
942
|
-
*/
|
|
943
|
-
type NonNullish<TValue> = TValue extends null | undefined ? never : TValue;
|
|
944
|
-
/**
|
|
945
|
-
* Extracts `undefined` from a type.
|
|
946
|
-
*/
|
|
947
|
-
type NonOptional<TValue> = TValue extends undefined ? never : TValue;
|
|
948
|
-
/**
|
|
949
|
-
* Constructs a type that is maybe readonly.
|
|
950
|
-
*/
|
|
951
|
-
type MaybeReadonly<TValue> = TValue | Readonly<TValue>;
|
|
952
|
-
/**
|
|
953
|
-
* Constructs a type that is maybe a promise.
|
|
954
|
-
*/
|
|
955
|
-
type MaybePromise<TValue> = TValue | Promise<TValue>;
|
|
956
|
-
/**
|
|
957
|
-
* Prettifies a type for better readability.
|
|
958
|
-
*
|
|
959
|
-
* Hint: This type has no effect and is only used so that TypeScript displays
|
|
960
|
-
* the final type in the preview instead of the utility types used.
|
|
961
|
-
*/
|
|
962
|
-
type Prettify<TObject> = {
|
|
963
|
-
[TKey in keyof TObject]: TObject[TKey];
|
|
964
|
-
} & {};
|
|
965
|
-
/**
|
|
966
|
-
* Marks specific keys as optional.
|
|
967
|
-
*/
|
|
968
|
-
type MarkOptional<TObject, TKeys extends keyof TObject> = Omit<TObject, TKeys> & Partial<Pick<TObject, TKeys>>;
|
|
969
|
-
/**
|
|
970
|
-
* Extracts first tuple item.
|
|
971
|
-
*/
|
|
972
|
-
type FirstTupleItem<TTuple extends [unknown, ...unknown[]]> = TTuple[0];
|
|
973
|
-
/**
|
|
974
|
-
* Extracts last tuple item.
|
|
975
|
-
*/
|
|
976
|
-
type LastTupleItem<TTuple extends [unknown, ...unknown[]]> = TTuple[TTuple extends [unknown, ...infer TRest] ? TRest['length'] : never];
|
|
977
|
-
|
|
978
|
-
/**
|
|
979
|
-
* Error message type.
|
|
804
|
+
* Pipe action type.
|
|
980
805
|
*/
|
|
981
|
-
type
|
|
806
|
+
type PipeAction<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidation<TInput, TOutput, TIssue> | BaseTransformation<TInput, TOutput, TIssue> | BaseMetadata<TInput>;
|
|
982
807
|
/**
|
|
983
|
-
*
|
|
808
|
+
* Pipe action async type.
|
|
984
809
|
*/
|
|
985
|
-
type
|
|
810
|
+
type PipeActionAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidationAsync<TInput, TOutput, TIssue> | BaseTransformationAsync<TInput, TOutput, TIssue>;
|
|
986
811
|
/**
|
|
987
|
-
*
|
|
812
|
+
* Pipe item type.
|
|
988
813
|
*/
|
|
989
|
-
type
|
|
814
|
+
type PipeItem<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchema<TInput, TOutput, TIssue> | PipeAction<TInput, TOutput, TIssue>;
|
|
990
815
|
/**
|
|
991
|
-
*
|
|
816
|
+
* Pipe item async type.
|
|
992
817
|
*/
|
|
993
|
-
type
|
|
818
|
+
type PipeItemAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchemaAsync<TInput, TOutput, TIssue> | PipeActionAsync<TInput, TOutput, TIssue>;
|
|
994
819
|
|
|
995
820
|
/**
|
|
996
|
-
*
|
|
821
|
+
* Array issue type.
|
|
997
822
|
*/
|
|
998
|
-
interface
|
|
999
|
-
|
|
823
|
+
interface ArrayIssue extends BaseIssue<unknown> {
|
|
824
|
+
/**
|
|
825
|
+
* The issue kind.
|
|
826
|
+
*/
|
|
827
|
+
readonly kind: 'schema';
|
|
828
|
+
/**
|
|
829
|
+
* The issue type.
|
|
830
|
+
*/
|
|
831
|
+
readonly type: 'array';
|
|
832
|
+
/**
|
|
833
|
+
* The expected property.
|
|
834
|
+
*/
|
|
835
|
+
readonly expected: 'Array';
|
|
1000
836
|
}
|
|
837
|
+
|
|
1001
838
|
/**
|
|
1002
|
-
*
|
|
839
|
+
* Array schema type.
|
|
1003
840
|
*/
|
|
1004
|
-
interface
|
|
1005
|
-
|
|
841
|
+
interface ArraySchema<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TMessage extends ErrorMessage<ArrayIssue> | undefined> extends BaseSchema<InferInput<TItem>[], InferOutput<TItem>[], ArrayIssue | InferIssue<TItem>> {
|
|
842
|
+
/**
|
|
843
|
+
* The schema type.
|
|
844
|
+
*/
|
|
845
|
+
readonly type: 'array';
|
|
846
|
+
/**
|
|
847
|
+
* The schema reference.
|
|
848
|
+
*/
|
|
849
|
+
readonly reference: typeof array;
|
|
850
|
+
/**
|
|
851
|
+
* The expected property.
|
|
852
|
+
*/
|
|
853
|
+
readonly expects: 'Array';
|
|
854
|
+
/**
|
|
855
|
+
* The array item schema.
|
|
856
|
+
*/
|
|
857
|
+
readonly item: TItem;
|
|
858
|
+
/**
|
|
859
|
+
* The error message.
|
|
860
|
+
*/
|
|
861
|
+
readonly message: TMessage;
|
|
1006
862
|
}
|
|
1007
863
|
/**
|
|
1008
|
-
*
|
|
864
|
+
* Creates an array schema.
|
|
1009
865
|
*
|
|
1010
|
-
*
|
|
1011
|
-
*
|
|
1012
|
-
*
|
|
866
|
+
* @param item The item schema.
|
|
867
|
+
*
|
|
868
|
+
* @returns An array schema.
|
|
1013
869
|
*/
|
|
1014
|
-
|
|
870
|
+
declare function array<const TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(item: TItem): ArraySchema<TItem, undefined>;
|
|
1015
871
|
/**
|
|
1016
|
-
*
|
|
872
|
+
* Creates an array schema.
|
|
873
|
+
*
|
|
874
|
+
* @param item The item schema.
|
|
875
|
+
* @param message The error message.
|
|
876
|
+
*
|
|
877
|
+
* @returns An array schema.
|
|
1017
878
|
*/
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
] extends [never] ? false : true;
|
|
879
|
+
declare function array<const TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TMessage extends ErrorMessage<ArrayIssue> | undefined>(item: TItem, message: TMessage): ArraySchema<TItem, TMessage>;
|
|
880
|
+
|
|
1021
881
|
/**
|
|
1022
|
-
*
|
|
882
|
+
* Boolean issue type.
|
|
1023
883
|
*/
|
|
1024
|
-
|
|
884
|
+
interface BooleanIssue extends BaseIssue<unknown> {
|
|
885
|
+
/**
|
|
886
|
+
* The issue kind.
|
|
887
|
+
*/
|
|
888
|
+
readonly kind: 'schema';
|
|
889
|
+
/**
|
|
890
|
+
* The issue type.
|
|
891
|
+
*/
|
|
892
|
+
readonly type: 'boolean';
|
|
893
|
+
/**
|
|
894
|
+
* The expected property.
|
|
895
|
+
*/
|
|
896
|
+
readonly expected: 'boolean';
|
|
897
|
+
}
|
|
1025
898
|
/**
|
|
1026
|
-
*
|
|
899
|
+
* Boolean schema type.
|
|
1027
900
|
*/
|
|
1028
|
-
|
|
901
|
+
interface BooleanSchema<TMessage extends ErrorMessage<BooleanIssue> | undefined> extends BaseSchema<boolean, boolean, BooleanIssue> {
|
|
902
|
+
/**
|
|
903
|
+
* The schema type.
|
|
904
|
+
*/
|
|
905
|
+
readonly type: 'boolean';
|
|
906
|
+
/**
|
|
907
|
+
* The schema reference.
|
|
908
|
+
*/
|
|
909
|
+
readonly reference: typeof boolean;
|
|
910
|
+
/**
|
|
911
|
+
* The expected property.
|
|
912
|
+
*/
|
|
913
|
+
readonly expects: 'boolean';
|
|
914
|
+
/**
|
|
915
|
+
* The error message.
|
|
916
|
+
*/
|
|
917
|
+
readonly message: TMessage;
|
|
918
|
+
}
|
|
1029
919
|
/**
|
|
1030
|
-
*
|
|
920
|
+
* Creates a boolean schema.
|
|
921
|
+
*
|
|
922
|
+
* @returns A boolean schema.
|
|
1031
923
|
*/
|
|
1032
|
-
|
|
1033
|
-
-readonly [TKey in keyof TEntries]: ExactOptionalInput<TEntries[TKey]>;
|
|
1034
|
-
};
|
|
924
|
+
declare function boolean(): BooleanSchema<undefined>;
|
|
1035
925
|
/**
|
|
1036
|
-
*
|
|
926
|
+
* Creates a boolean schema.
|
|
927
|
+
*
|
|
928
|
+
* @param message The error message.
|
|
929
|
+
*
|
|
930
|
+
* @returns A boolean schema.
|
|
1037
931
|
*/
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
};
|
|
932
|
+
declare function boolean<const TMessage extends ErrorMessage<BooleanIssue> | undefined>(message: TMessage): BooleanSchema<TMessage>;
|
|
933
|
+
|
|
1041
934
|
/**
|
|
1042
|
-
*
|
|
935
|
+
* Class type.
|
|
1043
936
|
*/
|
|
1044
|
-
type
|
|
1045
|
-
[TKey in keyof TEntries]: TEntries[TKey] extends QuestionMarkSchema ? TKey : never;
|
|
1046
|
-
}[keyof TEntries];
|
|
937
|
+
type Class = new (...args: any[]) => any;
|
|
1047
938
|
/**
|
|
1048
|
-
*
|
|
939
|
+
* Instance issue type.
|
|
1049
940
|
*/
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
941
|
+
interface InstanceIssue extends BaseIssue<unknown> {
|
|
942
|
+
/**
|
|
943
|
+
* The issue kind.
|
|
944
|
+
*/
|
|
945
|
+
readonly kind: 'schema';
|
|
946
|
+
/**
|
|
947
|
+
* The issue type.
|
|
948
|
+
*/
|
|
949
|
+
readonly type: 'instance';
|
|
950
|
+
/**
|
|
951
|
+
* The expected property.
|
|
952
|
+
*/
|
|
953
|
+
readonly expected: string;
|
|
954
|
+
}
|
|
1053
955
|
/**
|
|
1054
|
-
*
|
|
956
|
+
* Instance schema type.
|
|
1055
957
|
*/
|
|
1056
|
-
|
|
958
|
+
interface InstanceSchema<TClass extends Class, TMessage extends ErrorMessage<InstanceIssue> | undefined> extends BaseSchema<InstanceType<TClass>, InstanceType<TClass>, InstanceIssue> {
|
|
959
|
+
/**
|
|
960
|
+
* The schema type.
|
|
961
|
+
*/
|
|
962
|
+
readonly type: 'instance';
|
|
963
|
+
/**
|
|
964
|
+
* The schema reference.
|
|
965
|
+
*/
|
|
966
|
+
readonly reference: typeof instance;
|
|
967
|
+
/**
|
|
968
|
+
* The class of the instance.
|
|
969
|
+
*/
|
|
970
|
+
readonly class: TClass;
|
|
971
|
+
/**
|
|
972
|
+
* The error message.
|
|
973
|
+
*/
|
|
974
|
+
readonly message: TMessage;
|
|
975
|
+
}
|
|
1057
976
|
/**
|
|
1058
|
-
*
|
|
977
|
+
* Creates an instance schema.
|
|
978
|
+
*
|
|
979
|
+
* @param class_ The class of the instance.
|
|
980
|
+
*
|
|
981
|
+
* @returns An instance schema.
|
|
1059
982
|
*/
|
|
1060
|
-
|
|
983
|
+
declare function instance<TClass extends Class>(class_: TClass): InstanceSchema<TClass, undefined>;
|
|
1061
984
|
/**
|
|
1062
|
-
*
|
|
985
|
+
* Creates an instance schema.
|
|
986
|
+
*
|
|
987
|
+
* @param class_ The class of the instance.
|
|
988
|
+
* @param message The error message.
|
|
989
|
+
*
|
|
990
|
+
* @returns An instance schema.
|
|
1063
991
|
*/
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
}[keyof TEntries];
|
|
992
|
+
declare function instance<TClass extends Class, const TMessage extends ErrorMessage<InstanceIssue> | undefined>(class_: TClass, message: TMessage): InstanceSchema<TClass, TMessage>;
|
|
993
|
+
|
|
1067
994
|
/**
|
|
1068
|
-
*
|
|
995
|
+
* Infer nullish output type.
|
|
1069
996
|
*/
|
|
1070
|
-
type
|
|
997
|
+
type InferNullishOutput<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, null | undefined>> = [TDefault] extends [never] ? InferOutput<TWrapped> | null | undefined : NonNullish<InferOutput<TWrapped>> | Extract<DefaultValue<TDefault>, null | undefined>;
|
|
998
|
+
|
|
1071
999
|
/**
|
|
1072
|
-
*
|
|
1000
|
+
* Nullish schema type.
|
|
1073
1001
|
*/
|
|
1074
|
-
|
|
1002
|
+
interface NullishSchema<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TDefault extends Default<TWrapped, null | undefined>> extends BaseSchema<InferInput<TWrapped> | null | undefined, InferNullishOutput<TWrapped, TDefault>, InferIssue<TWrapped>> {
|
|
1003
|
+
/**
|
|
1004
|
+
* The schema type.
|
|
1005
|
+
*/
|
|
1006
|
+
readonly type: 'nullish';
|
|
1007
|
+
/**
|
|
1008
|
+
* The schema reference.
|
|
1009
|
+
*/
|
|
1010
|
+
readonly reference: typeof nullish;
|
|
1011
|
+
/**
|
|
1012
|
+
* The expected property.
|
|
1013
|
+
*/
|
|
1014
|
+
readonly expects: `(${TWrapped['expects']} | null | undefined)`;
|
|
1015
|
+
/**
|
|
1016
|
+
* The wrapped schema.
|
|
1017
|
+
*/
|
|
1018
|
+
readonly wrapped: TWrapped;
|
|
1019
|
+
/**
|
|
1020
|
+
* The default value.
|
|
1021
|
+
*/
|
|
1022
|
+
readonly default: TDefault;
|
|
1023
|
+
}
|
|
1075
1024
|
/**
|
|
1076
|
-
*
|
|
1025
|
+
* Creates a nullish schema.
|
|
1026
|
+
*
|
|
1027
|
+
* @param wrapped The wrapped schema.
|
|
1028
|
+
*
|
|
1029
|
+
* @returns A nullish schema.
|
|
1077
1030
|
*/
|
|
1078
|
-
|
|
1031
|
+
declare function nullish<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): NullishSchema<TWrapped, never>;
|
|
1079
1032
|
/**
|
|
1080
|
-
*
|
|
1033
|
+
* Creates a nullish schema.
|
|
1034
|
+
*
|
|
1035
|
+
* @param wrapped The wrapped schema.
|
|
1036
|
+
* @param default_ The default value.
|
|
1037
|
+
*
|
|
1038
|
+
* @returns A nullish schema.
|
|
1081
1039
|
*/
|
|
1082
|
-
|
|
1040
|
+
declare function nullish<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TDefault extends Default<TWrapped, null | undefined>>(wrapped: TWrapped, default_: TDefault): NullishSchema<TWrapped, TDefault>;
|
|
1083
1041
|
|
|
1084
1042
|
/**
|
|
1085
|
-
*
|
|
1043
|
+
* Nullish schema async type.
|
|
1086
1044
|
*/
|
|
1087
|
-
interface
|
|
1045
|
+
interface NullishSchemaAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, null | undefined>> extends BaseSchemaAsync<InferInput<TWrapped> | null | undefined, InferNullishOutput<TWrapped, TDefault>, InferIssue<TWrapped>> {
|
|
1088
1046
|
/**
|
|
1089
|
-
* The
|
|
1047
|
+
* The schema type.
|
|
1090
1048
|
*/
|
|
1091
|
-
readonly type: '
|
|
1049
|
+
readonly type: 'nullish';
|
|
1092
1050
|
/**
|
|
1093
|
-
* The
|
|
1051
|
+
* The schema reference.
|
|
1094
1052
|
*/
|
|
1095
|
-
readonly
|
|
1053
|
+
readonly reference: typeof nullishAsync;
|
|
1096
1054
|
/**
|
|
1097
|
-
* The
|
|
1055
|
+
* The expected property.
|
|
1098
1056
|
*/
|
|
1099
|
-
readonly
|
|
1057
|
+
readonly expects: `(${TWrapped['expects']} | null | undefined)`;
|
|
1100
1058
|
/**
|
|
1101
|
-
* The
|
|
1059
|
+
* The wrapped schema.
|
|
1102
1060
|
*/
|
|
1103
|
-
readonly
|
|
1061
|
+
readonly wrapped: TWrapped;
|
|
1104
1062
|
/**
|
|
1105
|
-
* The
|
|
1063
|
+
* The default value.
|
|
1106
1064
|
*/
|
|
1107
|
-
readonly
|
|
1065
|
+
readonly default: TDefault;
|
|
1108
1066
|
}
|
|
1109
1067
|
/**
|
|
1110
|
-
*
|
|
1068
|
+
* Creates a nullish schema.
|
|
1069
|
+
*
|
|
1070
|
+
* @param wrapped The wrapped schema.
|
|
1071
|
+
*
|
|
1072
|
+
* @returns A nullish schema.
|
|
1073
|
+
*/
|
|
1074
|
+
declare function nullishAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): NullishSchemaAsync<TWrapped, never>;
|
|
1075
|
+
/**
|
|
1076
|
+
* Creates a nullish schema.
|
|
1077
|
+
*
|
|
1078
|
+
* @param wrapped The wrapped schema.
|
|
1079
|
+
* @param default_ The default value.
|
|
1080
|
+
*
|
|
1081
|
+
* @returns A nullish schema.
|
|
1111
1082
|
*/
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
* The path item origin.
|
|
1119
|
-
*/
|
|
1120
|
-
readonly origin: 'key' | 'value';
|
|
1083
|
+
declare function nullishAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, const TDefault extends DefaultAsync<TWrapped, null | undefined>>(wrapped: TWrapped, default_: TDefault): NullishSchemaAsync<TWrapped, TDefault>;
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* Object issue type.
|
|
1087
|
+
*/
|
|
1088
|
+
interface ObjectIssue extends BaseIssue<unknown> {
|
|
1121
1089
|
/**
|
|
1122
|
-
* The
|
|
1090
|
+
* The issue kind.
|
|
1123
1091
|
*/
|
|
1124
|
-
readonly
|
|
1092
|
+
readonly kind: 'schema';
|
|
1125
1093
|
/**
|
|
1126
|
-
* The
|
|
1094
|
+
* The issue type.
|
|
1127
1095
|
*/
|
|
1128
|
-
readonly
|
|
1096
|
+
readonly type: 'object';
|
|
1129
1097
|
/**
|
|
1130
|
-
* The
|
|
1098
|
+
* The expected property.
|
|
1131
1099
|
*/
|
|
1132
|
-
readonly
|
|
1100
|
+
readonly expected: 'Object';
|
|
1133
1101
|
}
|
|
1102
|
+
|
|
1134
1103
|
/**
|
|
1135
|
-
* Object
|
|
1104
|
+
* Object schema type.
|
|
1136
1105
|
*/
|
|
1137
|
-
interface
|
|
1106
|
+
interface ObjectSchema<TEntries extends ObjectEntries, TMessage extends ErrorMessage<ObjectIssue> | undefined> extends BaseSchema<InferObjectInput<TEntries>, InferObjectOutput<TEntries>, ObjectIssue | InferObjectIssue<TEntries>> {
|
|
1138
1107
|
/**
|
|
1139
|
-
* The
|
|
1108
|
+
* The schema type.
|
|
1140
1109
|
*/
|
|
1141
1110
|
readonly type: 'object';
|
|
1142
1111
|
/**
|
|
1143
|
-
* The
|
|
1112
|
+
* The schema reference.
|
|
1144
1113
|
*/
|
|
1145
|
-
readonly
|
|
1114
|
+
readonly reference: typeof object;
|
|
1146
1115
|
/**
|
|
1147
|
-
* The
|
|
1116
|
+
* The expected property.
|
|
1148
1117
|
*/
|
|
1149
|
-
readonly
|
|
1118
|
+
readonly expects: 'Object';
|
|
1150
1119
|
/**
|
|
1151
|
-
* The
|
|
1120
|
+
* The entries schema.
|
|
1152
1121
|
*/
|
|
1153
|
-
readonly
|
|
1122
|
+
readonly entries: TEntries;
|
|
1154
1123
|
/**
|
|
1155
|
-
* The
|
|
1124
|
+
* The error message.
|
|
1156
1125
|
*/
|
|
1157
|
-
readonly
|
|
1126
|
+
readonly message: TMessage;
|
|
1158
1127
|
}
|
|
1159
1128
|
/**
|
|
1160
|
-
*
|
|
1129
|
+
* Creates an object schema.
|
|
1130
|
+
*
|
|
1131
|
+
* Hint: This schema removes unknown entries. The output will only include the
|
|
1132
|
+
* entries you specify. To include unknown entries, use `looseObject`. To
|
|
1133
|
+
* return an issue for unknown entries, use `strictObject`. To include and
|
|
1134
|
+
* validate unknown entries, use `objectWithRest`.
|
|
1135
|
+
*
|
|
1136
|
+
* @param entries The entries schema.
|
|
1137
|
+
*
|
|
1138
|
+
* @returns An object schema.
|
|
1161
1139
|
*/
|
|
1162
|
-
|
|
1140
|
+
declare function object<const TEntries extends ObjectEntries>(entries: TEntries): ObjectSchema<TEntries, undefined>;
|
|
1141
|
+
/**
|
|
1142
|
+
* Creates an object schema.
|
|
1143
|
+
*
|
|
1144
|
+
* Hint: This schema removes unknown entries. The output will only include the
|
|
1145
|
+
* entries you specify. To include unknown entries, use `looseObject`. To
|
|
1146
|
+
* return an issue for unknown entries, use `strictObject`. To include and
|
|
1147
|
+
* validate unknown entries, use `objectWithRest`.
|
|
1148
|
+
*
|
|
1149
|
+
* @param entries The entries schema.
|
|
1150
|
+
* @param message The error message.
|
|
1151
|
+
*
|
|
1152
|
+
* @returns An object schema.
|
|
1153
|
+
*/
|
|
1154
|
+
declare function object<const TEntries extends ObjectEntries, const TMessage extends ErrorMessage<ObjectIssue> | undefined>(entries: TEntries, message: TMessage): ObjectSchema<TEntries, TMessage>;
|
|
1155
|
+
|
|
1156
|
+
/**
|
|
1157
|
+
* Infer optional output type.
|
|
1158
|
+
*/
|
|
1159
|
+
type InferOptionalOutput<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, undefined>> = [TDefault] extends [never] ? InferOutput<TWrapped> | undefined : NonOptional<InferOutput<TWrapped>> | Extract<DefaultValue<TDefault>, undefined>;
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* Optional schema type.
|
|
1163
|
+
*/
|
|
1164
|
+
interface OptionalSchema<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TDefault extends Default<TWrapped, undefined>> extends BaseSchema<InferInput<TWrapped> | undefined, InferOptionalOutput<TWrapped, TDefault>, InferIssue<TWrapped>> {
|
|
1163
1165
|
/**
|
|
1164
|
-
* The
|
|
1166
|
+
* The schema type.
|
|
1165
1167
|
*/
|
|
1166
|
-
readonly type: '
|
|
1168
|
+
readonly type: 'optional';
|
|
1167
1169
|
/**
|
|
1168
|
-
* The
|
|
1170
|
+
* The schema reference.
|
|
1169
1171
|
*/
|
|
1170
|
-
readonly
|
|
1172
|
+
readonly reference: typeof optional;
|
|
1171
1173
|
/**
|
|
1172
|
-
* The
|
|
1174
|
+
* The expected property.
|
|
1173
1175
|
*/
|
|
1174
|
-
readonly
|
|
1176
|
+
readonly expects: `(${TWrapped['expects']} | undefined)`;
|
|
1175
1177
|
/**
|
|
1176
|
-
* The
|
|
1178
|
+
* The wrapped schema.
|
|
1177
1179
|
*/
|
|
1178
|
-
readonly
|
|
1180
|
+
readonly wrapped: TWrapped;
|
|
1179
1181
|
/**
|
|
1180
|
-
* The
|
|
1182
|
+
* The default value.
|
|
1181
1183
|
*/
|
|
1182
|
-
readonly
|
|
1184
|
+
readonly default: TDefault;
|
|
1183
1185
|
}
|
|
1184
1186
|
/**
|
|
1185
|
-
*
|
|
1187
|
+
* Creates a optional schema.
|
|
1188
|
+
*
|
|
1189
|
+
* @param wrapped The wrapped schema.
|
|
1190
|
+
*
|
|
1191
|
+
* @returns A optional schema.
|
|
1186
1192
|
*/
|
|
1187
|
-
|
|
1193
|
+
declare function optional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): OptionalSchema<TWrapped, never>;
|
|
1194
|
+
/**
|
|
1195
|
+
* Creates a optional schema.
|
|
1196
|
+
*
|
|
1197
|
+
* @param wrapped The wrapped schema.
|
|
1198
|
+
* @param default_ The default value.
|
|
1199
|
+
*
|
|
1200
|
+
* @returns A optional schema.
|
|
1201
|
+
*/
|
|
1202
|
+
declare function optional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TDefault extends Default<TWrapped, undefined>>(wrapped: TWrapped, default_: TDefault): OptionalSchema<TWrapped, TDefault>;
|
|
1203
|
+
|
|
1204
|
+
/**
|
|
1205
|
+
* Optional schema async type.
|
|
1206
|
+
*/
|
|
1207
|
+
interface OptionalSchemaAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, undefined>> extends BaseSchemaAsync<InferInput<TWrapped> | undefined, InferOptionalOutput<TWrapped, TDefault>, InferIssue<TWrapped>> {
|
|
1188
1208
|
/**
|
|
1189
|
-
* The
|
|
1209
|
+
* The schema type.
|
|
1190
1210
|
*/
|
|
1191
|
-
readonly type: '
|
|
1211
|
+
readonly type: 'optional';
|
|
1192
1212
|
/**
|
|
1193
|
-
* The
|
|
1213
|
+
* The schema reference.
|
|
1194
1214
|
*/
|
|
1195
|
-
readonly
|
|
1215
|
+
readonly reference: typeof optionalAsync;
|
|
1196
1216
|
/**
|
|
1197
|
-
* The
|
|
1217
|
+
* The expected property.
|
|
1198
1218
|
*/
|
|
1199
|
-
readonly
|
|
1219
|
+
readonly expects: `(${TWrapped['expects']} | undefined)`;
|
|
1200
1220
|
/**
|
|
1201
|
-
* The
|
|
1221
|
+
* The wrapped schema.
|
|
1202
1222
|
*/
|
|
1203
|
-
readonly
|
|
1223
|
+
readonly wrapped: TWrapped;
|
|
1204
1224
|
/**
|
|
1205
|
-
* The
|
|
1225
|
+
* The default value.
|
|
1206
1226
|
*/
|
|
1207
|
-
readonly
|
|
1227
|
+
readonly default: TDefault;
|
|
1208
1228
|
}
|
|
1209
1229
|
/**
|
|
1210
|
-
*
|
|
1230
|
+
* Creates an optional schema.
|
|
1211
1231
|
*
|
|
1212
|
-
*
|
|
1213
|
-
*
|
|
1232
|
+
* @param wrapped The wrapped schema.
|
|
1233
|
+
*
|
|
1234
|
+
* @returns An optional schema.
|
|
1214
1235
|
*/
|
|
1215
|
-
|
|
1236
|
+
declare function optionalAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): OptionalSchemaAsync<TWrapped, never>;
|
|
1216
1237
|
/**
|
|
1217
|
-
*
|
|
1238
|
+
* Creates an optional schema.
|
|
1239
|
+
*
|
|
1240
|
+
* @param wrapped The wrapped schema.
|
|
1241
|
+
* @param default_ The default value.
|
|
1242
|
+
*
|
|
1243
|
+
* @returns An optional schema.
|
|
1218
1244
|
*/
|
|
1219
|
-
|
|
1245
|
+
declare function optionalAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, const TDefault extends DefaultAsync<TWrapped, undefined>>(wrapped: TWrapped, default_: TDefault): OptionalSchemaAsync<TWrapped, TDefault>;
|
|
1246
|
+
|
|
1247
|
+
/**
|
|
1248
|
+
* String issue type.
|
|
1249
|
+
*/
|
|
1250
|
+
interface StringIssue extends BaseIssue<unknown> {
|
|
1220
1251
|
/**
|
|
1221
1252
|
* The issue kind.
|
|
1222
1253
|
*/
|
|
1223
|
-
readonly kind: 'schema'
|
|
1254
|
+
readonly kind: 'schema';
|
|
1224
1255
|
/**
|
|
1225
1256
|
* The issue type.
|
|
1226
1257
|
*/
|
|
1227
|
-
readonly type: string;
|
|
1228
|
-
/**
|
|
1229
|
-
* The raw input data.
|
|
1230
|
-
*/
|
|
1231
|
-
readonly input: TInput;
|
|
1258
|
+
readonly type: 'string';
|
|
1232
1259
|
/**
|
|
1233
1260
|
* The expected property.
|
|
1234
1261
|
*/
|
|
1235
|
-
readonly expected: string
|
|
1236
|
-
/**
|
|
1237
|
-
* The received property.
|
|
1238
|
-
*/
|
|
1239
|
-
readonly received: string;
|
|
1240
|
-
/**
|
|
1241
|
-
* The error message.
|
|
1242
|
-
*/
|
|
1243
|
-
readonly message: string;
|
|
1244
|
-
/**
|
|
1245
|
-
* The input requirement.
|
|
1246
|
-
*/
|
|
1247
|
-
readonly requirement?: unknown | undefined;
|
|
1248
|
-
/**
|
|
1249
|
-
* The issue path.
|
|
1250
|
-
*
|
|
1251
|
-
* TODO: Investigate if it is possible to make the path type safe based on the
|
|
1252
|
-
* input.
|
|
1253
|
-
*/
|
|
1254
|
-
readonly path?: [IssuePathItem, ...IssuePathItem[]] | undefined;
|
|
1255
|
-
/**
|
|
1256
|
-
* The sub issues.
|
|
1257
|
-
*/
|
|
1258
|
-
readonly issues?: [BaseIssue<TInput>, ...BaseIssue<TInput>[]] | undefined;
|
|
1262
|
+
readonly expected: 'string';
|
|
1259
1263
|
}
|
|
1260
|
-
|
|
1261
1264
|
/**
|
|
1262
|
-
*
|
|
1265
|
+
* String schema type.
|
|
1263
1266
|
*/
|
|
1264
|
-
interface
|
|
1267
|
+
interface StringSchema<TMessage extends ErrorMessage<StringIssue> | undefined> extends BaseSchema<string, string, StringIssue> {
|
|
1265
1268
|
/**
|
|
1266
|
-
* The
|
|
1269
|
+
* The schema type.
|
|
1267
1270
|
*/
|
|
1268
|
-
readonly
|
|
1271
|
+
readonly type: 'string';
|
|
1269
1272
|
/**
|
|
1270
|
-
* The
|
|
1273
|
+
* The schema reference.
|
|
1271
1274
|
*/
|
|
1272
|
-
readonly
|
|
1275
|
+
readonly reference: typeof string;
|
|
1273
1276
|
/**
|
|
1274
|
-
*
|
|
1277
|
+
* The expected property.
|
|
1275
1278
|
*/
|
|
1276
|
-
readonly
|
|
1279
|
+
readonly expects: 'string';
|
|
1277
1280
|
/**
|
|
1278
|
-
*
|
|
1281
|
+
* The error message.
|
|
1279
1282
|
*/
|
|
1280
|
-
readonly
|
|
1283
|
+
readonly message: TMessage;
|
|
1281
1284
|
}
|
|
1282
|
-
|
|
1283
|
-
/**
|
|
1284
|
-
* Pipe action type.
|
|
1285
|
-
*/
|
|
1286
|
-
type PipeAction<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidation<TInput, TOutput, TIssue> | BaseTransformation<TInput, TOutput, TIssue> | BaseMetadata<TInput>;
|
|
1287
|
-
/**
|
|
1288
|
-
* Pipe action async type.
|
|
1289
|
-
*/
|
|
1290
|
-
type PipeActionAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidationAsync<TInput, TOutput, TIssue> | BaseTransformationAsync<TInput, TOutput, TIssue>;
|
|
1291
1285
|
/**
|
|
1292
|
-
*
|
|
1286
|
+
* Creates a string schema.
|
|
1287
|
+
*
|
|
1288
|
+
* @returns A string schema.
|
|
1293
1289
|
*/
|
|
1294
|
-
|
|
1290
|
+
declare function string(): StringSchema<undefined>;
|
|
1295
1291
|
/**
|
|
1296
|
-
*
|
|
1292
|
+
* Creates a string schema.
|
|
1293
|
+
*
|
|
1294
|
+
* @param message The error message.
|
|
1295
|
+
*
|
|
1296
|
+
* @returns A string schema.
|
|
1297
1297
|
*/
|
|
1298
|
-
|
|
1298
|
+
declare function string<const TMessage extends ErrorMessage<StringIssue> | undefined>(message: TMessage): StringSchema<TMessage>;
|
|
1299
1299
|
|
|
1300
1300
|
/**
|
|
1301
1301
|
* Readonly action type.
|