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/README.md +197 -0
- package/dist/compiler.d.ts +195 -0
- package/dist/compiler.d.ts.map +1 -0
- package/dist/compiler.js +349 -0
- package/dist/compiler.js.map +1 -0
- package/dist/error.d.ts +415 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +619 -0
- package/dist/error.js.map +1 -0
- package/dist/factory.d.ts +107 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +135 -0
- package/dist/factory.js.map +1 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +104 -0
- package/dist/index.js.map +1 -0
- package/dist/primitives.d.ts +99 -0
- package/dist/primitives.d.ts.map +1 -0
- package/dist/primitives.js +315 -0
- package/dist/primitives.js.map +1 -0
- package/dist/schema.d.ts +710 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +1179 -0
- package/dist/schema.js.map +1 -0
- package/dist/streaming.d.ts +159 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/streaming.js +692 -0
- package/dist/streaming.js.map +1 -0
- package/dist/types.d.ts +107 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -0
- package/dist/v.d.ts +1382 -0
- package/dist/v.d.ts.map +1 -0
- package/dist/v.js +2396 -0
- package/dist/v.js.map +1 -0
- package/dist/wasm.d.ts +86 -0
- package/dist/wasm.d.ts.map +1 -0
- package/dist/wasm.js +87 -0
- package/dist/wasm.js.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema factory functions for creating Standard Schema compliant objects.
|
|
3
|
+
*
|
|
4
|
+
* These factories wrap validation and JSON Schema generation functions
|
|
5
|
+
* into the Standard Schema format with the `~standard` property.
|
|
6
|
+
*/
|
|
7
|
+
import type { StandardSchemaV1, StandardJSONSchemaV1, ValidationResult, ValidationIssue } from './types';
|
|
8
|
+
/** The vendor name for schemas created by this library. */
|
|
9
|
+
export declare const VENDOR: "valrs";
|
|
10
|
+
/** The Standard Schema version. */
|
|
11
|
+
export declare const VERSION: 1;
|
|
12
|
+
/**
|
|
13
|
+
* A function that validates an unknown value.
|
|
14
|
+
*/
|
|
15
|
+
export type ValidateFn<T> = (value: unknown) => ValidationResult<T>;
|
|
16
|
+
/**
|
|
17
|
+
* A function that generates a JSON Schema.
|
|
18
|
+
*/
|
|
19
|
+
export type JsonSchemaFn = (target: string) => Record<string, unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a Standard Schema from a validation function.
|
|
22
|
+
*
|
|
23
|
+
* This is the simplest way to create a compliant schema. The returned
|
|
24
|
+
* object has the `~standard` property with the validate function.
|
|
25
|
+
*
|
|
26
|
+
* @template T - The validated output type
|
|
27
|
+
* @param validateFn - The validation function
|
|
28
|
+
* @returns A Standard Schema compliant object
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const PositiveNumber = createSchema<number>((value) => {
|
|
33
|
+
* if (typeof value !== 'number') {
|
|
34
|
+
* return { issues: [{ message: 'Expected a number' }] };
|
|
35
|
+
* }
|
|
36
|
+
* if (value <= 0) {
|
|
37
|
+
* return { issues: [{ message: 'Must be positive' }] };
|
|
38
|
+
* }
|
|
39
|
+
* return { value };
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function createSchema<T>(validateFn: ValidateFn<T>): StandardSchemaV1<T, T>;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a Standard Schema with JSON Schema generation support.
|
|
46
|
+
*
|
|
47
|
+
* This extends the basic schema with the ability to generate JSON Schema
|
|
48
|
+
* representations for different targets (Draft 2020-12, Draft 07, OpenAPI 3.0).
|
|
49
|
+
*
|
|
50
|
+
* @template T - The validated output type
|
|
51
|
+
* @param validateFn - The validation function
|
|
52
|
+
* @param jsonSchemaFn - Function to generate JSON Schema for a target
|
|
53
|
+
* @returns A Standard JSON Schema compliant object
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const StringSchema = createSchemaWithJsonSchema<string>(
|
|
58
|
+
* (value) => {
|
|
59
|
+
* if (typeof value !== 'string') {
|
|
60
|
+
* return { issues: [{ message: 'Expected a string' }] };
|
|
61
|
+
* }
|
|
62
|
+
* return { value };
|
|
63
|
+
* },
|
|
64
|
+
* (target) => ({ type: 'string' })
|
|
65
|
+
* );
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function createSchemaWithJsonSchema<T>(validateFn: ValidateFn<T>, jsonSchemaFn: JsonSchemaFn): StandardJSONSchemaV1<T, T>;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a Standard Schema with separate input/output JSON Schemas.
|
|
71
|
+
*
|
|
72
|
+
* Use this when the input and output types differ (e.g., coercion, defaults).
|
|
73
|
+
*
|
|
74
|
+
* @template Input - The input type
|
|
75
|
+
* @template Output - The output type after transformation
|
|
76
|
+
* @param validateFn - The validation function
|
|
77
|
+
* @param inputSchemaFn - Function to generate input JSON Schema
|
|
78
|
+
* @param outputSchemaFn - Function to generate output JSON Schema
|
|
79
|
+
* @returns A Standard JSON Schema compliant object
|
|
80
|
+
*/
|
|
81
|
+
export declare function createSchemaWithSeparateJsonSchemas<Input, Output>(validateFn: ValidateFn<Output>, inputSchemaFn: JsonSchemaFn, outputSchemaFn: JsonSchemaFn): StandardJSONSchemaV1<Input, Output>;
|
|
82
|
+
/**
|
|
83
|
+
* Creates a validation success result.
|
|
84
|
+
*
|
|
85
|
+
* @template T - The value type
|
|
86
|
+
* @param value - The validated value
|
|
87
|
+
* @returns A successful validation result
|
|
88
|
+
*/
|
|
89
|
+
export declare function success<T>(value: T): ValidationResult<T>;
|
|
90
|
+
/**
|
|
91
|
+
* Creates a validation failure result.
|
|
92
|
+
*
|
|
93
|
+
* @param issues - The validation issues
|
|
94
|
+
* @returns A failed validation result
|
|
95
|
+
*/
|
|
96
|
+
export declare function failure(issues: ReadonlyArray<ValidationIssue>): ValidationResult<never>;
|
|
97
|
+
/**
|
|
98
|
+
* Creates a validation failure with a single issue.
|
|
99
|
+
*
|
|
100
|
+
* @param message - The error message
|
|
101
|
+
* @param path - Optional path to the invalid value
|
|
102
|
+
* @returns A failed validation result
|
|
103
|
+
*/
|
|
104
|
+
export declare function fail(message: string, path?: ReadonlyArray<string | number | {
|
|
105
|
+
readonly key: string | number;
|
|
106
|
+
}>): ValidationResult<never>;
|
|
107
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EAEhB,MAAM,SAAS,CAAC;AAEjB,2DAA2D;AAC3D,eAAO,MAAM,MAAM,EAAG,OAAgB,CAAC;AAEvC,mCAAmC;AACnC,eAAO,MAAM,OAAO,EAAG,CAAU,CAAC;AAElC;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,KAAK,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAQjF;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAC1C,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,YAAY,EAAE,YAAY,GACzB,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAY5B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,MAAM,EAC/D,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,EAC9B,aAAa,EAAE,YAAY,EAC3B,cAAc,EAAE,YAAY,GAC3B,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,CAYrC;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAExD;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAEvF;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAClB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,aAAa,CAAC,MAAM,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC,GACxE,gBAAgB,CAAC,KAAK,CAAC,CAGzB"}
|
package/dist/factory.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema factory functions for creating Standard Schema compliant objects.
|
|
3
|
+
*
|
|
4
|
+
* These factories wrap validation and JSON Schema generation functions
|
|
5
|
+
* into the Standard Schema format with the `~standard` property.
|
|
6
|
+
*/
|
|
7
|
+
/** The vendor name for schemas created by this library. */
|
|
8
|
+
export const VENDOR = 'valrs';
|
|
9
|
+
/** The Standard Schema version. */
|
|
10
|
+
export const VERSION = 1;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a Standard Schema from a validation function.
|
|
13
|
+
*
|
|
14
|
+
* This is the simplest way to create a compliant schema. The returned
|
|
15
|
+
* object has the `~standard` property with the validate function.
|
|
16
|
+
*
|
|
17
|
+
* @template T - The validated output type
|
|
18
|
+
* @param validateFn - The validation function
|
|
19
|
+
* @returns A Standard Schema compliant object
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const PositiveNumber = createSchema<number>((value) => {
|
|
24
|
+
* if (typeof value !== 'number') {
|
|
25
|
+
* return { issues: [{ message: 'Expected a number' }] };
|
|
26
|
+
* }
|
|
27
|
+
* if (value <= 0) {
|
|
28
|
+
* return { issues: [{ message: 'Must be positive' }] };
|
|
29
|
+
* }
|
|
30
|
+
* return { value };
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export function createSchema(validateFn) {
|
|
35
|
+
return {
|
|
36
|
+
'~standard': {
|
|
37
|
+
version: VERSION,
|
|
38
|
+
vendor: VENDOR,
|
|
39
|
+
validate: validateFn,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates a Standard Schema with JSON Schema generation support.
|
|
45
|
+
*
|
|
46
|
+
* This extends the basic schema with the ability to generate JSON Schema
|
|
47
|
+
* representations for different targets (Draft 2020-12, Draft 07, OpenAPI 3.0).
|
|
48
|
+
*
|
|
49
|
+
* @template T - The validated output type
|
|
50
|
+
* @param validateFn - The validation function
|
|
51
|
+
* @param jsonSchemaFn - Function to generate JSON Schema for a target
|
|
52
|
+
* @returns A Standard JSON Schema compliant object
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const StringSchema = createSchemaWithJsonSchema<string>(
|
|
57
|
+
* (value) => {
|
|
58
|
+
* if (typeof value !== 'string') {
|
|
59
|
+
* return { issues: [{ message: 'Expected a string' }] };
|
|
60
|
+
* }
|
|
61
|
+
* return { value };
|
|
62
|
+
* },
|
|
63
|
+
* (target) => ({ type: 'string' })
|
|
64
|
+
* );
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export function createSchemaWithJsonSchema(validateFn, jsonSchemaFn) {
|
|
68
|
+
return {
|
|
69
|
+
'~standard': {
|
|
70
|
+
version: VERSION,
|
|
71
|
+
vendor: VENDOR,
|
|
72
|
+
validate: validateFn,
|
|
73
|
+
jsonSchema: {
|
|
74
|
+
input: (options) => jsonSchemaFn(options.target),
|
|
75
|
+
output: (options) => jsonSchemaFn(options.target),
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Creates a Standard Schema with separate input/output JSON Schemas.
|
|
82
|
+
*
|
|
83
|
+
* Use this when the input and output types differ (e.g., coercion, defaults).
|
|
84
|
+
*
|
|
85
|
+
* @template Input - The input type
|
|
86
|
+
* @template Output - The output type after transformation
|
|
87
|
+
* @param validateFn - The validation function
|
|
88
|
+
* @param inputSchemaFn - Function to generate input JSON Schema
|
|
89
|
+
* @param outputSchemaFn - Function to generate output JSON Schema
|
|
90
|
+
* @returns A Standard JSON Schema compliant object
|
|
91
|
+
*/
|
|
92
|
+
export function createSchemaWithSeparateJsonSchemas(validateFn, inputSchemaFn, outputSchemaFn) {
|
|
93
|
+
return {
|
|
94
|
+
'~standard': {
|
|
95
|
+
version: VERSION,
|
|
96
|
+
vendor: VENDOR,
|
|
97
|
+
validate: validateFn,
|
|
98
|
+
jsonSchema: {
|
|
99
|
+
input: (options) => inputSchemaFn(options.target),
|
|
100
|
+
output: (options) => outputSchemaFn(options.target),
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Creates a validation success result.
|
|
107
|
+
*
|
|
108
|
+
* @template T - The value type
|
|
109
|
+
* @param value - The validated value
|
|
110
|
+
* @returns A successful validation result
|
|
111
|
+
*/
|
|
112
|
+
export function success(value) {
|
|
113
|
+
return { value };
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Creates a validation failure result.
|
|
117
|
+
*
|
|
118
|
+
* @param issues - The validation issues
|
|
119
|
+
* @returns A failed validation result
|
|
120
|
+
*/
|
|
121
|
+
export function failure(issues) {
|
|
122
|
+
return { issues };
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Creates a validation failure with a single issue.
|
|
126
|
+
*
|
|
127
|
+
* @param message - The error message
|
|
128
|
+
* @param path - Optional path to the invalid value
|
|
129
|
+
* @returns A failed validation result
|
|
130
|
+
*/
|
|
131
|
+
export function fail(message, path) {
|
|
132
|
+
const issue = path !== undefined ? { message, path } : { message };
|
|
133
|
+
return { issues: [issue] };
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,MAAM,GAAG,OAAgB,CAAC;AAEvC,mCAAmC;AACnC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAU,CAAC;AAYlC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,YAAY,CAAI,UAAyB;IACvD,OAAO;QACL,WAAW,EAAE;YACX,OAAO,EAAE,OAAO;YAChB,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,UAAU;SACrB;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,0BAA0B,CACxC,UAAyB,EACzB,YAA0B;IAE1B,OAAO;QACL,WAAW,EAAE;YACX,OAAO,EAAE,OAAO;YAChB,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,UAAU;YACpB,UAAU,EAAE;gBACV,KAAK,EAAE,CAAC,OAA0B,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC;gBACnE,MAAM,EAAE,CAAC,OAA0B,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC;aACrE;SACF;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mCAAmC,CACjD,UAA8B,EAC9B,aAA2B,EAC3B,cAA4B;IAE5B,OAAO;QACL,WAAW,EAAE;YACX,OAAO,EAAE,OAAO;YAChB,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,UAAU;YACpB,UAAU,EAAE;gBACV,KAAK,EAAE,CAAC,OAA0B,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC;gBACpE,MAAM,EAAE,CAAC,OAA0B,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC;aACvE;SACF;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAI,KAAQ;IACjC,OAAO,EAAE,KAAK,EAAE,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,MAAsC;IAC5D,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAClB,OAAe,EACf,IAAyE;IAEzE,MAAM,KAAK,GAAoB,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;IACpF,OAAO,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;AAC7B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* valrs
|
|
3
|
+
*
|
|
4
|
+
* Rust-powered Standard Schema implementation with WASM bindings.
|
|
5
|
+
*
|
|
6
|
+
* Provides both a Zod-compatible fluent API (`v`) and Standard Schema
|
|
7
|
+
* compliant exports for interoperability.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
* @see https://standardschema.dev/
|
|
11
|
+
*
|
|
12
|
+
* @example Zod-compatible API (recommended)
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { v } from 'valrs';
|
|
15
|
+
*
|
|
16
|
+
* // Create schemas with fluent API
|
|
17
|
+
* const nameSchema = v.string();
|
|
18
|
+
*
|
|
19
|
+
* // Parse and validate
|
|
20
|
+
* const name = nameSchema.parse('Alice');
|
|
21
|
+
*
|
|
22
|
+
* // Safe parsing (no exceptions)
|
|
23
|
+
* const result = nameSchema.safeParse(input);
|
|
24
|
+
* if (result.success) {
|
|
25
|
+
* console.log(result.data);
|
|
26
|
+
* } else {
|
|
27
|
+
* console.log(result.error.issues);
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* // Type inference
|
|
31
|
+
* type Name = v.infer<typeof nameSchema>; // string
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example Standard Schema API
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import { init, StringSchema, Int32Schema, isValidationSuccess } from 'valrs';
|
|
37
|
+
*
|
|
38
|
+
* async function main() {
|
|
39
|
+
* // Initialize the WASM module
|
|
40
|
+
* await init();
|
|
41
|
+
*
|
|
42
|
+
* // Validate a string
|
|
43
|
+
* const stringResult = StringSchema['~standard'].validate('hello');
|
|
44
|
+
* if (isValidationSuccess(stringResult)) {
|
|
45
|
+
* console.log(stringResult.value); // 'hello'
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
* // Validate an integer
|
|
49
|
+
* const intResult = Int32Schema['~standard'].validate(42);
|
|
50
|
+
* if (isValidationSuccess(intResult)) {
|
|
51
|
+
* console.log(intResult.value); // 42
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* // Get JSON Schema
|
|
55
|
+
* const schema = StringSchema['~standard'].jsonSchema.input({ target: 'draft-2020-12' });
|
|
56
|
+
* console.log(schema); // { type: 'string' }
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export type { StandardSchemaV1, StandardJSONSchemaV1, ValidationResult, ValidationIssue, PathSegment, JsonSchemaOptions, InferInput, InferOutput, } from './types';
|
|
61
|
+
export { isValidationSuccess, isValidationFailure } from './types';
|
|
62
|
+
export { init, isInitialized } from './wasm';
|
|
63
|
+
export type { WasmExports, WasmValidationResult } from './wasm';
|
|
64
|
+
export { createSchema, createSchemaWithJsonSchema, createSchemaWithSeparateJsonSchemas, success, failure, fail, VENDOR, VERSION, } from './factory';
|
|
65
|
+
export type { ValidateFn, JsonSchemaFn } from './factory';
|
|
66
|
+
export { StringSchema, NumberSchema, BooleanSchema, Int32Schema, Int64Schema, Uint32Schema, Uint64Schema, Float32Schema, Float64Schema, DoubleSchema, IntegerSchema, } from './primitives';
|
|
67
|
+
export { v, v as default } from './v';
|
|
68
|
+
export type { Infer, infer, input, output, SafeParseResult, SafeParseSuccess, SafeParseError } from './v';
|
|
69
|
+
export { ValSchema, ValString, ValNumber, ValBigInt, ValBoolean, ValDate, ValUndefined, ValNull, ValVoid, ValAny, ValUnknown, ValNever, ValInt32, ValInt64, ValUint32, ValUint64, ValFloat32, ValFloat64, ValObject, ValLiteral, ValArray, ValTuple, ValUnion, ValDiscriminatedUnion, ValIntersection, ValRecord, ValMap, ValSet, ValLiteralValue, ValEnum, ValNativeEnum, string, number, bigint, boolean, date, undefined, null, void, any, unknown, never, int32, int64, uint32, uint64, float32, float64, object, array, tuple, union, discriminatedUnion, intersection, record, map, set, literal, nativeEnum, wrap, preprocess, coerce, isSafeParseSuccess, isSafeParseError, } from './v';
|
|
70
|
+
export { enum } from './v';
|
|
71
|
+
export { ValOptional, ValNullable, ValNullish, ValDefault, ValCatch, ValTransformed, ValRefined, ValSuperRefined, ValPiped, ValPreprocessed, } from './schema';
|
|
72
|
+
export type { RefinementContext, RefinementOptions, TransformFn, RefinePredicate, SuperRefineFn, } from './schema';
|
|
73
|
+
export { ValError, setErrorMap, getErrorMap, resetErrorMap, getTypeName, createInvalidTypeIssue, createTooSmallIssue, createTooBigIssue, createInvalidStringIssue, createInvalidEnumValueIssue, createInvalidUnionIssue, createUnrecognizedKeysIssue, createCustomIssue, createInvalidLiteralIssue, createNotMultipleOfIssue, createNotFiniteIssue, createInvalidDateIssue, } from './error';
|
|
74
|
+
export type { ValIssueCode, ValIssueBase, ValIssue, InvalidTypeIssue, InvalidLiteralIssue, CustomIssue, InvalidUnionIssue, InvalidUnionDiscriminatorIssue, InvalidEnumValueIssue, UnrecognizedKeysIssue, InvalidArgumentsIssue, InvalidReturnTypeIssue, InvalidDateIssue, InvalidStringIssue, TooSmallIssue, TooBigIssue, InvalidIntersectionTypesIssue, NotMultipleOfIssue, NotFiniteIssue, SizeType, StringValidation, ErrorMapContext, ErrorMapFn, SchemaErrorOptions, FormattedError, FlattenedError, } from './error';
|
|
75
|
+
export { compileSchema, compileSchemaToCode, CompiledRegistry } from './compiler';
|
|
76
|
+
export type { JsonSchema, CompiledValidator } from './compiler';
|
|
77
|
+
export { stream, streamLines, createMockStream, createChunkedStream, } from './streaming';
|
|
78
|
+
export type { StreamOptions, StreamResult, StreamError, StreamResultWithErrors, StreamInput, } from './streaming';
|
|
79
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAGH,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,WAAW,GACZ,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAGnE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAA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AmB,GACpB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,aAAa,EACb,YAAY,EACZ,WAAW,EACX,sBAAsB,EACtB,WAAW,GACZ,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* valrs
|
|
3
|
+
*
|
|
4
|
+
* Rust-powered Standard Schema implementation with WASM bindings.
|
|
5
|
+
*
|
|
6
|
+
* Provides both a Zod-compatible fluent API (`v`) and Standard Schema
|
|
7
|
+
* compliant exports for interoperability.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
* @see https://standardschema.dev/
|
|
11
|
+
*
|
|
12
|
+
* @example Zod-compatible API (recommended)
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { v } from 'valrs';
|
|
15
|
+
*
|
|
16
|
+
* // Create schemas with fluent API
|
|
17
|
+
* const nameSchema = v.string();
|
|
18
|
+
*
|
|
19
|
+
* // Parse and validate
|
|
20
|
+
* const name = nameSchema.parse('Alice');
|
|
21
|
+
*
|
|
22
|
+
* // Safe parsing (no exceptions)
|
|
23
|
+
* const result = nameSchema.safeParse(input);
|
|
24
|
+
* if (result.success) {
|
|
25
|
+
* console.log(result.data);
|
|
26
|
+
* } else {
|
|
27
|
+
* console.log(result.error.issues);
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* // Type inference
|
|
31
|
+
* type Name = v.infer<typeof nameSchema>; // string
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example Standard Schema API
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import { init, StringSchema, Int32Schema, isValidationSuccess } from 'valrs';
|
|
37
|
+
*
|
|
38
|
+
* async function main() {
|
|
39
|
+
* // Initialize the WASM module
|
|
40
|
+
* await init();
|
|
41
|
+
*
|
|
42
|
+
* // Validate a string
|
|
43
|
+
* const stringResult = StringSchema['~standard'].validate('hello');
|
|
44
|
+
* if (isValidationSuccess(stringResult)) {
|
|
45
|
+
* console.log(stringResult.value); // 'hello'
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
* // Validate an integer
|
|
49
|
+
* const intResult = Int32Schema['~standard'].validate(42);
|
|
50
|
+
* if (isValidationSuccess(intResult)) {
|
|
51
|
+
* console.log(intResult.value); // 42
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* // Get JSON Schema
|
|
55
|
+
* const schema = StringSchema['~standard'].jsonSchema.input({ target: 'draft-2020-12' });
|
|
56
|
+
* console.log(schema); // { type: 'string' }
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export { isValidationSuccess, isValidationFailure } from './types';
|
|
61
|
+
// WASM initialization
|
|
62
|
+
export { init, isInitialized } from './wasm';
|
|
63
|
+
// Schema factory functions
|
|
64
|
+
export { createSchema, createSchemaWithJsonSchema, createSchemaWithSeparateJsonSchemas, success, failure, fail, VENDOR, VERSION, } from './factory';
|
|
65
|
+
// Primitive schemas
|
|
66
|
+
export { StringSchema, NumberSchema, BooleanSchema, Int32Schema, Int64Schema, Uint32Schema, Uint64Schema, Float32Schema, Float64Schema, DoubleSchema, IntegerSchema, } from './primitives';
|
|
67
|
+
// Zod-compatible fluent API
|
|
68
|
+
export { v, v as default } from './v';
|
|
69
|
+
export {
|
|
70
|
+
// Schema classes - primitives
|
|
71
|
+
ValSchema, ValString, ValNumber, ValBigInt, ValBoolean, ValDate, ValUndefined, ValNull, ValVoid, ValAny, ValUnknown, ValNever, ValInt32, ValInt64, ValUint32, ValUint64, ValFloat32, ValFloat64,
|
|
72
|
+
// Schema classes - composite
|
|
73
|
+
ValObject, ValLiteral,
|
|
74
|
+
// Schema classes - Phase 4
|
|
75
|
+
ValArray, ValTuple, ValUnion, ValDiscriminatedUnion, ValIntersection, ValRecord, ValMap, ValSet, ValLiteralValue, ValEnum, ValNativeEnum,
|
|
76
|
+
// Builder functions - primitives
|
|
77
|
+
string, number, bigint, boolean, date, undefined, null, void, any, unknown, never, int32, int64, uint32, uint64, float32, float64,
|
|
78
|
+
// Builder functions - composite
|
|
79
|
+
object,
|
|
80
|
+
// Builder functions - Phase 4
|
|
81
|
+
array, tuple, union, discriminatedUnion, intersection, record, map, set, literal, nativeEnum,
|
|
82
|
+
// Utilities
|
|
83
|
+
wrap,
|
|
84
|
+
// Phase 5: Transform and refinement utilities
|
|
85
|
+
preprocess, coerce,
|
|
86
|
+
// Type guards
|
|
87
|
+
isSafeParseSuccess, isSafeParseError, } from './v';
|
|
88
|
+
// Use 'enum' as a named export (reserved word)
|
|
89
|
+
export { enum } from './v';
|
|
90
|
+
// Wrapper schema classes
|
|
91
|
+
export { ValOptional, ValNullable, ValNullish, ValDefault, ValCatch,
|
|
92
|
+
// Phase 5: Transform and refinement wrappers
|
|
93
|
+
ValTransformed, ValRefined, ValSuperRefined, ValPiped, ValPreprocessed, } from './schema';
|
|
94
|
+
// Error types and formatting (Phase 7)
|
|
95
|
+
export { ValError,
|
|
96
|
+
// Error map functions
|
|
97
|
+
setErrorMap, getErrorMap, resetErrorMap,
|
|
98
|
+
// Issue creation helpers
|
|
99
|
+
getTypeName, createInvalidTypeIssue, createTooSmallIssue, createTooBigIssue, createInvalidStringIssue, createInvalidEnumValueIssue, createInvalidUnionIssue, createUnrecognizedKeysIssue, createCustomIssue, createInvalidLiteralIssue, createNotMultipleOfIssue, createNotFiniteIssue, createInvalidDateIssue, } from './error';
|
|
100
|
+
// Schema compiler (JS code generation)
|
|
101
|
+
export { compileSchema, compileSchemaToCode, CompiledRegistry } from './compiler';
|
|
102
|
+
// Phase 6: Streaming validation
|
|
103
|
+
export { stream, streamLines, createMockStream, createChunkedStream, } from './streaming';
|
|
104
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;AAC9B,KAAK,EACL,KAAK,EACL,KAAK,EACL,kBAAkB,EAClB,YAAY,EACZ,MAAM,EACN,GAAG,EACH,GAAG,EACH,OAAO,EACP,UAAU;AACV,YAAY;AACZ,IAAI;AACJ,8CAA8C;AAC9C,UAAU,EACV,MAAM;AACN,cAAc;AACd,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,KAAK,CAAC;AAEb,+CAA+C;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,yBAAyB;AACzB,OAAO,EACL,WAAW,EACX,WAAW,EACX,UAAU,EACV,UAAU,EACV,QAAQ;AACR,6CAA6C;AAC7C,cAAc,EACd,UAAU,EACV,eAAe,EACf,QAAQ,EACR,eAAe,GAChB,MAAM,UAAU,CAAC;AAWlB,uCAAuC;AACvC,OAAO,EACL,QAAQ;AACR,sBAAsB;AACtB,WAAW,EACX,WAAW,EACX,aAAa;AACb,yBAAyB;AACzB,WAAW,EACX,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,EACxB,2BAA2B,EAC3B,uBAAuB,EACvB,2BAA2B,EAC3B,iBAAiB,EACjB,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,SAAS,CAAC;AAqCjB,uCAAuC;AACvC,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGlF,gCAAgC;AAChC,OAAO,EACL,MAAM,EACN,WAAW,EACX,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Primitive schema definitions.
|
|
3
|
+
*
|
|
4
|
+
* These schemas validate JavaScript primitives using the WASM bindings.
|
|
5
|
+
* Each schema implements both validation and JSON Schema generation.
|
|
6
|
+
*/
|
|
7
|
+
import type { StandardJSONSchemaV1 } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Schema for validating string values.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { init, StringSchema } from 'valrs';
|
|
14
|
+
*
|
|
15
|
+
* await init();
|
|
16
|
+
*
|
|
17
|
+
* const result = StringSchema['~standard'].validate('hello');
|
|
18
|
+
* // { value: 'hello' }
|
|
19
|
+
*
|
|
20
|
+
* const invalid = StringSchema['~standard'].validate(123);
|
|
21
|
+
* // { issues: [{ message: 'Expected string' }] }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const StringSchema: StandardJSONSchemaV1<string, string>;
|
|
25
|
+
/**
|
|
26
|
+
* Schema for validating number values (JavaScript number, IEEE 754 double).
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const result = NumberSchema['~standard'].validate(3.14);
|
|
31
|
+
* // { value: 3.14 }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare const NumberSchema: StandardJSONSchemaV1<number, number>;
|
|
35
|
+
/**
|
|
36
|
+
* Schema for validating boolean values.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const result = BooleanSchema['~standard'].validate(true);
|
|
41
|
+
* // { value: true }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare const BooleanSchema: StandardJSONSchemaV1<boolean, boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* Schema for validating 32-bit signed integers.
|
|
47
|
+
*
|
|
48
|
+
* Range: -2,147,483,648 to 2,147,483,647
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const result = Int32Schema['~standard'].validate(42);
|
|
53
|
+
* // { value: 42 }
|
|
54
|
+
*
|
|
55
|
+
* const invalid = Int32Schema['~standard'].validate(3.14);
|
|
56
|
+
* // { issues: [{ message: 'Expected i32' }] }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare const Int32Schema: StandardJSONSchemaV1<number, number>;
|
|
60
|
+
/**
|
|
61
|
+
* Schema for validating 64-bit signed integers.
|
|
62
|
+
*
|
|
63
|
+
* Note: JavaScript numbers can only safely represent integers up to 2^53 - 1.
|
|
64
|
+
* For full i64 range, consider using BigInt.
|
|
65
|
+
*
|
|
66
|
+
* Range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
|
|
67
|
+
*/
|
|
68
|
+
export declare const Int64Schema: StandardJSONSchemaV1<number, number>;
|
|
69
|
+
/**
|
|
70
|
+
* Schema for validating 32-bit unsigned integers.
|
|
71
|
+
*
|
|
72
|
+
* Range: 0 to 4,294,967,295
|
|
73
|
+
*/
|
|
74
|
+
export declare const Uint32Schema: StandardJSONSchemaV1<number, number>;
|
|
75
|
+
/**
|
|
76
|
+
* Schema for validating 64-bit unsigned integers.
|
|
77
|
+
*
|
|
78
|
+
* Note: JavaScript numbers can only safely represent integers up to 2^53 - 1.
|
|
79
|
+
*
|
|
80
|
+
* Range: 0 to 18,446,744,073,709,551,615
|
|
81
|
+
*/
|
|
82
|
+
export declare const Uint64Schema: StandardJSONSchemaV1<number, number>;
|
|
83
|
+
/**
|
|
84
|
+
* Schema for validating 32-bit floating point numbers.
|
|
85
|
+
*/
|
|
86
|
+
export declare const Float32Schema: StandardJSONSchemaV1<number, number>;
|
|
87
|
+
/**
|
|
88
|
+
* Schema for validating 64-bit floating point numbers.
|
|
89
|
+
*/
|
|
90
|
+
export declare const Float64Schema: StandardJSONSchemaV1<number, number>;
|
|
91
|
+
/**
|
|
92
|
+
* Alias for Float64Schema - the default JavaScript number type.
|
|
93
|
+
*/
|
|
94
|
+
export { Float64Schema as DoubleSchema };
|
|
95
|
+
/**
|
|
96
|
+
* Alias for Int32Schema - commonly used integer type.
|
|
97
|
+
*/
|
|
98
|
+
export { Int32Schema as IntegerSchema };
|
|
99
|
+
//# sourceMappingURL=primitives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../src/primitives.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAqC,MAAM,SAAS,CAAC;AAmBvF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,YAAY,EAAE,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAuB7D,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,EAAE,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAqB7D,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,EAAE,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAqBhE,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,EAAE,oBAAoB,CAAC,MAAM,EAAE,MAAM,CA8B5D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,EAAE,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAqB5D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,oBAAoB,CAAC,MAAM,EAAE,MAAM,CA6B7D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAqB7D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAqB9D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAqB9D,CAAC;AAEF;;GAEG;AACH,OAAO,EAAE,aAAa,IAAI,YAAY,EAAE,CAAC;AAEzC;;GAEG;AACH,OAAO,EAAE,WAAW,IAAI,aAAa,EAAE,CAAC"}
|