@gravito/mass 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -76
- package/README.zh-TW.md +120 -11
- package/dist/coercion.d.ts +233 -0
- package/dist/coercion.d.ts.map +1 -0
- package/dist/errors.d.ts +169 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/formats.d.ts +98 -0
- package/dist/formats.d.ts.map +1 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +526 -5
- package/dist/openapi.d.ts +215 -0
- package/dist/openapi.d.ts.map +1 -0
- package/dist/types.d.ts +53 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +23 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/validator.d.ts +47 -0
- package/dist/validator.d.ts.map +1 -0
- package/package.json +9 -7
- package/dist/mass/src/index.d.ts +0 -30
- package/dist/mass/src/index.d.ts.map +0 -1
- package/dist/mass/src/validator.d.ts +0 -28
- package/dist/mass/src/validator.d.ts.map +0 -1
- package/dist/photon/src/index.d.ts +0 -21
- package/dist/photon/src/index.d.ts.map +0 -1
- package/dist/photon/src/middleware/binary.d.ts +0 -35
- package/dist/photon/src/middleware/binary.d.ts.map +0 -1
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { ValueError } from '@sinclair/typebox/errors';
|
|
2
|
+
import type { ValidationSource } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Error Messages - Traditional Chinese
|
|
5
|
+
*
|
|
6
|
+
* Provides common validation error messages in Traditional Chinese.
|
|
7
|
+
*/
|
|
8
|
+
export declare const ERROR_MESSAGES_ZH_TW: {
|
|
9
|
+
readonly REQUIRED: "此欄位為必填";
|
|
10
|
+
readonly INVALID_TYPE: "資料型別不正確";
|
|
11
|
+
readonly INVALID_EMAIL: "電子郵件格式不正確";
|
|
12
|
+
readonly INVALID_URL: "網址格式不正確";
|
|
13
|
+
readonly INVALID_UUID: "UUID 格式不正確";
|
|
14
|
+
readonly INVALID_DATE: "日期格式不正確";
|
|
15
|
+
readonly TOO_SHORT: "長度過短";
|
|
16
|
+
readonly TOO_LONG: "長度過長";
|
|
17
|
+
readonly TOO_SMALL: "數值過小";
|
|
18
|
+
readonly TOO_LARGE: "數值過大";
|
|
19
|
+
readonly INVALID_PATTERN: "格式不符合規則";
|
|
20
|
+
readonly INVALID_FORMAT: "格式不正確";
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Error Messages - English
|
|
24
|
+
*
|
|
25
|
+
* Provides common validation error messages in English.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ERROR_MESSAGES_EN: {
|
|
28
|
+
readonly REQUIRED: "This field is required";
|
|
29
|
+
readonly INVALID_TYPE: "Invalid data type";
|
|
30
|
+
readonly INVALID_EMAIL: "Invalid email format";
|
|
31
|
+
readonly INVALID_URL: "Invalid URL format";
|
|
32
|
+
readonly INVALID_UUID: "Invalid UUID format";
|
|
33
|
+
readonly INVALID_DATE: "Invalid date format";
|
|
34
|
+
readonly TOO_SHORT: "Too short";
|
|
35
|
+
readonly TOO_LONG: "Too long";
|
|
36
|
+
readonly TOO_SMALL: "Value too small";
|
|
37
|
+
readonly TOO_LARGE: "Value too large";
|
|
38
|
+
readonly INVALID_PATTERN: "Does not match required pattern";
|
|
39
|
+
readonly INVALID_FORMAT: "Invalid format";
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Error Formatter Function Type
|
|
43
|
+
*
|
|
44
|
+
* Function type for converting TypeBox errors into a custom format.
|
|
45
|
+
*/
|
|
46
|
+
export type ErrorFormatter = (error: ValueError) => {
|
|
47
|
+
path: string;
|
|
48
|
+
message: string;
|
|
49
|
+
expected?: string;
|
|
50
|
+
received?: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Custom error class thrown or returned when validation fails.
|
|
54
|
+
*
|
|
55
|
+
* This class encapsulates the validation error details and the source of the data
|
|
56
|
+
* (e.g., 'json', 'query') that failed validation. It is suitable for use in
|
|
57
|
+
* exception filters or global error handlers.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* throw new MassValidationError('json', [
|
|
62
|
+
* { path: '/email', message: 'Invalid email format' }
|
|
63
|
+
* ])
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare class MassValidationError extends Error {
|
|
67
|
+
readonly source: ValidationSource;
|
|
68
|
+
readonly errors: Array<{
|
|
69
|
+
path: string;
|
|
70
|
+
message: string;
|
|
71
|
+
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Creates a new MassValidationError instance.
|
|
74
|
+
*
|
|
75
|
+
* @param source - The source of the invalid data
|
|
76
|
+
* @param errors - The list of validation errors
|
|
77
|
+
*/
|
|
78
|
+
constructor(source: ValidationSource, errors: Array<{
|
|
79
|
+
path: string;
|
|
80
|
+
message: string;
|
|
81
|
+
}>);
|
|
82
|
+
/**
|
|
83
|
+
* Serializes the error to a JSON-compatible object.
|
|
84
|
+
*
|
|
85
|
+
* @returns A structured error object suitable for API responses
|
|
86
|
+
*/
|
|
87
|
+
toJSON(): {
|
|
88
|
+
error: string;
|
|
89
|
+
source: ValidationSource;
|
|
90
|
+
details: {
|
|
91
|
+
path: string;
|
|
92
|
+
message: string;
|
|
93
|
+
}[];
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Enhances TypeBox Validation Errors.
|
|
98
|
+
*
|
|
99
|
+
* Converts raw TypeBox errors into structured error objects with more context,
|
|
100
|
+
* suitable for returning directly to clients or logging.
|
|
101
|
+
*
|
|
102
|
+
* @param error - The raw TypeBox validation error
|
|
103
|
+
* @param locale - Locale ('zh-TW' or 'en'), defaults to 'zh-TW'
|
|
104
|
+
* @returns Enhanced error object
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* import { Value } from '@sinclair/typebox/value'
|
|
109
|
+
*
|
|
110
|
+
* const errors = [...Value.Errors(schema, data)]
|
|
111
|
+
* const enhanced = errors.map(err => enhanceError(err, 'zh-TW'))
|
|
112
|
+
* // [{ path: '/email', message: '電子郵件格式不正確', expected: 'string<email>', received: 'string' }]
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export declare function enhanceError(error: ValueError, locale?: 'zh-TW' | 'en'): {
|
|
116
|
+
path: string;
|
|
117
|
+
message: string;
|
|
118
|
+
expected?: string;
|
|
119
|
+
received?: string;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Creates Custom Error Formatter.
|
|
123
|
+
*
|
|
124
|
+
* High-order function that allows creating custom error formatting logic for TypeBox validation errors.
|
|
125
|
+
* Useful for standardizing error formats or supporting multiple languages.
|
|
126
|
+
*
|
|
127
|
+
* @param formatter - Custom formatter function
|
|
128
|
+
* @returns Error formatter function
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const myFormatter = createErrorFormatter((error) => ({
|
|
133
|
+
* path: error.path,
|
|
134
|
+
* message: `Custom Message: ${error.message}`,
|
|
135
|
+
* code: 'VALIDATION_ERROR'
|
|
136
|
+
* }))
|
|
137
|
+
*
|
|
138
|
+
* const errors = [...Value.Errors(schema, data)]
|
|
139
|
+
* const formatted = errors.map(myFormatter)
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
export declare function createErrorFormatter(formatter: (error: ValueError) => {
|
|
143
|
+
path: string;
|
|
144
|
+
message: string;
|
|
145
|
+
[key: string]: unknown;
|
|
146
|
+
}): ErrorFormatter;
|
|
147
|
+
/**
|
|
148
|
+
* Formats a flat list of validation errors into a field-grouped structure.
|
|
149
|
+
*
|
|
150
|
+
* This helper transforms TypeBox's error format into a more frontend-friendly
|
|
151
|
+
* format where errors are grouped by field name.
|
|
152
|
+
*
|
|
153
|
+
* @param errors - The raw validation errors
|
|
154
|
+
* @returns An object where keys are field names and values are arrays of error messages
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* const errors = [{ path: '/user/name', message: 'Required' }]
|
|
159
|
+
* const formatted = formatErrors(errors)
|
|
160
|
+
* // Result: { fields: { 'user.name': ['Required'] } }
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export declare function formatErrors(errors: Array<{
|
|
164
|
+
path: string;
|
|
165
|
+
message: string;
|
|
166
|
+
}>): {
|
|
167
|
+
fields: Record<string, string[]>;
|
|
168
|
+
};
|
|
169
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;CAavB,CAAA;AAEV;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;CAapB,CAAA;AAEV;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK;IAClD,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;aAQ1B,MAAM,EAAE,gBAAgB;aACxB,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IARlE;;;;;OAKG;gBAEe,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAMlE;;;;OAIG;IACH,MAAM;;;;kBAXkC,MAAM;qBAAW,MAAM;;;CAkBhE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,UAAU,EACjB,MAAM,GAAE,OAAO,GAAG,IAAc,GAC/B;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAsDA;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB,GACA,cAAc,CAUhB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG;IAC9E,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;CACjC,CAYA"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-registered Format Names.
|
|
3
|
+
*
|
|
4
|
+
* Provides common data format validators including email, url, uuid, date-time, etc.
|
|
5
|
+
*/
|
|
6
|
+
export declare const REGISTERED_FORMATS: readonly ["email", "uri", "uri-reference", "uuid", "date-time", "date", "time", "ipv4", "ipv6"];
|
|
7
|
+
export type RegisteredFormat = (typeof REGISTERED_FORMATS)[number];
|
|
8
|
+
/**
|
|
9
|
+
* Registers Custom Format Validator.
|
|
10
|
+
*
|
|
11
|
+
* Allows registering custom format validation logic to TypeBox's FormatRegistry.
|
|
12
|
+
* Once registered, can be used in Schema.String() via the format option.
|
|
13
|
+
*
|
|
14
|
+
* @param name - Format name (e.g., 'phone-number', 'credit-card')
|
|
15
|
+
* @param validator - Validation function, returns true if valid
|
|
16
|
+
*
|
|
17
|
+
* @example Register Taiwan Phone Number Format
|
|
18
|
+
* ```typescript
|
|
19
|
+
* registerFormat('tw-phone', (value) => /^09\d{8}$/.test(value))
|
|
20
|
+
*
|
|
21
|
+
* const schema = Schema.String({ format: 'tw-phone' })
|
|
22
|
+
* const valid = Value.Check(schema, '0912345678') // true
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example Register Credit Card Format (Simplified)
|
|
26
|
+
* ```typescript
|
|
27
|
+
* registerFormat('credit-card', (value) => {
|
|
28
|
+
* const cleaned = value.replace(/\s/g, '')
|
|
29
|
+
* return /^\d{13,19}$/.test(cleaned)
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function registerFormat(name: string, validator: (value: string) => boolean): void;
|
|
34
|
+
/**
|
|
35
|
+
* Registers All Predefined Format Validators.
|
|
36
|
+
*
|
|
37
|
+
* Registers all common formats (email, url, uuid, etc.) to TypeBox's FormatRegistry.
|
|
38
|
+
* Typically called once at application startup.
|
|
39
|
+
*
|
|
40
|
+
* @example Register at Application Entry Point
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import { registerAllFormats } from '@gravito/mass'
|
|
43
|
+
*
|
|
44
|
+
* // Register all predefined formats
|
|
45
|
+
* registerAllFormats()
|
|
46
|
+
*
|
|
47
|
+
* // Now you can use these formats in schemas
|
|
48
|
+
* const userSchema = Schema.Object({
|
|
49
|
+
* email: Schema.String({ format: 'email' }),
|
|
50
|
+
* website: Schema.String({ format: 'uri' }),
|
|
51
|
+
* id: Schema.String({ format: 'uuid' })
|
|
52
|
+
* })
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function registerAllFormats(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Checks if a Specific Format is Registered.
|
|
58
|
+
*
|
|
59
|
+
* @param name - Format name
|
|
60
|
+
* @returns True if the format is registered
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* registerFormat('custom-format', (value) => true)
|
|
65
|
+
* isFormatRegistered('custom-format') // true
|
|
66
|
+
* isFormatRegistered('unknown-format') // false
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function isFormatRegistered(name: string): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Gets Registered Format Validator.
|
|
72
|
+
*
|
|
73
|
+
* @param name - Format name
|
|
74
|
+
* @returns Validation function, or undefined if not registered
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const emailValidator = getFormatValidator('email')
|
|
79
|
+
* if (emailValidator) {
|
|
80
|
+
* const isValid = emailValidator('test@example.com') // true
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare function getFormatValidator(name: string): ((value: string) => boolean) | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Removes Registered Format Validator.
|
|
87
|
+
*
|
|
88
|
+
* @param name - Format name
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* registerFormat('temp-format', (value) => true)
|
|
93
|
+
* unregisterFormat('temp-format')
|
|
94
|
+
* isFormatRegistered('temp-format') // false
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare function unregisterFormat(name: string): void;
|
|
98
|
+
//# sourceMappingURL=formats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formats.d.ts","sourceRoot":"","sources":["../src/formats.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,iGAUrB,CAAA;AAEV,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAA;AAmFlE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAExF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAIzC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,SAAS,CAEzF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEnD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @gravito/mass - TypeBox-based validation for Gravito Galaxy Architecture.
|
|
3
|
+
*
|
|
4
|
+
* Mass provides high-performance schema validation with full TypeScript support,
|
|
5
|
+
* seamlessly integrating with Photon middleware system. Named after the concept
|
|
6
|
+
* of "mass" in physics, this package provides the "weight" of data integrity
|
|
7
|
+
* to your API endpoints.
|
|
8
|
+
*
|
|
9
|
+
* ## Key Features
|
|
10
|
+
*
|
|
11
|
+
* - **Zero-overhead TypeBox validation** - Generates validators at build-time for faster runtime performance
|
|
12
|
+
* - **Full TypeScript inference** - Validated data is fully typed without manual typings
|
|
13
|
+
* - **Multiple validation sources** - Validate JSON, query, params, and form data
|
|
14
|
+
* - **Custom error handling hooks** - Override default error responses
|
|
15
|
+
* - **Seamless Photon/Hono integration** - Works out of the box with Gravito's HTTP layer
|
|
16
|
+
*
|
|
17
|
+
* @example Basic JSON validation
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { Photon } from '@gravito/photon'
|
|
20
|
+
* import { Schema, validate } from '@gravito/mass'
|
|
21
|
+
*
|
|
22
|
+
* const app = new Photon()
|
|
23
|
+
*
|
|
24
|
+
* const loginSchema = Schema.Object({
|
|
25
|
+
* username: Schema.String({ minLength: 3, maxLength: 50 }),
|
|
26
|
+
* password: Schema.String({ minLength: 8 })
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* app.post('/login', validate('json', loginSchema), (c) => {
|
|
30
|
+
* const { username } = c.req.valid('json')
|
|
31
|
+
* // username is fully typed as string
|
|
32
|
+
* return c.json({ success: true, user: username })
|
|
33
|
+
* })
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example Custom error handling
|
|
37
|
+
* ```typescript
|
|
38
|
+
* app.post('/register',
|
|
39
|
+
* validate('json', registerSchema, (result, c) => {
|
|
40
|
+
* if (!result.success) {
|
|
41
|
+
* return c.json({
|
|
42
|
+
* error: 'Validation failed',
|
|
43
|
+
* details: result.errors
|
|
44
|
+
* }, 400)
|
|
45
|
+
* }
|
|
46
|
+
* }),
|
|
47
|
+
* handler
|
|
48
|
+
* )
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @example Query parameter validation
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const searchSchema = Schema.Object({
|
|
54
|
+
* q: Schema.String(),
|
|
55
|
+
* page: Schema.Optional(Schema.Number({ minimum: 1, default: 1 })),
|
|
56
|
+
* limit: Schema.Optional(Schema.Number({ minimum: 1, maximum: 100, default: 20 }))
|
|
57
|
+
* })
|
|
58
|
+
*
|
|
59
|
+
* app.get('/search', validate('query', searchSchema), (c) => {
|
|
60
|
+
* const { q, page, limit } = c.req.valid('query')
|
|
61
|
+
* return c.json({ query: q, page, limit })
|
|
62
|
+
* })
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @see {@link validate} - Main validation middleware
|
|
66
|
+
* @see {@link Schema} - TypeBox schema builders
|
|
67
|
+
* @see {@link https://github.com/sinclairzx81/typebox | TypeBox Documentation}
|
|
68
|
+
*
|
|
69
|
+
* @packageDocumentation
|
|
70
|
+
*/
|
|
71
|
+
export { tbValidator as validator } from '@hono/typebox-validator';
|
|
72
|
+
export type { Static, TSchema } from '@sinclair/typebox';
|
|
73
|
+
export * as Schema from '@sinclair/typebox';
|
|
74
|
+
export { CoercibleBoolean, CoercibleInteger, CoercibleNumber, coerceBoolean, coerceData, coerceDate, coerceInteger, coerceNumber, validateWithCoercion, } from './coercion';
|
|
75
|
+
export { createErrorFormatter, ERROR_MESSAGES_EN, ERROR_MESSAGES_ZH_TW, type ErrorFormatter, enhanceError, formatErrors, MassValidationError, } from './errors';
|
|
76
|
+
export { getFormatValidator, isFormatRegistered, REGISTERED_FORMATS, type RegisteredFormat, registerAllFormats, registerFormat, unregisterFormat, } from './formats';
|
|
77
|
+
export { type AstralResource, createAstralResource, createCrudResources, type OpenApiSchema, typeboxToOpenApi, } from './openapi';
|
|
78
|
+
export type { ValidationError, ValidationHook, ValidationResult, } from './types';
|
|
79
|
+
export { partial } from './utils';
|
|
80
|
+
export { type ValidationSource, validate } from './validator';
|
|
81
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAGH,OAAO,EAAE,WAAW,IAAI,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAGlE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAE3C,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,UAAU,EACV,UAAU,EACV,aAAa,EACb,YAAY,EACZ,oBAAoB,GACrB,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,cAAc,EACnB,YAAY,EACZ,YAAY,EACZ,mBAAmB,GACpB,MAAM,UAAU,CAAA;AAEjB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GACjB,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,KAAK,cAAc,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,aAAa,EAClB,gBAAgB,GACjB,MAAM,WAAW,CAAA;AAElB,YAAY,EACV,eAAe,EACf,cAAc,EACd,gBAAgB,GACjB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjC,OAAO,EAAE,KAAK,gBAAgB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA"}
|