@arrirpc/schema 0.45.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.
@@ -0,0 +1,167 @@
1
+ import { Type } from 'jtd-utils';
2
+
3
+ declare function sanitizeJson(json: string): string;
4
+ /**
5
+ * Check if the input matches the specified schema. This is a type guard.
6
+ */
7
+ declare function validate<T = any>(schema: ASchema<T>, input: unknown): input is T;
8
+ /**
9
+ * Parse a JSON string or the result of JSON.parse(). Throws a ValidationError if parsing fails.
10
+ */
11
+ declare function parse<T = any>(schema: ASchema<T>, input: unknown): T;
12
+ /**
13
+ * Parse a value without throwing an error.
14
+ */
15
+ declare function safeParse<T = any>(schema: ASchema<T>, input: unknown): SafeResult<T>;
16
+ /**
17
+ * Try to convert input to match the specified schema. Throws a ValidationError if conversion fails.
18
+ */
19
+ declare function coerce<T = any>(schema: ASchema<T>, input: unknown): T;
20
+ type SafeResult<T> = {
21
+ success: true;
22
+ value: T;
23
+ } | {
24
+ success: false;
25
+ error: ValidationError;
26
+ };
27
+ /**
28
+ * Convert a value into the specified schema without throwing an error.
29
+ */
30
+ declare function safeCoerce<T = any>(schema: ASchema<T>, input: unknown): SafeResult<T>;
31
+ /**
32
+ * Serialize a value into a JSON string
33
+ */
34
+ declare function serialize<T = any>(schema: ASchema<T>, input: T): string;
35
+ declare function errors(schema: ASchema, input: unknown): ValueError[];
36
+ interface ValueError {
37
+ instancePath: string;
38
+ schemaPath: string;
39
+ message?: string;
40
+ data?: any;
41
+ }
42
+ declare class ValidationError extends Error {
43
+ errors: ValueError[];
44
+ constructor(options: {
45
+ message: string;
46
+ errors: ValueError[];
47
+ });
48
+ }
49
+ declare function isValidationError(input: unknown): input is ValidationError;
50
+
51
+ declare const SCHEMA_METADATA: unique symbol;
52
+ type MaybeNullable<T = any, TIsNullable extends boolean = false> = TIsNullable extends true ? T | null : T;
53
+ interface ValidationData {
54
+ instancePath: string;
55
+ schemaPath: string;
56
+ errors: ValueError[];
57
+ discriminatorKey?: string;
58
+ discriminatorValue?: string;
59
+ }
60
+ interface SchemaValidator<T> {
61
+ output: T;
62
+ optional?: boolean;
63
+ parse: (input: unknown, data: ValidationData) => T | undefined;
64
+ coerce: (input: unknown, data: ValidationData) => T | undefined;
65
+ serialize: (input: T, data: ValidationData) => string;
66
+ validate: (input: unknown) => input is T;
67
+ }
68
+ interface SchemaMetadata<T> {
69
+ [key: string]: any;
70
+ id?: string;
71
+ description?: string;
72
+ isDeprecated?: boolean;
73
+ [SCHEMA_METADATA]: SchemaValidator<T>;
74
+ }
75
+ interface ASchema<T = any> {
76
+ metadata: SchemaMetadata<T>;
77
+ nullable?: boolean;
78
+ }
79
+ declare function isASchema(input: unknown): input is ASchema;
80
+ interface ASchemaOptions {
81
+ id?: string;
82
+ description?: string;
83
+ isDeprecated?: boolean;
84
+ }
85
+ type Resolve<T> = T;
86
+ type ResolveObject<T> = Resolve<{
87
+ [k in keyof T]: T[k];
88
+ }>;
89
+ type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
90
+ type InferType<TInput extends ASchema<any>> = Resolve<TInput["metadata"][typeof SCHEMA_METADATA]["output"]>;
91
+ /**
92
+ * Infer a specific subtype of a discriminated union.
93
+ * In order for this to work you must first infer the union type using `a.infer`
94
+ * Then pass the type result to this
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * const Shape = a.discriminator(
99
+ * "type",
100
+ * {
101
+ * "RECTANGLE": a.object({
102
+ * width: a.number(),
103
+ * height: a.number(),
104
+ * }),
105
+ * "CIRCLE": a.object({
106
+ * radius: a.number(),
107
+ * }),
108
+ * }
109
+ * );
110
+ *
111
+ * type Shape = a.infer<typeof Shape>;
112
+ * // { type: "RECTANGLE"; width: number; height: number } | { type: "CIRCLE"; radius: number; }
113
+ *
114
+ * type ShapeTypeRectangle = a.infer<Shape, "type", "RECTANGLE">
115
+ * // { type: "RECTANGLE"; width: number; height: number; }
116
+ *
117
+ * type ShapeTypeCircle = a.infer<Shape, "type", "CIRCLE">
118
+ * // { type: "CIRCLE"; radius: number; }
119
+ * ```
120
+ */
121
+ type InferSubType<TUnion extends Record<string, any>, TKey extends keyof TUnion, TVal extends TUnion[TKey]> = TUnion extends Record<TKey, TVal> ? TUnion : never;
122
+ interface AScalarSchema<T extends Type | NumberType = any, TVal = any> extends ASchema<TVal> {
123
+ type: T;
124
+ }
125
+ declare function isAScalarSchema(input: unknown): input is AScalarSchema;
126
+ declare const NumberTypeValues: readonly ["float32", "float64", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64"];
127
+ type NumberType = (typeof NumberTypeValues)[number];
128
+ interface AArraySchema<TInnerSchema extends ASchema<any> = any> extends ASchema<Array<InferType<TInnerSchema>>> {
129
+ elements: TInnerSchema;
130
+ }
131
+ declare function isAAraySchema(input: unknown): input is AArraySchema;
132
+ interface AStringEnumSchema<TValues extends string[]> extends ASchema<TValues[number]> {
133
+ enum: TValues;
134
+ }
135
+ declare function isAStringEnumSchema(input: unknown): input is AStringEnumSchema<any>;
136
+ interface ADiscriminatorSchema<T> extends ASchema<T> {
137
+ discriminator: string;
138
+ mapping: Record<string, AObjectSchema<any>>;
139
+ }
140
+ declare function isADiscriminatorSchema(input: unknown): input is ADiscriminatorSchema<any>;
141
+ interface ARecordSchema<TInnerSchema extends ASchema<any>, TNullable extends boolean = false> extends ASchema<MaybeNullable<Record<string, InferType<TInnerSchema>>, TNullable>> {
142
+ values: TInnerSchema;
143
+ }
144
+ declare function isARecordSchema(input: unknown): input is ARecordSchema<any, any>;
145
+ interface AObjectSchema<TVal = any, TAllowAdditionalProperties extends boolean = false> extends ASchema<TVal> {
146
+ properties: Record<string, ASchema>;
147
+ optionalProperties?: Record<string, ASchema>;
148
+ additionalProperties?: TAllowAdditionalProperties;
149
+ }
150
+ declare function isAObjectSchema(input: unknown): input is AObjectSchema;
151
+ interface AObjectSchemaOptions<TAdditionalProps extends boolean = false> extends ASchemaOptions {
152
+ /**
153
+ * Allow this object to include additional properties not specified here
154
+ */
155
+ additionalProperties?: TAdditionalProps;
156
+ }
157
+ type InferObjectOutput<TInput = any, TAdditionalProps extends boolean = false> = TAdditionalProps extends true ? ResolveObject<InferObjectRawType<TInput>> & Record<any, any> : ResolveObject<InferObjectRawType<TInput>>;
158
+ type InferObjectRawType<TInput> = TInput extends Record<any, any> ? {
159
+ [TKey in keyof TInput]: TInput[TKey]["metadata"][typeof SCHEMA_METADATA]["optional"] extends true ? TInput[TKey]["metadata"][typeof SCHEMA_METADATA]["output"] | undefined : TInput[TKey]["metadata"][typeof SCHEMA_METADATA]["output"];
160
+ } : never;
161
+ declare function isObject(input: unknown): input is Record<any, any>;
162
+ interface ARefSchema<T> extends ASchema<T> {
163
+ ref: string;
164
+ }
165
+ declare function isARefSchema(input: unknown): input is ARefSchema<any>;
166
+
167
+ export { type ASchemaOptions as A, type Resolve as B, isAScalarSchema as C, type NumberType as D, isAAraySchema as E, isAStringEnumSchema as F, isADiscriminatorSchema as G, isARecordSchema as H, type InferType as I, isAObjectSchema as J, type InferObjectRawType as K, isObject as L, type MaybeNullable as M, NumberTypeValues as N, isARefSchema as O, type PartialBy as P, type ResolveObject as R, type SafeResult as S, type ValidationData as V, type ASchema as a, type AArraySchema as b, type AScalarSchema as c, type AObjectSchema as d, type ADiscriminatorSchema as e, type AStringEnumSchema as f, type AObjectSchemaOptions as g, type InferObjectOutput as h, type ARecordSchema as i, type ARefSchema as j, coerce as k, errors as l, type InferSubType as m, safeParse as n, serialize as o, parse as p, type SchemaValidator as q, type SchemaMetadata as r, safeCoerce as s, SCHEMA_METADATA as t, sanitizeJson as u, validate as v, type ValueError as w, ValidationError as x, isValidationError as y, isASchema as z };
@@ -0,0 +1,167 @@
1
+ import { Type } from 'jtd-utils';
2
+
3
+ declare function sanitizeJson(json: string): string;
4
+ /**
5
+ * Check if the input matches the specified schema. This is a type guard.
6
+ */
7
+ declare function validate<T = any>(schema: ASchema<T>, input: unknown): input is T;
8
+ /**
9
+ * Parse a JSON string or the result of JSON.parse(). Throws a ValidationError if parsing fails.
10
+ */
11
+ declare function parse<T = any>(schema: ASchema<T>, input: unknown): T;
12
+ /**
13
+ * Parse a value without throwing an error.
14
+ */
15
+ declare function safeParse<T = any>(schema: ASchema<T>, input: unknown): SafeResult<T>;
16
+ /**
17
+ * Try to convert input to match the specified schema. Throws a ValidationError if conversion fails.
18
+ */
19
+ declare function coerce<T = any>(schema: ASchema<T>, input: unknown): T;
20
+ type SafeResult<T> = {
21
+ success: true;
22
+ value: T;
23
+ } | {
24
+ success: false;
25
+ error: ValidationError;
26
+ };
27
+ /**
28
+ * Convert a value into the specified schema without throwing an error.
29
+ */
30
+ declare function safeCoerce<T = any>(schema: ASchema<T>, input: unknown): SafeResult<T>;
31
+ /**
32
+ * Serialize a value into a JSON string
33
+ */
34
+ declare function serialize<T = any>(schema: ASchema<T>, input: T): string;
35
+ declare function errors(schema: ASchema, input: unknown): ValueError[];
36
+ interface ValueError {
37
+ instancePath: string;
38
+ schemaPath: string;
39
+ message?: string;
40
+ data?: any;
41
+ }
42
+ declare class ValidationError extends Error {
43
+ errors: ValueError[];
44
+ constructor(options: {
45
+ message: string;
46
+ errors: ValueError[];
47
+ });
48
+ }
49
+ declare function isValidationError(input: unknown): input is ValidationError;
50
+
51
+ declare const SCHEMA_METADATA: unique symbol;
52
+ type MaybeNullable<T = any, TIsNullable extends boolean = false> = TIsNullable extends true ? T | null : T;
53
+ interface ValidationData {
54
+ instancePath: string;
55
+ schemaPath: string;
56
+ errors: ValueError[];
57
+ discriminatorKey?: string;
58
+ discriminatorValue?: string;
59
+ }
60
+ interface SchemaValidator<T> {
61
+ output: T;
62
+ optional?: boolean;
63
+ parse: (input: unknown, data: ValidationData) => T | undefined;
64
+ coerce: (input: unknown, data: ValidationData) => T | undefined;
65
+ serialize: (input: T, data: ValidationData) => string;
66
+ validate: (input: unknown) => input is T;
67
+ }
68
+ interface SchemaMetadata<T> {
69
+ [key: string]: any;
70
+ id?: string;
71
+ description?: string;
72
+ isDeprecated?: boolean;
73
+ [SCHEMA_METADATA]: SchemaValidator<T>;
74
+ }
75
+ interface ASchema<T = any> {
76
+ metadata: SchemaMetadata<T>;
77
+ nullable?: boolean;
78
+ }
79
+ declare function isASchema(input: unknown): input is ASchema;
80
+ interface ASchemaOptions {
81
+ id?: string;
82
+ description?: string;
83
+ isDeprecated?: boolean;
84
+ }
85
+ type Resolve<T> = T;
86
+ type ResolveObject<T> = Resolve<{
87
+ [k in keyof T]: T[k];
88
+ }>;
89
+ type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
90
+ type InferType<TInput extends ASchema<any>> = Resolve<TInput["metadata"][typeof SCHEMA_METADATA]["output"]>;
91
+ /**
92
+ * Infer a specific subtype of a discriminated union.
93
+ * In order for this to work you must first infer the union type using `a.infer`
94
+ * Then pass the type result to this
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * const Shape = a.discriminator(
99
+ * "type",
100
+ * {
101
+ * "RECTANGLE": a.object({
102
+ * width: a.number(),
103
+ * height: a.number(),
104
+ * }),
105
+ * "CIRCLE": a.object({
106
+ * radius: a.number(),
107
+ * }),
108
+ * }
109
+ * );
110
+ *
111
+ * type Shape = a.infer<typeof Shape>;
112
+ * // { type: "RECTANGLE"; width: number; height: number } | { type: "CIRCLE"; radius: number; }
113
+ *
114
+ * type ShapeTypeRectangle = a.infer<Shape, "type", "RECTANGLE">
115
+ * // { type: "RECTANGLE"; width: number; height: number; }
116
+ *
117
+ * type ShapeTypeCircle = a.infer<Shape, "type", "CIRCLE">
118
+ * // { type: "CIRCLE"; radius: number; }
119
+ * ```
120
+ */
121
+ type InferSubType<TUnion extends Record<string, any>, TKey extends keyof TUnion, TVal extends TUnion[TKey]> = TUnion extends Record<TKey, TVal> ? TUnion : never;
122
+ interface AScalarSchema<T extends Type | NumberType = any, TVal = any> extends ASchema<TVal> {
123
+ type: T;
124
+ }
125
+ declare function isAScalarSchema(input: unknown): input is AScalarSchema;
126
+ declare const NumberTypeValues: readonly ["float32", "float64", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64"];
127
+ type NumberType = (typeof NumberTypeValues)[number];
128
+ interface AArraySchema<TInnerSchema extends ASchema<any> = any> extends ASchema<Array<InferType<TInnerSchema>>> {
129
+ elements: TInnerSchema;
130
+ }
131
+ declare function isAAraySchema(input: unknown): input is AArraySchema;
132
+ interface AStringEnumSchema<TValues extends string[]> extends ASchema<TValues[number]> {
133
+ enum: TValues;
134
+ }
135
+ declare function isAStringEnumSchema(input: unknown): input is AStringEnumSchema<any>;
136
+ interface ADiscriminatorSchema<T> extends ASchema<T> {
137
+ discriminator: string;
138
+ mapping: Record<string, AObjectSchema<any>>;
139
+ }
140
+ declare function isADiscriminatorSchema(input: unknown): input is ADiscriminatorSchema<any>;
141
+ interface ARecordSchema<TInnerSchema extends ASchema<any>, TNullable extends boolean = false> extends ASchema<MaybeNullable<Record<string, InferType<TInnerSchema>>, TNullable>> {
142
+ values: TInnerSchema;
143
+ }
144
+ declare function isARecordSchema(input: unknown): input is ARecordSchema<any, any>;
145
+ interface AObjectSchema<TVal = any, TAllowAdditionalProperties extends boolean = false> extends ASchema<TVal> {
146
+ properties: Record<string, ASchema>;
147
+ optionalProperties?: Record<string, ASchema>;
148
+ additionalProperties?: TAllowAdditionalProperties;
149
+ }
150
+ declare function isAObjectSchema(input: unknown): input is AObjectSchema;
151
+ interface AObjectSchemaOptions<TAdditionalProps extends boolean = false> extends ASchemaOptions {
152
+ /**
153
+ * Allow this object to include additional properties not specified here
154
+ */
155
+ additionalProperties?: TAdditionalProps;
156
+ }
157
+ type InferObjectOutput<TInput = any, TAdditionalProps extends boolean = false> = TAdditionalProps extends true ? ResolveObject<InferObjectRawType<TInput>> & Record<any, any> : ResolveObject<InferObjectRawType<TInput>>;
158
+ type InferObjectRawType<TInput> = TInput extends Record<any, any> ? {
159
+ [TKey in keyof TInput]: TInput[TKey]["metadata"][typeof SCHEMA_METADATA]["optional"] extends true ? TInput[TKey]["metadata"][typeof SCHEMA_METADATA]["output"] | undefined : TInput[TKey]["metadata"][typeof SCHEMA_METADATA]["output"];
160
+ } : never;
161
+ declare function isObject(input: unknown): input is Record<any, any>;
162
+ interface ARefSchema<T> extends ASchema<T> {
163
+ ref: string;
164
+ }
165
+ declare function isARefSchema(input: unknown): input is ARefSchema<any>;
166
+
167
+ export { type ASchemaOptions as A, type Resolve as B, isAScalarSchema as C, type NumberType as D, isAAraySchema as E, isAStringEnumSchema as F, isADiscriminatorSchema as G, isARecordSchema as H, type InferType as I, isAObjectSchema as J, type InferObjectRawType as K, isObject as L, type MaybeNullable as M, NumberTypeValues as N, isARefSchema as O, type PartialBy as P, type ResolveObject as R, type SafeResult as S, type ValidationData as V, type ASchema as a, type AArraySchema as b, type AScalarSchema as c, type AObjectSchema as d, type ADiscriminatorSchema as e, type AStringEnumSchema as f, type AObjectSchemaOptions as g, type InferObjectOutput as h, type ARecordSchema as i, type ARefSchema as j, coerce as k, errors as l, type InferSubType as m, safeParse as n, serialize as o, parse as p, type SchemaValidator as q, type SchemaMetadata as r, safeCoerce as s, SCHEMA_METADATA as t, sanitizeJson as u, validate as v, type ValueError as w, ValidationError as x, isValidationError as y, isASchema as z };
@@ -0,0 +1,167 @@
1
+ import { Type } from 'jtd-utils';
2
+
3
+ declare function sanitizeJson(json: string): string;
4
+ /**
5
+ * Check if the input matches the specified schema. This is a type guard.
6
+ */
7
+ declare function validate<T = any>(schema: ASchema<T>, input: unknown): input is T;
8
+ /**
9
+ * Parse a JSON string or the result of JSON.parse(). Throws a ValidationError if parsing fails.
10
+ */
11
+ declare function parse<T = any>(schema: ASchema<T>, input: unknown): T;
12
+ /**
13
+ * Parse a value without throwing an error.
14
+ */
15
+ declare function safeParse<T = any>(schema: ASchema<T>, input: unknown): SafeResult<T>;
16
+ /**
17
+ * Try to convert input to match the specified schema. Throws a ValidationError if conversion fails.
18
+ */
19
+ declare function coerce<T = any>(schema: ASchema<T>, input: unknown): T;
20
+ type SafeResult<T> = {
21
+ success: true;
22
+ value: T;
23
+ } | {
24
+ success: false;
25
+ error: ValidationError;
26
+ };
27
+ /**
28
+ * Convert a value into the specified schema without throwing an error.
29
+ */
30
+ declare function safeCoerce<T = any>(schema: ASchema<T>, input: unknown): SafeResult<T>;
31
+ /**
32
+ * Serialize a value into a JSON string
33
+ */
34
+ declare function serialize<T = any>(schema: ASchema<T>, input: T): string;
35
+ declare function errors(schema: ASchema, input: unknown): ValueError[];
36
+ interface ValueError {
37
+ instancePath: string;
38
+ schemaPath: string;
39
+ message?: string;
40
+ data?: any;
41
+ }
42
+ declare class ValidationError extends Error {
43
+ errors: ValueError[];
44
+ constructor(options: {
45
+ message: string;
46
+ errors: ValueError[];
47
+ });
48
+ }
49
+ declare function isValidationError(input: unknown): input is ValidationError;
50
+
51
+ declare const SCHEMA_METADATA: unique symbol;
52
+ type MaybeNullable<T = any, TIsNullable extends boolean = false> = TIsNullable extends true ? T | null : T;
53
+ interface ValidationData {
54
+ instancePath: string;
55
+ schemaPath: string;
56
+ errors: ValueError[];
57
+ discriminatorKey?: string;
58
+ discriminatorValue?: string;
59
+ }
60
+ interface SchemaValidator<T> {
61
+ output: T;
62
+ optional?: boolean;
63
+ parse: (input: unknown, data: ValidationData) => T | undefined;
64
+ coerce: (input: unknown, data: ValidationData) => T | undefined;
65
+ serialize: (input: T, data: ValidationData) => string;
66
+ validate: (input: unknown) => input is T;
67
+ }
68
+ interface SchemaMetadata<T> {
69
+ [key: string]: any;
70
+ id?: string;
71
+ description?: string;
72
+ isDeprecated?: boolean;
73
+ [SCHEMA_METADATA]: SchemaValidator<T>;
74
+ }
75
+ interface ASchema<T = any> {
76
+ metadata: SchemaMetadata<T>;
77
+ nullable?: boolean;
78
+ }
79
+ declare function isASchema(input: unknown): input is ASchema;
80
+ interface ASchemaOptions {
81
+ id?: string;
82
+ description?: string;
83
+ isDeprecated?: boolean;
84
+ }
85
+ type Resolve<T> = T;
86
+ type ResolveObject<T> = Resolve<{
87
+ [k in keyof T]: T[k];
88
+ }>;
89
+ type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
90
+ type InferType<TInput extends ASchema<any>> = Resolve<TInput["metadata"][typeof SCHEMA_METADATA]["output"]>;
91
+ /**
92
+ * Infer a specific subtype of a discriminated union.
93
+ * In order for this to work you must first infer the union type using `a.infer`
94
+ * Then pass the type result to this
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * const Shape = a.discriminator(
99
+ * "type",
100
+ * {
101
+ * "RECTANGLE": a.object({
102
+ * width: a.number(),
103
+ * height: a.number(),
104
+ * }),
105
+ * "CIRCLE": a.object({
106
+ * radius: a.number(),
107
+ * }),
108
+ * }
109
+ * );
110
+ *
111
+ * type Shape = a.infer<typeof Shape>;
112
+ * // { type: "RECTANGLE"; width: number; height: number } | { type: "CIRCLE"; radius: number; }
113
+ *
114
+ * type ShapeTypeRectangle = a.infer<Shape, "type", "RECTANGLE">
115
+ * // { type: "RECTANGLE"; width: number; height: number; }
116
+ *
117
+ * type ShapeTypeCircle = a.infer<Shape, "type", "CIRCLE">
118
+ * // { type: "CIRCLE"; radius: number; }
119
+ * ```
120
+ */
121
+ type InferSubType<TUnion extends Record<string, any>, TKey extends keyof TUnion, TVal extends TUnion[TKey]> = TUnion extends Record<TKey, TVal> ? TUnion : never;
122
+ interface AScalarSchema<T extends Type | NumberType = any, TVal = any> extends ASchema<TVal> {
123
+ type: T;
124
+ }
125
+ declare function isAScalarSchema(input: unknown): input is AScalarSchema;
126
+ declare const NumberTypeValues: readonly ["float32", "float64", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64"];
127
+ type NumberType = (typeof NumberTypeValues)[number];
128
+ interface AArraySchema<TInnerSchema extends ASchema<any> = any> extends ASchema<Array<InferType<TInnerSchema>>> {
129
+ elements: TInnerSchema;
130
+ }
131
+ declare function isAAraySchema(input: unknown): input is AArraySchema;
132
+ interface AStringEnumSchema<TValues extends string[]> extends ASchema<TValues[number]> {
133
+ enum: TValues;
134
+ }
135
+ declare function isAStringEnumSchema(input: unknown): input is AStringEnumSchema<any>;
136
+ interface ADiscriminatorSchema<T> extends ASchema<T> {
137
+ discriminator: string;
138
+ mapping: Record<string, AObjectSchema<any>>;
139
+ }
140
+ declare function isADiscriminatorSchema(input: unknown): input is ADiscriminatorSchema<any>;
141
+ interface ARecordSchema<TInnerSchema extends ASchema<any>, TNullable extends boolean = false> extends ASchema<MaybeNullable<Record<string, InferType<TInnerSchema>>, TNullable>> {
142
+ values: TInnerSchema;
143
+ }
144
+ declare function isARecordSchema(input: unknown): input is ARecordSchema<any, any>;
145
+ interface AObjectSchema<TVal = any, TAllowAdditionalProperties extends boolean = false> extends ASchema<TVal> {
146
+ properties: Record<string, ASchema>;
147
+ optionalProperties?: Record<string, ASchema>;
148
+ additionalProperties?: TAllowAdditionalProperties;
149
+ }
150
+ declare function isAObjectSchema(input: unknown): input is AObjectSchema;
151
+ interface AObjectSchemaOptions<TAdditionalProps extends boolean = false> extends ASchemaOptions {
152
+ /**
153
+ * Allow this object to include additional properties not specified here
154
+ */
155
+ additionalProperties?: TAdditionalProps;
156
+ }
157
+ type InferObjectOutput<TInput = any, TAdditionalProps extends boolean = false> = TAdditionalProps extends true ? ResolveObject<InferObjectRawType<TInput>> & Record<any, any> : ResolveObject<InferObjectRawType<TInput>>;
158
+ type InferObjectRawType<TInput> = TInput extends Record<any, any> ? {
159
+ [TKey in keyof TInput]: TInput[TKey]["metadata"][typeof SCHEMA_METADATA]["optional"] extends true ? TInput[TKey]["metadata"][typeof SCHEMA_METADATA]["output"] | undefined : TInput[TKey]["metadata"][typeof SCHEMA_METADATA]["output"];
160
+ } : never;
161
+ declare function isObject(input: unknown): input is Record<any, any>;
162
+ interface ARefSchema<T> extends ASchema<T> {
163
+ ref: string;
164
+ }
165
+ declare function isARefSchema(input: unknown): input is ARefSchema<any>;
166
+
167
+ export { type ASchemaOptions as A, type Resolve as B, isAScalarSchema as C, type NumberType as D, isAAraySchema as E, isAStringEnumSchema as F, isADiscriminatorSchema as G, isARecordSchema as H, type InferType as I, isAObjectSchema as J, type InferObjectRawType as K, isObject as L, type MaybeNullable as M, NumberTypeValues as N, isARefSchema as O, type PartialBy as P, type ResolveObject as R, type SafeResult as S, type ValidationData as V, type ASchema as a, type AArraySchema as b, type AScalarSchema as c, type AObjectSchema as d, type ADiscriminatorSchema as e, type AStringEnumSchema as f, type AObjectSchemaOptions as g, type InferObjectOutput as h, type ARecordSchema as i, type ARefSchema as j, coerce as k, errors as l, type InferSubType as m, safeParse as n, serialize as o, parse as p, type SchemaValidator as q, type SchemaMetadata as r, safeCoerce as s, SCHEMA_METADATA as t, sanitizeJson as u, validate as v, type ValueError as w, ValidationError as x, isValidationError as y, isASchema as z };