valrs 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/dist/v.d.ts ADDED
@@ -0,0 +1,1382 @@
1
+ /**
2
+ * Zod-compatible fluent API for valrs.
3
+ *
4
+ * This module provides a `v` namespace with schema builders that mirror
5
+ * Zod's API while maintaining Standard Schema compliance.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { v } from 'valrs';
10
+ *
11
+ * // Create schemas
12
+ * const userSchema = v.object({
13
+ * name: v.string(),
14
+ * age: v.number(),
15
+ * });
16
+ *
17
+ * // Parse data
18
+ * const user = userSchema.parse({ name: 'Alice', age: 30 });
19
+ *
20
+ * // Infer types
21
+ * type User = v.infer<typeof userSchema>;
22
+ * ```
23
+ */
24
+ import type { StandardSchemaV1 } from './types';
25
+ import { ValSchema, ValArray, ValUnion, ValIntersection, ValPreprocessed } from './schema';
26
+ import { stream, streamLines, createMockStream, createChunkedStream } from './streaming';
27
+ export type { StreamOptions, StreamResult, StreamError, StreamResultWithErrors, StreamInput, } from './streaming';
28
+ export type { SafeParseResult, SafeParseSuccess, SafeParseError, } from './schema';
29
+ export { ValSchema } from './schema';
30
+ export { isSafeParseSuccess, isSafeParseError } from './schema';
31
+ import { ValError as ValErrorClass, setErrorMap as setErrorMapFn, getErrorMap as getErrorMapFn, resetErrorMap as resetErrorMapFn, getTypeName, createInvalidTypeIssue, createTooSmallIssue, createTooBigIssue, createInvalidStringIssue, createInvalidEnumValueIssue, createInvalidUnionIssue, createUnrecognizedKeysIssue, createCustomIssue, createInvalidLiteralIssue, createNotMultipleOfIssue, createNotFiniteIssue, createInvalidDateIssue } from './error';
32
+ export declare const ValError: typeof ValErrorClass;
33
+ export declare const setErrorMap: typeof setErrorMapFn;
34
+ export declare const getErrorMap: typeof getErrorMapFn;
35
+ export declare const resetErrorMap: typeof resetErrorMapFn;
36
+ export { getTypeName, createInvalidTypeIssue, createTooSmallIssue, createTooBigIssue, createInvalidStringIssue, createInvalidEnumValueIssue, createInvalidUnionIssue, createUnrecognizedKeysIssue, createCustomIssue, createInvalidLiteralIssue, createNotMultipleOfIssue, createNotFiniteIssue, createInvalidDateIssue, };
37
+ export type { ValIssueCode, ValIssueBase, ValIssue, InvalidTypeIssue, TooSmallIssue, TooBigIssue, InvalidStringIssue, InvalidEnumValueIssue, InvalidUnionIssue, CustomIssue, SizeType, ErrorMapFn, ErrorMapContext, FormattedError, FlattenedError, } from './error';
38
+ /**
39
+ * Infers the output type from a schema.
40
+ *
41
+ * This is the primary type inference utility, matching Zod's `z.infer`.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const schema = v.string();
46
+ * type MyString = v.infer<typeof schema>; // string
47
+ * ```
48
+ */
49
+ export type Infer<T extends ValSchema<unknown, unknown>> = T extends ValSchema<unknown, infer O> ? O : never;
50
+ export type infer<T extends ValSchema<unknown, unknown>> = Infer<T>;
51
+ /**
52
+ * Infers the input type from a schema.
53
+ *
54
+ * Use this when the input type differs from the output type
55
+ * (e.g., with coercion or transforms).
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const schema = v.coerce.number();
60
+ * type Input = v.input<typeof schema>; // unknown
61
+ * type Output = v.output<typeof schema>; // number
62
+ * ```
63
+ */
64
+ export type input<T extends ValSchema<unknown, unknown>> = T extends ValSchema<infer I, unknown> ? I : never;
65
+ /**
66
+ * Infers the output type from a schema.
67
+ *
68
+ * Alias for `v.infer` for symmetry with `v.input`.
69
+ */
70
+ export type output<T extends ValSchema<unknown, unknown>> = Infer<T>;
71
+ type StringValidator = (value: string) => {
72
+ issues: Array<{
73
+ message: string;
74
+ }>;
75
+ } | null;
76
+ type StringTransform = (value: string) => string;
77
+ /**
78
+ * Schema for string values with validation and transformation methods.
79
+ *
80
+ * Supports chainable methods like `.min()`, `.max()`, `.email()`, `.url()`, etc.
81
+ * Each method returns a new schema instance (immutable).
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const emailSchema = v.string().email();
86
+ * const usernameSchema = v.string().min(3).max(20);
87
+ * const normalizedSchema = v.string().trim().toLowerCase();
88
+ * ```
89
+ */
90
+ export declare class ValString extends ValSchema<string, string> {
91
+ private readonly validators;
92
+ private readonly transforms;
93
+ constructor(validators?: ReadonlyArray<StringValidator>, transforms?: ReadonlyArray<StringTransform>);
94
+ /**
95
+ * Creates a copy of this schema with additional validators/transforms.
96
+ */
97
+ private clone;
98
+ /**
99
+ * Requires string to be at least `length` characters.
100
+ */
101
+ min(length: number, message?: string): ValString;
102
+ /**
103
+ * Requires string to be at most `length` characters.
104
+ */
105
+ max(length: number, message?: string): ValString;
106
+ /**
107
+ * Requires string to be exactly `len` characters.
108
+ */
109
+ length(len: number, message?: string): ValString;
110
+ /**
111
+ * Validates that the string is a valid email address.
112
+ */
113
+ email(message?: string): ValString;
114
+ /**
115
+ * Validates that the string is a valid URL.
116
+ */
117
+ url(message?: string): ValString;
118
+ /**
119
+ * Validates that the string is a valid UUID.
120
+ */
121
+ uuid(message?: string): ValString;
122
+ /**
123
+ * Validates that the string is a valid CUID.
124
+ */
125
+ cuid(message?: string): ValString;
126
+ /**
127
+ * Validates that the string is a valid CUID2.
128
+ */
129
+ cuid2(message?: string): ValString;
130
+ /**
131
+ * Validates that the string is a valid ULID.
132
+ */
133
+ ulid(message?: string): ValString;
134
+ /**
135
+ * Validates that the string matches the provided regex pattern.
136
+ */
137
+ regex(pattern: RegExp, message?: string): ValString;
138
+ /**
139
+ * Validates that the string is a valid ISO 8601 datetime.
140
+ */
141
+ datetime(message?: string): ValString;
142
+ /**
143
+ * Validates that the string is a valid IP address (v4 or v6).
144
+ */
145
+ ip(message?: string): ValString;
146
+ /**
147
+ * Validates that the string includes the specified substring.
148
+ */
149
+ includes(needle: string, message?: string): ValString;
150
+ /**
151
+ * Validates that the string starts with the specified prefix.
152
+ */
153
+ startsWith(prefix: string, message?: string): ValString;
154
+ /**
155
+ * Validates that the string ends with the specified suffix.
156
+ */
157
+ endsWith(suffix: string, message?: string): ValString;
158
+ /**
159
+ * Trims whitespace from both ends of the string.
160
+ */
161
+ trim(): ValString;
162
+ /**
163
+ * Converts the string to lowercase.
164
+ */
165
+ toLowerCase(): ValString;
166
+ /**
167
+ * Converts the string to uppercase.
168
+ */
169
+ toUpperCase(): ValString;
170
+ }
171
+ type NumberValidator = (value: number) => {
172
+ issues: Array<{
173
+ message: string;
174
+ }>;
175
+ } | null;
176
+ /**
177
+ * Schema for number values with validation methods.
178
+ *
179
+ * Supports chainable methods like `.gt()`, `.gte()`, `.int()`, `.positive()`, etc.
180
+ * Each method returns a new schema instance (immutable).
181
+ *
182
+ * @example
183
+ * ```typescript
184
+ * const ageSchema = v.number().int().positive();
185
+ * const priceSchema = v.number().gte(0).lte(1000);
186
+ * const percentSchema = v.number().gte(0).lte(100);
187
+ * ```
188
+ */
189
+ export declare class ValNumber extends ValSchema<number, number> {
190
+ private readonly validators;
191
+ constructor(validators?: ReadonlyArray<NumberValidator>);
192
+ /**
193
+ * Creates a copy of this schema with additional validators.
194
+ */
195
+ private clone;
196
+ /**
197
+ * Requires number to be greater than `value`.
198
+ */
199
+ gt(value: number, message?: string): ValNumber;
200
+ /**
201
+ * Requires number to be greater than or equal to `value`.
202
+ */
203
+ gte(value: number, message?: string): ValNumber;
204
+ /**
205
+ * Alias for `gte()`.
206
+ */
207
+ min(value: number, message?: string): ValNumber;
208
+ /**
209
+ * Requires number to be less than `value`.
210
+ */
211
+ lt(value: number, message?: string): ValNumber;
212
+ /**
213
+ * Requires number to be less than or equal to `value`.
214
+ */
215
+ lte(value: number, message?: string): ValNumber;
216
+ /**
217
+ * Alias for `lte()`.
218
+ */
219
+ max(value: number, message?: string): ValNumber;
220
+ /**
221
+ * Requires number to be an integer.
222
+ */
223
+ int(message?: string): ValNumber;
224
+ /**
225
+ * Requires number to be positive (> 0).
226
+ */
227
+ positive(message?: string): ValNumber;
228
+ /**
229
+ * Requires number to be non-negative (>= 0).
230
+ */
231
+ nonnegative(message?: string): ValNumber;
232
+ /**
233
+ * Requires number to be negative (< 0).
234
+ */
235
+ negative(message?: string): ValNumber;
236
+ /**
237
+ * Requires number to be non-positive (<= 0).
238
+ */
239
+ nonpositive(message?: string): ValNumber;
240
+ /**
241
+ * Requires number to be a multiple of `value`.
242
+ *
243
+ * Uses tolerance-based comparison to handle floating point precision issues.
244
+ */
245
+ multipleOf(value: number, message?: string): ValNumber;
246
+ /**
247
+ * Alias for `multipleOf()`.
248
+ */
249
+ step(value: number, message?: string): ValNumber;
250
+ /**
251
+ * Requires number to be finite (not Infinity or -Infinity).
252
+ */
253
+ finite(message?: string): ValNumber;
254
+ /**
255
+ * Requires number to be a safe integer (within Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER).
256
+ */
257
+ safe(message?: string): ValNumber;
258
+ }
259
+ /**
260
+ * Schema for bigint values.
261
+ *
262
+ * Validates that the input is a JavaScript BigInt.
263
+ */
264
+ export declare class ValBigInt extends ValSchema<bigint, bigint> {
265
+ constructor();
266
+ }
267
+ /**
268
+ * Schema for boolean values.
269
+ */
270
+ export declare class ValBoolean extends ValSchema<boolean, boolean> {
271
+ constructor();
272
+ }
273
+ /**
274
+ * Schema for Date values.
275
+ *
276
+ * Validates that the input is a valid Date object (not Invalid Date).
277
+ */
278
+ export declare class ValDate extends ValSchema<Date, Date> {
279
+ constructor();
280
+ }
281
+ /**
282
+ * Schema for undefined values.
283
+ */
284
+ export declare class ValUndefined extends ValSchema<undefined, undefined> {
285
+ constructor();
286
+ isOptional(): boolean;
287
+ }
288
+ /**
289
+ * Schema for null values.
290
+ */
291
+ export declare class ValNull extends ValSchema<null, null> {
292
+ constructor();
293
+ isNullable(): boolean;
294
+ }
295
+ /**
296
+ * Schema for void (undefined).
297
+ *
298
+ * Alias for undefined schema, matching Zod's behavior.
299
+ */
300
+ export declare class ValVoid extends ValSchema<void, void> {
301
+ constructor();
302
+ }
303
+ /**
304
+ * Schema that accepts any value.
305
+ *
306
+ * Use sparingly - prefer more specific schemas when possible.
307
+ */
308
+ export declare class ValAny extends ValSchema<any, any> {
309
+ constructor();
310
+ }
311
+ /**
312
+ * Schema that accepts any value as unknown.
313
+ *
314
+ * Unlike `any`, `unknown` requires type narrowing before use.
315
+ */
316
+ export declare class ValUnknown extends ValSchema<unknown, unknown> {
317
+ constructor();
318
+ }
319
+ /**
320
+ * Schema that never validates successfully.
321
+ *
322
+ * Useful for exhaustive type checking and unreachable code paths.
323
+ */
324
+ export declare class ValNever extends ValSchema<never, never> {
325
+ constructor();
326
+ }
327
+ /**
328
+ * Schema for 32-bit signed integers.
329
+ */
330
+ export declare class ValInt32 extends ValSchema<number, number> {
331
+ constructor();
332
+ }
333
+ /**
334
+ * Schema for 64-bit signed integers.
335
+ */
336
+ export declare class ValInt64 extends ValSchema<number, number> {
337
+ constructor();
338
+ }
339
+ /**
340
+ * Schema for 32-bit unsigned integers.
341
+ */
342
+ export declare class ValUint32 extends ValSchema<number, number> {
343
+ constructor();
344
+ }
345
+ /**
346
+ * Schema for 64-bit unsigned integers.
347
+ */
348
+ export declare class ValUint64 extends ValSchema<number, number> {
349
+ constructor();
350
+ }
351
+ /**
352
+ * Schema for 32-bit floating point numbers.
353
+ */
354
+ export declare class ValFloat32 extends ValSchema<number, number> {
355
+ constructor();
356
+ }
357
+ /**
358
+ * Schema for 64-bit floating point numbers.
359
+ */
360
+ export declare class ValFloat64 extends ValSchema<number, number> {
361
+ constructor();
362
+ }
363
+ /**
364
+ * A shape is a record of string keys to ValSchema instances.
365
+ */
366
+ type Shape = Record<string, ValSchema<unknown, unknown>>;
367
+ /**
368
+ * Infers the input type from a shape definition.
369
+ */
370
+ type InferShapeInput<T extends Shape> = {
371
+ [K in keyof T]: T[K] extends ValSchema<infer I, unknown> ? I : never;
372
+ };
373
+ /**
374
+ * Infers the output type from a shape definition.
375
+ */
376
+ type InferShapeOutput<T extends Shape> = {
377
+ [K in keyof T]: T[K] extends ValSchema<unknown, infer O> ? O : never;
378
+ };
379
+ /**
380
+ * Gets the keys that are optional in a shape (schemas that accept undefined).
381
+ */
382
+ type OptionalKeys<T extends Shape> = {
383
+ [K in keyof T]: undefined extends InferShapeOutput<T>[K] ? K : never;
384
+ }[keyof T];
385
+ /**
386
+ * Gets the keys that are required in a shape.
387
+ */
388
+ type RequiredKeys<T extends Shape> = Exclude<keyof T, OptionalKeys<T>>;
389
+ /**
390
+ * Builds the proper object type with optional keys marked with ?.
391
+ */
392
+ type BuildObjectType<T extends Shape> = {
393
+ [K in RequiredKeys<T>]: InferShapeOutput<T>[K];
394
+ } & {
395
+ [K in OptionalKeys<T>]?: InferShapeOutput<T>[K];
396
+ };
397
+ /**
398
+ * Flatten intersection types for better readability.
399
+ */
400
+ type Flatten<T> = {
401
+ [K in keyof T]: T[K];
402
+ } & {};
403
+ /**
404
+ * Unknown key handling mode for object schemas.
405
+ */
406
+ type UnknownKeyMode = 'strip' | 'strict' | 'passthrough';
407
+ /**
408
+ * Schema for object values with a defined shape.
409
+ *
410
+ * Supports validation of each property, unknown key handling, and various
411
+ * transformation methods like pick, omit, partial, extend, etc.
412
+ *
413
+ * @template T - The shape definition (record of property schemas)
414
+ *
415
+ * @example
416
+ * ```typescript
417
+ * const User = v.object({
418
+ * name: v.string(),
419
+ * age: v.number().int().positive(),
420
+ * email: v.string().email().optional(),
421
+ * });
422
+ *
423
+ * type User = v.infer<typeof User>;
424
+ * // { name: string; age: number; email?: string }
425
+ *
426
+ * User.parse({ name: 'Alice', age: 30 });
427
+ * ```
428
+ */
429
+ export declare class ValObject<T extends Shape> extends ValSchema<Flatten<InferShapeInput<T>>, Flatten<BuildObjectType<T>>> {
430
+ /**
431
+ * The shape definition containing all property schemas.
432
+ */
433
+ readonly shape: T;
434
+ private readonly unknownKeyMode;
435
+ private readonly catchallSchema;
436
+ constructor(shape: T, unknownKeyMode?: UnknownKeyMode, catchallSchema?: ValSchema<unknown, unknown> | null);
437
+ /**
438
+ * Extends the object schema with additional properties.
439
+ *
440
+ * @param augmentation - Additional property schemas to add
441
+ * @returns A new object schema with the combined shape
442
+ *
443
+ * @example
444
+ * ```typescript
445
+ * const User = v.object({ name: v.string() });
446
+ * const Admin = User.extend({ role: v.string() });
447
+ * // { name: string; role: string }
448
+ * ```
449
+ */
450
+ extend<U extends Shape>(augmentation: U): ValObject<Flatten<T & U>>;
451
+ /**
452
+ * Merges this object schema with another object schema.
453
+ *
454
+ * Properties from the other schema override properties in this schema.
455
+ *
456
+ * @param other - Another object schema to merge with
457
+ * @returns A new object schema with the merged shape
458
+ *
459
+ * @example
460
+ * ```typescript
461
+ * const A = v.object({ a: v.string(), shared: v.number() });
462
+ * const B = v.object({ b: v.boolean(), shared: v.string() });
463
+ * const Merged = A.merge(B);
464
+ * // { a: string; b: boolean; shared: string }
465
+ * ```
466
+ */
467
+ merge<U extends Shape>(other: ValObject<U>): ValObject<Flatten<T & U>>;
468
+ /**
469
+ * Creates a new schema with only the specified keys.
470
+ *
471
+ * @param mask - An object with keys to pick (values should be true)
472
+ * @returns A new object schema with only the picked keys
473
+ *
474
+ * @example
475
+ * ```typescript
476
+ * const User = v.object({ name: v.string(), age: v.number(), email: v.string() });
477
+ * const NameOnly = User.pick({ name: true });
478
+ * // { name: string }
479
+ * ```
480
+ */
481
+ pick<K extends keyof T>(mask: {
482
+ [key in K]: true;
483
+ }): ValObject<Pick<T, K>>;
484
+ /**
485
+ * Creates a new schema without the specified keys.
486
+ *
487
+ * @param mask - An object with keys to omit (values should be true)
488
+ * @returns A new object schema without the omitted keys
489
+ *
490
+ * @example
491
+ * ```typescript
492
+ * const User = v.object({ name: v.string(), age: v.number(), email: v.string() });
493
+ * const WithoutEmail = User.omit({ email: true });
494
+ * // { name: string; age: number }
495
+ * ```
496
+ */
497
+ omit<K extends keyof T>(mask: {
498
+ [key in K]: true;
499
+ }): ValObject<Omit<T, K>>;
500
+ /**
501
+ * Makes all properties optional.
502
+ *
503
+ * @returns A new object schema where all properties are optional
504
+ *
505
+ * @example
506
+ * ```typescript
507
+ * const User = v.object({ name: v.string(), age: v.number() });
508
+ * const PartialUser = User.partial();
509
+ * // { name?: string; age?: number }
510
+ * ```
511
+ */
512
+ partial(): ValObject<{
513
+ [K in keyof T]: ReturnType<T[K]['optional']>;
514
+ }>;
515
+ /**
516
+ * Makes all properties deeply optional (recursive).
517
+ *
518
+ * For nested objects, this recursively applies partial().
519
+ *
520
+ * @returns A new object schema where all properties are deeply optional
521
+ *
522
+ * @example
523
+ * ```typescript
524
+ * const User = v.object({
525
+ * name: v.string(),
526
+ * address: v.object({ city: v.string(), zip: v.string() }),
527
+ * });
528
+ * const DeepPartialUser = User.deepPartial();
529
+ * // { name?: string; address?: { city?: string; zip?: string } }
530
+ * ```
531
+ */
532
+ deepPartial(): ValObject<{
533
+ [K in keyof T]: ReturnType<T[K]['optional']>;
534
+ }>;
535
+ /**
536
+ * Makes all properties required (removes optional).
537
+ *
538
+ * @returns A new object schema where all properties are required
539
+ *
540
+ * @example
541
+ * ```typescript
542
+ * const PartialUser = v.object({ name: v.string().optional(), age: v.number().optional() });
543
+ * const User = PartialUser.required();
544
+ * // { name: string; age: number }
545
+ * ```
546
+ */
547
+ required(): ValObject<{
548
+ [K in keyof T]: ValSchema<unknown, Exclude<InferShapeOutput<T>[K], undefined>>;
549
+ }>;
550
+ /**
551
+ * Allows unknown keys to pass through without validation.
552
+ *
553
+ * @returns A new object schema that preserves unknown keys
554
+ *
555
+ * @example
556
+ * ```typescript
557
+ * const User = v.object({ name: v.string() }).passthrough();
558
+ * User.parse({ name: 'Alice', extra: 'value' });
559
+ * // { name: 'Alice', extra: 'value' }
560
+ * ```
561
+ */
562
+ passthrough(): ValObject<T>;
563
+ /**
564
+ * Rejects any unknown keys (throws validation error).
565
+ *
566
+ * @returns A new object schema that rejects unknown keys
567
+ *
568
+ * @example
569
+ * ```typescript
570
+ * const User = v.object({ name: v.string() }).strict();
571
+ * User.parse({ name: 'Alice', extra: 'value' }); // throws
572
+ * ```
573
+ */
574
+ strict(): ValObject<T>;
575
+ /**
576
+ * Silently removes unknown keys (default behavior).
577
+ *
578
+ * @returns A new object schema that strips unknown keys
579
+ *
580
+ * @example
581
+ * ```typescript
582
+ * const User = v.object({ name: v.string() }).strip();
583
+ * User.parse({ name: 'Alice', extra: 'value' });
584
+ * // { name: 'Alice' }
585
+ * ```
586
+ */
587
+ strip(): ValObject<T>;
588
+ /**
589
+ * Validates unknown keys with the provided schema.
590
+ *
591
+ * @param schema - Schema to validate unknown keys with
592
+ * @returns A new object schema that validates unknown keys
593
+ *
594
+ * @example
595
+ * ```typescript
596
+ * const Metadata = v.object({ id: v.string() }).catchall(v.number());
597
+ * Metadata.parse({ id: 'abc', count: 42, score: 100 });
598
+ * // { id: 'abc', count: 42, score: 100 }
599
+ * ```
600
+ */
601
+ catchall<U>(schema: ValSchema<unknown, U>): ValObject<T>;
602
+ /**
603
+ * Returns a schema that validates to a union of the object's literal keys.
604
+ *
605
+ * @returns A schema for the object's keys as literals
606
+ *
607
+ * @example
608
+ * ```typescript
609
+ * const User = v.object({ name: v.string(), age: v.number() });
610
+ * const UserKey = User.keyof();
611
+ * UserKey.parse('name'); // 'name'
612
+ * UserKey.parse('age'); // 'age'
613
+ * UserKey.parse('email'); // throws
614
+ * ```
615
+ */
616
+ keyof(): ValLiteral<keyof T & string>;
617
+ }
618
+ /**
619
+ * Schema for literal union values.
620
+ *
621
+ * Used by object.keyof() to create a schema that validates to one of the
622
+ * object's keys.
623
+ *
624
+ * @template T - The union of literal values
625
+ */
626
+ export declare class ValLiteral<T extends string> extends ValSchema<T, T> {
627
+ readonly values: ReadonlyArray<T>;
628
+ constructor(values: ReadonlyArray<T>);
629
+ }
630
+ export { ValArray, ValUnion, ValIntersection } from './schema';
631
+ /**
632
+ * Helper type to infer input type from a schema.
633
+ */
634
+ type InferSchemaInput<T extends ValSchema<unknown, unknown>> = T extends ValSchema<infer I, unknown> ? I : never;
635
+ /**
636
+ * Helper type to infer output type from a schema.
637
+ */
638
+ type InferSchemaOutput<T extends ValSchema<unknown, unknown>> = T extends ValSchema<unknown, infer O> ? O : never;
639
+ /**
640
+ * Infers tuple input type from an array of schemas.
641
+ */
642
+ type InferTupleInput<T extends ReadonlyArray<ValSchema<unknown, unknown>>> = {
643
+ [K in keyof T]: T[K] extends ValSchema<infer I, unknown> ? I : never;
644
+ };
645
+ /**
646
+ * Infers tuple output type from an array of schemas.
647
+ */
648
+ type InferTupleOutput<T extends ReadonlyArray<ValSchema<unknown, unknown>>> = {
649
+ [K in keyof T]: T[K] extends ValSchema<unknown, infer O> ? O : never;
650
+ };
651
+ /**
652
+ * Schema for tuple values with fixed element types.
653
+ *
654
+ * @template T - The array of element schemas
655
+ *
656
+ * @example
657
+ * ```typescript
658
+ * const schema = v.tuple([v.string(), v.number()]);
659
+ * schema.parse(['hello', 42]); // ['hello', 42]
660
+ *
661
+ * type Tuple = v.infer<typeof schema>; // [string, number]
662
+ * ```
663
+ */
664
+ export declare class ValTuple<T extends ReadonlyArray<ValSchema<unknown, unknown>>, R extends ValSchema<unknown, unknown> | null = null> extends ValSchema<R extends ValSchema<infer RI, unknown> ? [...InferTupleInput<T>, ...RI[]] : InferTupleInput<T>, R extends ValSchema<unknown, infer RO> ? [...InferTupleOutput<T>, ...RO[]] : InferTupleOutput<T>> {
665
+ readonly items: T;
666
+ constructor(items: T, restSchema?: R);
667
+ /**
668
+ * Adds a rest element type to the tuple.
669
+ *
670
+ * @example
671
+ * ```typescript
672
+ * const schema = v.tuple([v.string()]).rest(v.number());
673
+ * schema.parse(['hello', 1, 2, 3]); // ['hello', 1, 2, 3]
674
+ *
675
+ * type T = v.infer<typeof schema>; // [string, ...number[]]
676
+ * ```
677
+ */
678
+ rest<RNew extends ValSchema<unknown, unknown>>(restSchema: RNew): ValTuple<T, RNew>;
679
+ }
680
+ /**
681
+ * Infers union input type from an array of schemas.
682
+ */
683
+ type InferUnionInput<T extends ReadonlyArray<ValSchema<unknown, unknown>>> = T[number] extends ValSchema<infer I, unknown> ? I : never;
684
+ /**
685
+ * Infers union output type from an array of schemas.
686
+ */
687
+ type InferUnionOutput<T extends ReadonlyArray<ValSchema<unknown, unknown>>> = T[number] extends ValSchema<unknown, infer O> ? O : never;
688
+ /**
689
+ * Schema for discriminated union types (tagged unions).
690
+ *
691
+ * Provides better error messages by identifying the discriminator first.
692
+ *
693
+ * @example
694
+ * ```typescript
695
+ * const schema = v.discriminatedUnion('type', [
696
+ * v.object({ type: v.literal('a'), value: v.string() }),
697
+ * v.object({ type: v.literal('b'), count: v.number() }),
698
+ * ]);
699
+ *
700
+ * schema.parse({ type: 'a', value: 'hello' }); // OK
701
+ * schema.parse({ type: 'b', count: 42 }); // OK
702
+ * ```
703
+ */
704
+ export declare class ValDiscriminatedUnion<D extends string, T extends ReadonlyArray<ValObject<Shape>>> extends ValSchema<InferUnionInput<T>, InferUnionOutput<T>> {
705
+ readonly discriminator: D;
706
+ readonly options: T;
707
+ constructor(discriminator: D, options: T);
708
+ }
709
+ /**
710
+ * Schema for record/dictionary values with string keys.
711
+ *
712
+ * @template K - Key schema (must be string)
713
+ * @template V - Value schema
714
+ *
715
+ * @example
716
+ * ```typescript
717
+ * const schema = v.record(v.string());
718
+ * schema.parse({ a: 'hello', b: 'world' }); // OK
719
+ *
720
+ * const typedRecord = v.record(v.string(), v.number());
721
+ * typedRecord.parse({ count: 42, score: 100 }); // OK
722
+ * ```
723
+ */
724
+ export declare class ValRecord<K extends ValSchema<string, string>, V extends ValSchema<unknown, unknown>> extends ValSchema<Record<InferSchemaOutput<K>, InferSchemaInput<V>>, Record<InferSchemaOutput<K>, InferSchemaOutput<V>>> {
725
+ readonly keySchema: K;
726
+ readonly valueSchema: V;
727
+ constructor(keySchema: K, valueSchema: V);
728
+ }
729
+ /**
730
+ * Schema for JavaScript Map objects.
731
+ *
732
+ * @template K - Key schema
733
+ * @template V - Value schema
734
+ *
735
+ * @example
736
+ * ```typescript
737
+ * const schema = v.map(v.string(), v.number());
738
+ * const map = new Map([['a', 1], ['b', 2]]);
739
+ * schema.parse(map); // Map { 'a' => 1, 'b' => 2 }
740
+ * ```
741
+ */
742
+ export declare class ValMap<K extends ValSchema<unknown, unknown>, V extends ValSchema<unknown, unknown>> extends ValSchema<Map<InferSchemaInput<K>, InferSchemaInput<V>>, Map<InferSchemaOutput<K>, InferSchemaOutput<V>>> {
743
+ readonly keySchema: K;
744
+ readonly valueSchema: V;
745
+ constructor(keySchema: K, valueSchema: V);
746
+ }
747
+ /**
748
+ * Schema for JavaScript Set objects.
749
+ *
750
+ * @template V - Value schema
751
+ *
752
+ * @example
753
+ * ```typescript
754
+ * const schema = v.set(v.string());
755
+ * schema.parse(new Set(['a', 'b', 'c'])); // Set { 'a', 'b', 'c' }
756
+ * ```
757
+ */
758
+ export declare class ValSet<V extends ValSchema<unknown, unknown>> extends ValSchema<Set<InferSchemaInput<V>>, Set<InferSchemaOutput<V>>> {
759
+ readonly valueSchema: V;
760
+ constructor(valueSchema: V);
761
+ }
762
+ /**
763
+ * Allowed literal types.
764
+ */
765
+ type LiteralValue = string | number | boolean | null | undefined;
766
+ /**
767
+ * Schema for a single literal value.
768
+ *
769
+ * @template T - The literal type
770
+ *
771
+ * @example
772
+ * ```typescript
773
+ * const schema = v.literal('hello');
774
+ * schema.parse('hello'); // 'hello'
775
+ * schema.parse('world'); // throws
776
+ *
777
+ * type Hello = v.infer<typeof schema>; // 'hello'
778
+ * ```
779
+ */
780
+ export declare class ValLiteralValue<T extends LiteralValue> extends ValSchema<T, T> {
781
+ readonly value: T;
782
+ constructor(literalValue: T);
783
+ }
784
+ /**
785
+ * Schema for enum values (one of a fixed set of string literals).
786
+ *
787
+ * @template T - Tuple of allowed string values
788
+ *
789
+ * @example
790
+ * ```typescript
791
+ * const RoleSchema = v.enum(['admin', 'user', 'guest']);
792
+ * RoleSchema.parse('admin'); // 'admin'
793
+ * RoleSchema.parse('other'); // throws
794
+ *
795
+ * type Role = v.infer<typeof RoleSchema>; // 'admin' | 'user' | 'guest'
796
+ * ```
797
+ */
798
+ export declare class ValEnum<T extends readonly [string, ...string[]]> extends ValSchema<T[number], T[number]> {
799
+ readonly options: T;
800
+ /** Enum-like object mapping values to themselves */
801
+ readonly enum: {
802
+ [K in T[number]]: K;
803
+ };
804
+ constructor(values: T);
805
+ }
806
+ /**
807
+ * Gets the values of a TypeScript enum.
808
+ */
809
+ type EnumLike = {
810
+ [k: string]: string | number;
811
+ [nu: number]: string;
812
+ };
813
+ /**
814
+ * Schema for TypeScript native enums.
815
+ *
816
+ * @template T - The enum type
817
+ *
818
+ * @example
819
+ * ```typescript
820
+ * enum Status { Active, Inactive }
821
+ * const schema = v.nativeEnum(Status);
822
+ * schema.parse(Status.Active); // 0
823
+ * schema.parse('Active'); // throws (numeric enum)
824
+ * ```
825
+ */
826
+ export declare class ValNativeEnum<T extends EnumLike> extends ValSchema<T[keyof T], T[keyof T]> {
827
+ readonly enumObject: T;
828
+ constructor(enumObj: T);
829
+ }
830
+ /**
831
+ * Creates an object schema from a shape definition.
832
+ *
833
+ * @param shape - An object mapping property names to their schemas
834
+ * @returns A new object schema
835
+ *
836
+ * @example
837
+ * ```typescript
838
+ * const User = v.object({
839
+ * name: v.string(),
840
+ * age: v.number().int().positive(),
841
+ * email: v.string().email().optional(),
842
+ * });
843
+ *
844
+ * type User = v.infer<typeof User>;
845
+ * // { name: string; age: number; email?: string }
846
+ *
847
+ * const user = User.parse({ name: 'Alice', age: 30 });
848
+ * ```
849
+ */
850
+ export declare function object<T extends Shape>(shape: T): ValObject<T>;
851
+ /**
852
+ * Creates a string schema.
853
+ *
854
+ * @returns A new string schema
855
+ *
856
+ * @example
857
+ * ```typescript
858
+ * const nameSchema = v.string();
859
+ * nameSchema.parse('Alice'); // 'Alice'
860
+ * nameSchema.parse(123); // throws ValError
861
+ * ```
862
+ */
863
+ export declare function string(): ValString;
864
+ /**
865
+ * Creates a number schema.
866
+ *
867
+ * @returns A new number schema
868
+ *
869
+ * @example
870
+ * ```typescript
871
+ * const ageSchema = v.number();
872
+ * ageSchema.parse(25); // 25
873
+ * ageSchema.parse('25'); // throws ValError
874
+ * ```
875
+ */
876
+ export declare function number(): ValNumber;
877
+ /**
878
+ * Creates a bigint schema.
879
+ *
880
+ * @returns A new bigint schema
881
+ *
882
+ * @example
883
+ * ```typescript
884
+ * const bigSchema = v.bigint();
885
+ * bigSchema.parse(123n); // 123n
886
+ * bigSchema.parse(123); // throws ValError
887
+ * ```
888
+ */
889
+ export declare function bigint(): ValBigInt;
890
+ /**
891
+ * Creates a boolean schema.
892
+ *
893
+ * @returns A new boolean schema
894
+ *
895
+ * @example
896
+ * ```typescript
897
+ * const flagSchema = v.boolean();
898
+ * flagSchema.parse(true); // true
899
+ * flagSchema.parse('true'); // throws ValError
900
+ * ```
901
+ */
902
+ declare function booleanFn(): ValBoolean;
903
+ export { booleanFn as boolean };
904
+ /**
905
+ * Creates a date schema.
906
+ *
907
+ * @returns A new date schema
908
+ *
909
+ * @example
910
+ * ```typescript
911
+ * const dateSchema = v.date();
912
+ * dateSchema.parse(new Date()); // Date object
913
+ * dateSchema.parse('2024-01-01'); // throws ValError
914
+ * ```
915
+ */
916
+ export declare function date(): ValDate;
917
+ /**
918
+ * Creates an undefined schema.
919
+ *
920
+ * @returns A new undefined schema
921
+ */
922
+ declare function undefinedFn(): ValUndefined;
923
+ export { undefinedFn as undefined };
924
+ /**
925
+ * Creates a null schema.
926
+ *
927
+ * @returns A new null schema
928
+ */
929
+ declare function nullFn(): ValNull;
930
+ export { nullFn as null };
931
+ /**
932
+ * Creates a void schema (alias for undefined).
933
+ *
934
+ * @returns A new void schema
935
+ */
936
+ declare function voidFn(): ValVoid;
937
+ export { voidFn as void };
938
+ /**
939
+ * Creates an any schema.
940
+ *
941
+ * Use sparingly - prefer more specific schemas when possible.
942
+ *
943
+ * @returns A new any schema
944
+ */
945
+ export declare function any(): ValAny;
946
+ /**
947
+ * Creates an unknown schema.
948
+ *
949
+ * Unlike `any`, `unknown` requires type narrowing before use.
950
+ *
951
+ * @returns A new unknown schema
952
+ */
953
+ export declare function unknown(): ValUnknown;
954
+ /**
955
+ * Creates a never schema.
956
+ *
957
+ * Useful for exhaustive type checking and unreachable code paths.
958
+ *
959
+ * @returns A new never schema
960
+ */
961
+ export declare function never(): ValNever;
962
+ /**
963
+ * Creates a 32-bit signed integer schema.
964
+ *
965
+ * Range: -2,147,483,648 to 2,147,483,647
966
+ */
967
+ export declare function int32(): ValInt32;
968
+ /**
969
+ * Creates a 64-bit signed integer schema.
970
+ *
971
+ * Note: JavaScript numbers can only safely represent integers up to 2^53 - 1.
972
+ */
973
+ export declare function int64(): ValInt64;
974
+ /**
975
+ * Creates a 32-bit unsigned integer schema.
976
+ *
977
+ * Range: 0 to 4,294,967,295
978
+ */
979
+ export declare function uint32(): ValUint32;
980
+ /**
981
+ * Creates a 64-bit unsigned integer schema.
982
+ */
983
+ export declare function uint64(): ValUint64;
984
+ /**
985
+ * Creates a 32-bit floating point schema.
986
+ */
987
+ export declare function float32(): ValFloat32;
988
+ /**
989
+ * Creates a 64-bit floating point schema.
990
+ */
991
+ export declare function float64(): ValFloat64;
992
+ /**
993
+ * Creates an array schema for the given element type.
994
+ *
995
+ * @param element - The schema for array elements
996
+ * @returns A new array schema
997
+ *
998
+ * @example
999
+ * ```typescript
1000
+ * const schema = v.array(v.string());
1001
+ * schema.parse(['a', 'b', 'c']); // ['a', 'b', 'c']
1002
+ *
1003
+ * const withMin = v.array(v.number()).min(1);
1004
+ * withMin.parse([]); // throws
1005
+ * withMin.parse([1, 2]); // [1, 2]
1006
+ * ```
1007
+ */
1008
+ export declare function array<S extends ValSchema<unknown, unknown>>(element: S): ValArray<S>;
1009
+ /**
1010
+ * Creates a tuple schema with fixed element types.
1011
+ *
1012
+ * @param items - Array of schemas for each tuple element
1013
+ * @returns A new tuple schema
1014
+ *
1015
+ * @example
1016
+ * ```typescript
1017
+ * const schema = v.tuple([v.string(), v.number()]);
1018
+ * schema.parse(['hello', 42]); // ['hello', 42]
1019
+ *
1020
+ * const withRest = v.tuple([v.string()]).rest(v.number());
1021
+ * withRest.parse(['hello', 1, 2, 3]); // ['hello', 1, 2, 3]
1022
+ * ```
1023
+ */
1024
+ export declare function tuple<T extends ReadonlyArray<ValSchema<unknown, unknown>>>(items: T): ValTuple<T, null>;
1025
+ /**
1026
+ * Creates a union schema (one of multiple types).
1027
+ *
1028
+ * @param options - Array of schemas to union
1029
+ * @returns A new union schema
1030
+ *
1031
+ * @example
1032
+ * ```typescript
1033
+ * const schema = v.union([v.string(), v.number()]);
1034
+ * schema.parse('hello'); // 'hello'
1035
+ * schema.parse(42); // 42
1036
+ * schema.parse(true); // throws
1037
+ * ```
1038
+ */
1039
+ export declare function union<T extends readonly [ValSchema<unknown, unknown>, ...ValSchema<unknown, unknown>[]]>(options: T): ValUnion<T>;
1040
+ /**
1041
+ * Creates a discriminated union schema (tagged union).
1042
+ *
1043
+ * Uses a discriminator property to efficiently match variants.
1044
+ * Provides better error messages than regular unions.
1045
+ *
1046
+ * @param discriminator - The property name used to discriminate variants
1047
+ * @param options - Array of object schemas with the discriminator
1048
+ * @returns A new discriminated union schema
1049
+ *
1050
+ * @example
1051
+ * ```typescript
1052
+ * const schema = v.discriminatedUnion('type', [
1053
+ * v.object({ type: v.literal('a'), value: v.string() }),
1054
+ * v.object({ type: v.literal('b'), count: v.number() }),
1055
+ * ]);
1056
+ *
1057
+ * schema.parse({ type: 'a', value: 'hello' }); // OK
1058
+ * schema.parse({ type: 'b', count: 42 }); // OK
1059
+ * schema.parse({ type: 'c' }); // throws with helpful error
1060
+ * ```
1061
+ */
1062
+ export declare function discriminatedUnion<D extends string, T extends readonly [ValObject<Shape>, ...ValObject<Shape>[]]>(discriminator: D, options: T): ValDiscriminatedUnion<D, T>;
1063
+ /**
1064
+ * Creates an intersection schema (all types must match).
1065
+ *
1066
+ * @param left - First schema
1067
+ * @param right - Second schema
1068
+ * @returns A new intersection schema
1069
+ *
1070
+ * @example
1071
+ * ```typescript
1072
+ * const A = v.object({ a: v.string() });
1073
+ * const B = v.object({ b: v.number() });
1074
+ * const AB = v.intersection(A, B);
1075
+ *
1076
+ * AB.parse({ a: 'hello', b: 42 }); // { a: 'hello', b: 42 }
1077
+ * ```
1078
+ */
1079
+ export declare function intersection<L extends ValSchema<unknown, unknown>, R extends ValSchema<unknown, unknown>>(left: L, right: R): ValIntersection<L, R>;
1080
+ /**
1081
+ * Creates a record schema (object with string keys and typed values).
1082
+ *
1083
+ * @param valueSchema - Schema for all values (keys default to string)
1084
+ * @returns A new record schema
1085
+ *
1086
+ * @example
1087
+ * ```typescript
1088
+ * // Record<string, string>
1089
+ * const dict = v.record(v.string());
1090
+ * dict.parse({ a: 'hello', b: 'world' }); // OK
1091
+ *
1092
+ * // Record<string, number>
1093
+ * const counts = v.record(v.string(), v.number());
1094
+ * counts.parse({ count: 42, score: 100 }); // OK
1095
+ * ```
1096
+ */
1097
+ export declare function record<V extends ValSchema<unknown, unknown>>(valueSchema: V): ValRecord<ValString, V>;
1098
+ export declare function record<K extends ValSchema<string, string>, V extends ValSchema<unknown, unknown>>(keySchema: K, valueSchema: V): ValRecord<K, V>;
1099
+ /**
1100
+ * Creates a Map schema.
1101
+ *
1102
+ * @param keySchema - Schema for map keys
1103
+ * @param valueSchema - Schema for map values
1104
+ * @returns A new Map schema
1105
+ *
1106
+ * @example
1107
+ * ```typescript
1108
+ * const schema = v.map(v.string(), v.number());
1109
+ * schema.parse(new Map([['a', 1], ['b', 2]])); // OK
1110
+ * ```
1111
+ */
1112
+ export declare function map<K extends ValSchema<unknown, unknown>, V extends ValSchema<unknown, unknown>>(keySchema: K, valueSchema: V): ValMap<K, V>;
1113
+ /**
1114
+ * Creates a Set schema.
1115
+ *
1116
+ * @param valueSchema - Schema for set values
1117
+ * @returns A new Set schema
1118
+ *
1119
+ * @example
1120
+ * ```typescript
1121
+ * const schema = v.set(v.string());
1122
+ * schema.parse(new Set(['a', 'b', 'c'])); // OK
1123
+ * ```
1124
+ */
1125
+ export declare function set<V extends ValSchema<unknown, unknown>>(valueSchema: V): ValSet<V>;
1126
+ /**
1127
+ * Creates a literal schema for a single value.
1128
+ *
1129
+ * @param value - The literal value to match
1130
+ * @returns A new literal schema
1131
+ *
1132
+ * @example
1133
+ * ```typescript
1134
+ * const hello = v.literal('hello');
1135
+ * hello.parse('hello'); // 'hello'
1136
+ * hello.parse('world'); // throws
1137
+ *
1138
+ * const fortyTwo = v.literal(42);
1139
+ * fortyTwo.parse(42); // 42
1140
+ *
1141
+ * type Hello = v.infer<typeof hello>; // 'hello'
1142
+ * ```
1143
+ */
1144
+ export declare function literal<T extends string | number | boolean | null | undefined>(value: T): ValLiteralValue<T>;
1145
+ /**
1146
+ * Creates an enum schema for a fixed set of string values.
1147
+ *
1148
+ * @param values - Tuple of allowed string values
1149
+ * @returns A new enum schema with an `enum` property
1150
+ *
1151
+ * @example
1152
+ * ```typescript
1153
+ * const Role = v.enum(['admin', 'user', 'guest']);
1154
+ * Role.parse('admin'); // 'admin'
1155
+ * Role.parse('other'); // throws
1156
+ *
1157
+ * type Role = v.infer<typeof Role>; // 'admin' | 'user' | 'guest'
1158
+ *
1159
+ * // Access values like an enum
1160
+ * Role.enum.admin; // 'admin'
1161
+ * ```
1162
+ */
1163
+ declare function enumFn<T extends readonly [string, ...string[]]>(values: T): ValEnum<T>;
1164
+ export { enumFn as enum };
1165
+ /**
1166
+ * Creates a schema for a TypeScript native enum.
1167
+ *
1168
+ * @param enumObject - The TypeScript enum object
1169
+ * @returns A new native enum schema
1170
+ *
1171
+ * @example
1172
+ * ```typescript
1173
+ * enum Status { Active, Inactive }
1174
+ * const schema = v.nativeEnum(Status);
1175
+ *
1176
+ * schema.parse(Status.Active); // 0
1177
+ * schema.parse(Status.Inactive); // 1
1178
+ * schema.parse(2); // throws
1179
+ * ```
1180
+ */
1181
+ export declare function nativeEnum<T extends EnumLike>(enumObject: T): ValNativeEnum<T>;
1182
+ /**
1183
+ * Wraps an existing Standard Schema into a ValSchema.
1184
+ *
1185
+ * Useful for integrating schemas from other Standard Schema compliant libraries.
1186
+ *
1187
+ * @param schema - A Standard Schema compliant object
1188
+ * @returns A ValSchema instance with parse/safeParse methods
1189
+ *
1190
+ * @example
1191
+ * ```typescript
1192
+ * import { StringSchema } from 'valrs';
1193
+ *
1194
+ * const wrapped = v.wrap(StringSchema);
1195
+ * wrapped.parse('hello'); // 'hello'
1196
+ * ```
1197
+ */
1198
+ export declare function wrap<Input, Output>(schema: StandardSchemaV1<Input, Output> & {
1199
+ '~standard': {
1200
+ jsonSchema?: {
1201
+ input: (options: {
1202
+ target: string;
1203
+ }) => Record<string, unknown>;
1204
+ output: (options: {
1205
+ target: string;
1206
+ }) => Record<string, unknown>;
1207
+ };
1208
+ };
1209
+ }): ValSchema<Input, Output>;
1210
+ /**
1211
+ * Preprocesses input before passing to the schema.
1212
+ *
1213
+ * Useful for coercing input types before validation.
1214
+ *
1215
+ * @param preprocessFn - Function to transform the raw input
1216
+ * @param schema - Schema to validate after preprocessing
1217
+ * @returns A new schema that preprocesses then validates
1218
+ *
1219
+ * @example
1220
+ * ```typescript
1221
+ * const schema = v.preprocess(
1222
+ * (val) => (typeof val === 'string' ? parseInt(val, 10) : val),
1223
+ * v.number()
1224
+ * );
1225
+ *
1226
+ * schema.parse('42'); // 42
1227
+ * schema.parse(42); // 42
1228
+ * ```
1229
+ */
1230
+ export declare function preprocess<Input, Output>(preprocessFn: (value: unknown) => Input, schema: ValSchema<Input, Output>): ValPreprocessed<Input, Output>;
1231
+ /**
1232
+ * Schema that coerces input to string using String().
1233
+ */
1234
+ declare class ValCoerceString extends ValSchema<unknown, string> {
1235
+ constructor();
1236
+ }
1237
+ /**
1238
+ * Schema that coerces input to number using Number().
1239
+ */
1240
+ declare class ValCoerceNumber extends ValSchema<unknown, number> {
1241
+ constructor();
1242
+ }
1243
+ /**
1244
+ * Schema that coerces input to boolean.
1245
+ *
1246
+ * Truthy values become true, falsy values become false.
1247
+ */
1248
+ declare class ValCoerceBoolean extends ValSchema<unknown, boolean> {
1249
+ constructor();
1250
+ }
1251
+ /**
1252
+ * Schema that coerces input to bigint using BigInt().
1253
+ */
1254
+ declare class ValCoerceBigInt extends ValSchema<unknown, bigint> {
1255
+ constructor();
1256
+ }
1257
+ /**
1258
+ * Schema that coerces input to Date using new Date().
1259
+ */
1260
+ declare class ValCoerceDate extends ValSchema<unknown, Date> {
1261
+ constructor();
1262
+ }
1263
+ /**
1264
+ * Coercion schema builders.
1265
+ *
1266
+ * These schemas attempt to convert input values to the target type
1267
+ * before validation. Similar to Zod's coerce namespace.
1268
+ *
1269
+ * @example
1270
+ * ```typescript
1271
+ * v.coerce.string().parse(42); // '42'
1272
+ * v.coerce.number().parse('42'); // 42
1273
+ * v.coerce.boolean().parse(1); // true
1274
+ * v.coerce.date().parse('2024-01-01'); // Date object
1275
+ * ```
1276
+ */
1277
+ export declare const coerce: {
1278
+ /**
1279
+ * Coerces any value to string using String().
1280
+ */
1281
+ readonly string: () => ValCoerceString;
1282
+ /**
1283
+ * Coerces any value to number using Number().
1284
+ * Fails if the result is NaN.
1285
+ */
1286
+ readonly number: () => ValCoerceNumber;
1287
+ /**
1288
+ * Coerces any value to boolean using Boolean().
1289
+ */
1290
+ readonly boolean: () => ValCoerceBoolean;
1291
+ /**
1292
+ * Coerces any value to bigint using BigInt().
1293
+ * Fails if the value cannot be converted.
1294
+ */
1295
+ readonly bigint: () => ValCoerceBigInt;
1296
+ /**
1297
+ * Coerces any value to Date using new Date().
1298
+ * Fails if the result is an Invalid Date.
1299
+ */
1300
+ readonly date: () => ValCoerceDate;
1301
+ };
1302
+ export { stream, streamLines, createMockStream, createChunkedStream };
1303
+ /**
1304
+ * The main valrs namespace, providing a Zod-compatible API.
1305
+ *
1306
+ * @example
1307
+ * ```typescript
1308
+ * import { v } from 'valrs';
1309
+ *
1310
+ * const schema = v.string();
1311
+ * schema.parse('hello');
1312
+ *
1313
+ * type MyType = v.infer<typeof schema>;
1314
+ * ```
1315
+ */
1316
+ export declare const v: {
1317
+ readonly string: typeof string;
1318
+ readonly number: typeof number;
1319
+ readonly bigint: typeof bigint;
1320
+ readonly boolean: typeof booleanFn;
1321
+ readonly date: typeof date;
1322
+ readonly undefined: typeof undefinedFn;
1323
+ readonly null: typeof nullFn;
1324
+ readonly void: typeof voidFn;
1325
+ readonly any: typeof any;
1326
+ readonly unknown: typeof unknown;
1327
+ readonly never: typeof never;
1328
+ readonly object: typeof object;
1329
+ readonly array: typeof array;
1330
+ readonly tuple: typeof tuple;
1331
+ readonly union: typeof union;
1332
+ readonly discriminatedUnion: typeof discriminatedUnion;
1333
+ readonly intersection: typeof intersection;
1334
+ readonly record: typeof record;
1335
+ readonly map: typeof map;
1336
+ readonly set: typeof set;
1337
+ readonly literal: typeof literal;
1338
+ readonly enum: typeof enumFn;
1339
+ readonly nativeEnum: typeof nativeEnum;
1340
+ readonly int32: typeof int32;
1341
+ readonly int64: typeof int64;
1342
+ readonly uint32: typeof uint32;
1343
+ readonly uint64: typeof uint64;
1344
+ readonly float32: typeof float32;
1345
+ readonly float64: typeof float64;
1346
+ readonly preprocess: typeof preprocess;
1347
+ readonly coerce: {
1348
+ /**
1349
+ * Coerces any value to string using String().
1350
+ */
1351
+ readonly string: () => ValCoerceString;
1352
+ /**
1353
+ * Coerces any value to number using Number().
1354
+ * Fails if the result is NaN.
1355
+ */
1356
+ readonly number: () => ValCoerceNumber;
1357
+ /**
1358
+ * Coerces any value to boolean using Boolean().
1359
+ */
1360
+ readonly boolean: () => ValCoerceBoolean;
1361
+ /**
1362
+ * Coerces any value to bigint using BigInt().
1363
+ * Fails if the value cannot be converted.
1364
+ */
1365
+ readonly bigint: () => ValCoerceBigInt;
1366
+ /**
1367
+ * Coerces any value to Date using new Date().
1368
+ * Fails if the result is an Invalid Date.
1369
+ */
1370
+ readonly date: () => ValCoerceDate;
1371
+ };
1372
+ readonly wrap: typeof wrap;
1373
+ readonly stream: typeof stream;
1374
+ readonly streamLines: typeof streamLines;
1375
+ readonly createMockStream: typeof createMockStream;
1376
+ readonly createChunkedStream: typeof createChunkedStream;
1377
+ readonly setErrorMap: typeof setErrorMapFn;
1378
+ readonly getErrorMap: typeof getErrorMapFn;
1379
+ readonly resetErrorMap: typeof resetErrorMapFn;
1380
+ };
1381
+ export default v;
1382
+ //# sourceMappingURL=v.d.ts.map