typia 12.0.0-dev.20260309 → 12.0.0-dev.20260310
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/lib/executable/setup/PluginConfigurator.js +3 -3
- package/lib/executable/setup/PluginConfigurator.mjs +3 -3
- package/lib/executable/setup/PluginConfigurator.mjs.map +1 -1
- package/lib/executable/typia.js +15 -15
- package/lib/executable/typia.mjs +15 -15
- package/package.json +5 -5
- package/src/TypeGuardError.ts +145 -145
- package/src/executable/TypiaGenerateWizard.ts +82 -82
- package/src/executable/TypiaPatchWizard.ts +45 -45
- package/src/executable/TypiaSetupWizard.ts +171 -171
- package/src/executable/setup/ArgumentParser.ts +42 -42
- package/src/executable/setup/CommandExecutor.ts +8 -8
- package/src/executable/setup/FileRetriever.ts +19 -19
- package/src/executable/setup/PackageManager.ts +87 -87
- package/src/executable/setup/PluginConfigurator.ts +74 -74
- package/src/executable/typia.ts +55 -55
- package/src/functional.ts +600 -600
- package/src/http.ts +843 -843
- package/src/index.ts +4 -4
- package/src/internal/_IProtobufWriter.ts +18 -18
- package/src/internal/_ProtobufReader.ts +187 -187
- package/src/internal/_ProtobufSizer.ts +137 -137
- package/src/internal/_ProtobufWriter.ts +135 -135
- package/src/internal/_accessExpressionAsString.ts +46 -46
- package/src/internal/_assertGuard.ts +13 -13
- package/src/internal/_coerceLlmArguments.ts +7 -7
- package/src/internal/_createStandardSchema.ts +133 -133
- package/src/internal/_functionalTypeGuardErrorFactory.ts +4 -4
- package/src/internal/_httpFormDataReadArray.ts +4 -4
- package/src/internal/_httpFormDataReadBigint.ts +18 -18
- package/src/internal/_httpFormDataReadBlob.ts +10 -10
- package/src/internal/_httpFormDataReadBoolean.ts +16 -16
- package/src/internal/_httpFormDataReadFile.ts +10 -10
- package/src/internal/_httpFormDataReadNumber.ts +15 -15
- package/src/internal/_httpFormDataReadString.ts +10 -10
- package/src/internal/_httpHeaderReadBigint.ts +10 -10
- package/src/internal/_httpHeaderReadBoolean.ts +8 -8
- package/src/internal/_httpHeaderReadNumber.ts +7 -7
- package/src/internal/_httpParameterReadBigint.ts +10 -10
- package/src/internal/_httpParameterReadBoolean.ts +8 -8
- package/src/internal/_httpParameterReadNumber.ts +7 -7
- package/src/internal/_httpParameterReadString.ts +2 -2
- package/src/internal/_httpQueryParseURLSearchParams.ts +12 -12
- package/src/internal/_httpQueryReadArray.ts +4 -4
- package/src/internal/_httpQueryReadBigint.ts +12 -12
- package/src/internal/_httpQueryReadBoolean.ts +14 -14
- package/src/internal/_httpQueryReadNumber.ts +9 -9
- package/src/internal/_httpQueryReadString.ts +4 -4
- package/src/internal/_isBetween.ts +2 -2
- package/src/internal/_isBigintString.ts +8 -8
- package/src/internal/_isFormatByte.ts +7 -7
- package/src/internal/_isFormatDate.ts +3 -3
- package/src/internal/_isFormatDateTime.ts +4 -4
- package/src/internal/_isFormatDuration.ts +4 -4
- package/src/internal/_isFormatEmail.ts +4 -4
- package/src/internal/_isFormatHostname.ts +4 -4
- package/src/internal/_isFormatIdnEmail.ts +4 -4
- package/src/internal/_isFormatIdnHostname.ts +4 -4
- package/src/internal/_isFormatIpv4.ts +4 -4
- package/src/internal/_isFormatIpv6.ts +4 -4
- package/src/internal/_isFormatIri.ts +3 -3
- package/src/internal/_isFormatIriReference.ts +4 -4
- package/src/internal/_isFormatJsonPointer.ts +3 -3
- package/src/internal/_isFormatPassword.ts +1 -1
- package/src/internal/_isFormatRegex.ts +8 -8
- package/src/internal/_isFormatRelativeJsonPointer.ts +4 -4
- package/src/internal/_isFormatTime.ts +4 -4
- package/src/internal/_isFormatUri.ts +6 -6
- package/src/internal/_isFormatUriReference.ts +5 -5
- package/src/internal/_isFormatUriTemplate.ts +4 -4
- package/src/internal/_isFormatUrl.ts +4 -4
- package/src/internal/_isFormatUuid.ts +3 -3
- package/src/internal/_isTypeFloat.ts +5 -5
- package/src/internal/_isTypeInt32.ts +5 -5
- package/src/internal/_isTypeInt64.ts +5 -5
- package/src/internal/_isTypeUint32.ts +5 -5
- package/src/internal/_isTypeUint64.ts +5 -5
- package/src/internal/_isUniqueItems.ts +159 -159
- package/src/internal/_jsonStringifyNumber.ts +12 -12
- package/src/internal/_jsonStringifyRest.ts +3 -3
- package/src/internal/_jsonStringifyString.ts +42 -42
- package/src/internal/_jsonStringifyTail.ts +2 -2
- package/src/internal/_llmApplicationFinalize.ts +24 -24
- package/src/internal/_miscCloneAny.ts +46 -46
- package/src/internal/_notationAny.ts +37 -37
- package/src/internal/_notationCamel.ts +13 -13
- package/src/internal/_notationPascal.ts +8 -8
- package/src/internal/_notationSnake.ts +43 -43
- package/src/internal/_parseLlmArguments.ts +7 -7
- package/src/internal/_randomArray.ts +21 -21
- package/src/internal/_randomBigint.ts +6 -6
- package/src/internal/_randomBoolean.ts +1 -1
- package/src/internal/_randomFormatByte.ts +3 -3
- package/src/internal/_randomFormatDate.ts +18 -18
- package/src/internal/_randomFormatDatetime.ts +16 -16
- package/src/internal/_randomFormatDuration.ts +27 -27
- package/src/internal/_randomFormatEmail.ts +11 -11
- package/src/internal/_randomFormatHostname.ts +6 -6
- package/src/internal/_randomFormatIdnEmail.ts +3 -3
- package/src/internal/_randomFormatIdnHostname.ts +3 -3
- package/src/internal/_randomFormatIpv4.ts +11 -11
- package/src/internal/_randomFormatIpv6.ts +11 -11
- package/src/internal/_randomFormatIri.ts +3 -3
- package/src/internal/_randomFormatIriReference.ts +3 -3
- package/src/internal/_randomFormatJsonPointer.ts +7 -7
- package/src/internal/_randomFormatPassword.ts +8 -8
- package/src/internal/_randomFormatRegex.ts +4 -4
- package/src/internal/_randomFormatRelativeJsonPointer.ts +8 -8
- package/src/internal/_randomFormatTime.ts +14 -14
- package/src/internal/_randomFormatUri.ts +3 -3
- package/src/internal/_randomFormatUriReference.ts +3 -3
- package/src/internal/_randomFormatUriTemplate.ts +3 -3
- package/src/internal/_randomFormatUrl.ts +11 -11
- package/src/internal/_randomFormatUuid.ts +6 -6
- package/src/internal/_randomInteger.ts +53 -53
- package/src/internal/_randomNumber.ts +80 -80
- package/src/internal/_randomPattern.ts +10 -10
- package/src/internal/_randomPick.ts +9 -9
- package/src/internal/_randomString.ts +24 -24
- package/src/internal/_throwTypeGuardError.ts +5 -5
- package/src/internal/_validateReport.ts +21 -21
- package/src/internal/private/__notationCapitalize.ts +2 -2
- package/src/internal/private/__notationUnsnake.ts +24 -24
- package/src/json.ts +553 -553
- package/src/llm.ts +408 -408
- package/src/misc.ts +448 -448
- package/src/module.ts +811 -811
- package/src/notations.ts +624 -624
- package/src/programmers/TypiaProgrammer.ts +8 -8
- package/src/protobuf.ts +499 -499
- package/src/re-exports.ts +33 -33
- package/src/reflect.ts +75 -75
- package/src/transform.ts +5 -5
- package/src/transformers/NoTransformConfigurationError.ts +16 -16
package/src/notations.ts
CHANGED
|
@@ -1,624 +1,624 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CamelCase,
|
|
3
|
-
IValidation,
|
|
4
|
-
PascalCase,
|
|
5
|
-
SnakeCase,
|
|
6
|
-
} from "@typia/interface";
|
|
7
|
-
|
|
8
|
-
import { TypeGuardError } from "./TypeGuardError";
|
|
9
|
-
import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";
|
|
10
|
-
|
|
11
|
-
/* ===========================================================
|
|
12
|
-
NOTATIONS (NAMING CONVENTIONS)
|
|
13
|
-
- CAMEL CASE
|
|
14
|
-
- PASCAL CASE
|
|
15
|
-
- SNAKE CASE
|
|
16
|
-
- FACTORY FUNCTIONS
|
|
17
|
-
==============================================================
|
|
18
|
-
CAMEL CASE
|
|
19
|
-
----------------------------------------------------------- */
|
|
20
|
-
/**
|
|
21
|
-
* Converts property names to camelCase.
|
|
22
|
-
*
|
|
23
|
-
* Transforms all property names in the object (including nested) to camelCase
|
|
24
|
-
* convention. Creates a new object with renamed properties.
|
|
25
|
-
*
|
|
26
|
-
* Does not validate the input. For validation, use:
|
|
27
|
-
*
|
|
28
|
-
* - {@link assertCamel} — Throws on type mismatch
|
|
29
|
-
* - {@link isCamel} — Returns `null` on type mismatch
|
|
30
|
-
* - {@link validateCamel} — Returns detailed validation errors
|
|
31
|
-
*
|
|
32
|
-
* @template T Type of input value
|
|
33
|
-
* @param input Object to convert
|
|
34
|
-
* @returns New object with camelCase property names
|
|
35
|
-
*/
|
|
36
|
-
export function camel<T>(input: T): CamelCase<T>;
|
|
37
|
-
|
|
38
|
-
/** @internal */
|
|
39
|
-
export function camel(): never {
|
|
40
|
-
return NoTransformConfigurationError("notations.camel");
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Converts property names to camelCase with assertion.
|
|
45
|
-
*
|
|
46
|
-
* Transforms all property names to camelCase with {@link assert} validation.
|
|
47
|
-
* Throws {@link TypeGuardError} on type mismatch.
|
|
48
|
-
*
|
|
49
|
-
* Related functions:
|
|
50
|
-
*
|
|
51
|
-
* - {@link camel} — No validation
|
|
52
|
-
* - {@link isCamel} — Returns `null` instead of throwing
|
|
53
|
-
* - {@link validateCamel} — Returns detailed validation errors
|
|
54
|
-
*
|
|
55
|
-
* @template T Type of input value
|
|
56
|
-
* @param input Object to convert
|
|
57
|
-
* @param errorFactory Custom error factory receiving
|
|
58
|
-
* {@link TypeGuardError.IProps}
|
|
59
|
-
* @returns New object with camelCase property names
|
|
60
|
-
* @throws {TypeGuardError} When input doesn't conform to type `T`
|
|
61
|
-
*/
|
|
62
|
-
export function assertCamel<T>(
|
|
63
|
-
input: T,
|
|
64
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
65
|
-
): CamelCase<T>;
|
|
66
|
-
|
|
67
|
-
/** @internal */
|
|
68
|
-
export function assertCamel<T>(
|
|
69
|
-
input: unknown,
|
|
70
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
71
|
-
): CamelCase<T>;
|
|
72
|
-
|
|
73
|
-
/** @internal */
|
|
74
|
-
export function assertCamel(): never {
|
|
75
|
-
return NoTransformConfigurationError("notations.assertCamel");
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Converts property names to camelCase with type checking.
|
|
80
|
-
*
|
|
81
|
-
* Transforms all property names to camelCase with {@link is} validation. Returns
|
|
82
|
-
* `null` on type mismatch.
|
|
83
|
-
*
|
|
84
|
-
* Related functions:
|
|
85
|
-
*
|
|
86
|
-
* - {@link camel} — No validation
|
|
87
|
-
* - {@link assertCamel} — Throws instead of returning `null`
|
|
88
|
-
* - {@link validateCamel} — Returns detailed validation errors
|
|
89
|
-
*
|
|
90
|
-
* @template T Type of input value
|
|
91
|
-
* @param input Object to convert
|
|
92
|
-
* @returns New object with camelCase property names, or `null` if invalid
|
|
93
|
-
*/
|
|
94
|
-
export function isCamel<T>(input: T): CamelCase<T> | null;
|
|
95
|
-
|
|
96
|
-
/** @internal */
|
|
97
|
-
export function isCamel<T>(input: unknown): CamelCase<T> | null;
|
|
98
|
-
|
|
99
|
-
/** @internal */
|
|
100
|
-
export function isCamel(): never {
|
|
101
|
-
return NoTransformConfigurationError("notations.isCamel");
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Converts property names to camelCase with validation.
|
|
106
|
-
*
|
|
107
|
-
* Transforms all property names to camelCase with {@link validate} validation.
|
|
108
|
-
* Returns {@link IValidation.IFailure} with all errors on mismatch, or
|
|
109
|
-
* {@link IValidation.ISuccess} with converted object.
|
|
110
|
-
*
|
|
111
|
-
* Related functions:
|
|
112
|
-
*
|
|
113
|
-
* - {@link camel} — No validation
|
|
114
|
-
* - {@link assertCamel} — Throws on first error
|
|
115
|
-
* - {@link isCamel} — Returns `null` instead of error details
|
|
116
|
-
*
|
|
117
|
-
* @template T Type of input value
|
|
118
|
-
* @param input Object to convert
|
|
119
|
-
* @returns Validation result containing converted object or errors
|
|
120
|
-
*/
|
|
121
|
-
export function validateCamel<T>(input: T): IValidation<CamelCase<T>>;
|
|
122
|
-
|
|
123
|
-
/** @internal */
|
|
124
|
-
export function validateCamel<T>(input: unknown): IValidation<CamelCase<T>>;
|
|
125
|
-
|
|
126
|
-
/** @internal */
|
|
127
|
-
export function validateCamel(): never {
|
|
128
|
-
return NoTransformConfigurationError("notations.validateCamel");
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/* -----------------------------------------------------------
|
|
132
|
-
PASCAL CASE
|
|
133
|
-
----------------------------------------------------------- */
|
|
134
|
-
/**
|
|
135
|
-
* Converts property names to PascalCase.
|
|
136
|
-
*
|
|
137
|
-
* Transforms all property names in the object (including nested) to PascalCase
|
|
138
|
-
* convention. Creates a new object with renamed properties.
|
|
139
|
-
*
|
|
140
|
-
* Does not validate the input. For validation, use:
|
|
141
|
-
*
|
|
142
|
-
* - {@link assertPascal} — Throws on type mismatch
|
|
143
|
-
* - {@link isPascal} — Returns `null` on type mismatch
|
|
144
|
-
* - {@link validatePascal} — Returns detailed validation errors
|
|
145
|
-
*
|
|
146
|
-
* @template T Type of input value
|
|
147
|
-
* @param input Object to convert
|
|
148
|
-
* @returns New object with PascalCase property names
|
|
149
|
-
*/
|
|
150
|
-
export function pascal<T>(input: T): PascalCase<T>;
|
|
151
|
-
|
|
152
|
-
/** @internal */
|
|
153
|
-
export function pascal(): never {
|
|
154
|
-
return NoTransformConfigurationError("notations.pascal");
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Converts property names to PascalCase with assertion.
|
|
159
|
-
*
|
|
160
|
-
* Transforms all property names to PascalCase with {@link assert} validation.
|
|
161
|
-
* Throws {@link TypeGuardError} on type mismatch.
|
|
162
|
-
*
|
|
163
|
-
* Related functions:
|
|
164
|
-
*
|
|
165
|
-
* - {@link pascal} — No validation
|
|
166
|
-
* - {@link isPascal} — Returns `null` instead of throwing
|
|
167
|
-
* - {@link validatePascal} — Returns detailed validation errors
|
|
168
|
-
*
|
|
169
|
-
* @template T Type of input value
|
|
170
|
-
* @param input Object to convert
|
|
171
|
-
* @param errorFactory Custom error factory receiving
|
|
172
|
-
* {@link TypeGuardError.IProps}
|
|
173
|
-
* @returns New object with PascalCase property names
|
|
174
|
-
* @throws {TypeGuardError} When input doesn't conform to type `T`
|
|
175
|
-
*/
|
|
176
|
-
export function assertPascal<T>(
|
|
177
|
-
input: T,
|
|
178
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
179
|
-
): PascalCase<T>;
|
|
180
|
-
|
|
181
|
-
/** @internal */
|
|
182
|
-
export function assertPascal<T>(
|
|
183
|
-
input: unknown,
|
|
184
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
185
|
-
): PascalCase<T>;
|
|
186
|
-
|
|
187
|
-
/** @internal */
|
|
188
|
-
export function assertPascal(): never {
|
|
189
|
-
return NoTransformConfigurationError("notations.assertPascal");
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Converts property names to PascalCase with type checking.
|
|
194
|
-
*
|
|
195
|
-
* Transforms all property names to PascalCase with {@link is} validation.
|
|
196
|
-
* Returns `null` on type mismatch.
|
|
197
|
-
*
|
|
198
|
-
* Related functions:
|
|
199
|
-
*
|
|
200
|
-
* - {@link pascal} — No validation
|
|
201
|
-
* - {@link assertPascal} — Throws instead of returning `null`
|
|
202
|
-
* - {@link validatePascal} — Returns detailed validation errors
|
|
203
|
-
*
|
|
204
|
-
* @template T Type of input value
|
|
205
|
-
* @param input Object to convert
|
|
206
|
-
* @returns New object with PascalCase property names, or `null` if invalid
|
|
207
|
-
*/
|
|
208
|
-
export function isPascal<T>(input: T): PascalCase<T> | null;
|
|
209
|
-
|
|
210
|
-
/** @internal */
|
|
211
|
-
export function isPascal<T>(input: unknown): PascalCase<T> | null;
|
|
212
|
-
|
|
213
|
-
/** @internal */
|
|
214
|
-
export function isPascal(): never {
|
|
215
|
-
return NoTransformConfigurationError("notations.isPascal");
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Converts property names to PascalCase with validation.
|
|
220
|
-
*
|
|
221
|
-
* Transforms all property names to PascalCase with {@link validate} validation.
|
|
222
|
-
* Returns {@link IValidation.IFailure} with all errors on mismatch, or
|
|
223
|
-
* {@link IValidation.ISuccess} with converted object.
|
|
224
|
-
*
|
|
225
|
-
* Related functions:
|
|
226
|
-
*
|
|
227
|
-
* - {@link pascal} — No validation
|
|
228
|
-
* - {@link assertPascal} — Throws on first error
|
|
229
|
-
* - {@link isPascal} — Returns `null` instead of error details
|
|
230
|
-
*
|
|
231
|
-
* @template T Type of input value
|
|
232
|
-
* @param input Object to convert
|
|
233
|
-
* @returns Validation result containing converted object or errors
|
|
234
|
-
*/
|
|
235
|
-
export function validatePascal<T>(input: T): IValidation<PascalCase<T>>;
|
|
236
|
-
|
|
237
|
-
/** @internal */
|
|
238
|
-
export function validatePascal<T>(input: unknown): IValidation<PascalCase<T>>;
|
|
239
|
-
|
|
240
|
-
/** @internal */
|
|
241
|
-
export function validatePascal(): never {
|
|
242
|
-
return NoTransformConfigurationError("notations.validatePascal");
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/* -----------------------------------------------------------
|
|
246
|
-
SNAKE CASE
|
|
247
|
-
----------------------------------------------------------- */
|
|
248
|
-
/**
|
|
249
|
-
* Converts property names to snake_case.
|
|
250
|
-
*
|
|
251
|
-
* Transforms all property names in the object (including nested) to snake_case
|
|
252
|
-
* convention. Creates a new object with renamed properties.
|
|
253
|
-
*
|
|
254
|
-
* Does not validate the input. For validation, use:
|
|
255
|
-
*
|
|
256
|
-
* - {@link assertSnake} — Throws on type mismatch
|
|
257
|
-
* - {@link isSnake} — Returns `null` on type mismatch
|
|
258
|
-
* - {@link validateSnake} — Returns detailed validation errors
|
|
259
|
-
*
|
|
260
|
-
* @template T Type of input value
|
|
261
|
-
* @param input Object to convert
|
|
262
|
-
* @returns New object with snake_case property names
|
|
263
|
-
*/
|
|
264
|
-
export function snake<T>(input: T): SnakeCase<T>;
|
|
265
|
-
|
|
266
|
-
/** @internal */
|
|
267
|
-
export function snake(): never {
|
|
268
|
-
return NoTransformConfigurationError("notations.snake");
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Converts property names to snake_case with assertion.
|
|
273
|
-
*
|
|
274
|
-
* Transforms all property names to snake_case with {@link assert} validation.
|
|
275
|
-
* Throws {@link TypeGuardError} on type mismatch.
|
|
276
|
-
*
|
|
277
|
-
* Related functions:
|
|
278
|
-
*
|
|
279
|
-
* - {@link snake} — No validation
|
|
280
|
-
* - {@link isSnake} — Returns `null` instead of throwing
|
|
281
|
-
* - {@link validateSnake} — Returns detailed validation errors
|
|
282
|
-
*
|
|
283
|
-
* @template T Type of input value
|
|
284
|
-
* @param input Object to convert
|
|
285
|
-
* @param errorFactory Custom error factory receiving
|
|
286
|
-
* {@link TypeGuardError.IProps}
|
|
287
|
-
* @returns New object with snake_case property names
|
|
288
|
-
* @throws {TypeGuardError} When input doesn't conform to type `T`
|
|
289
|
-
*/
|
|
290
|
-
export function assertSnake<T>(
|
|
291
|
-
input: T,
|
|
292
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
293
|
-
): SnakeCase<T>;
|
|
294
|
-
|
|
295
|
-
/** @internal */
|
|
296
|
-
export function assertSnake<T>(
|
|
297
|
-
input: unknown,
|
|
298
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
299
|
-
): SnakeCase<T>;
|
|
300
|
-
|
|
301
|
-
/** @internal */
|
|
302
|
-
export function assertSnake(): never {
|
|
303
|
-
return NoTransformConfigurationError("notations.assertSnake");
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Converts property names to snake_case with type checking.
|
|
308
|
-
*
|
|
309
|
-
* Transforms all property names to snake_case with {@link is} validation.
|
|
310
|
-
* Returns `null` on type mismatch.
|
|
311
|
-
*
|
|
312
|
-
* Related functions:
|
|
313
|
-
*
|
|
314
|
-
* - {@link snake} — No validation
|
|
315
|
-
* - {@link assertSnake} — Throws instead of returning `null`
|
|
316
|
-
* - {@link validateSnake} — Returns detailed validation errors
|
|
317
|
-
*
|
|
318
|
-
* @template T Type of input value
|
|
319
|
-
* @param input Object to convert
|
|
320
|
-
* @returns New object with snake_case property names, or `null` if invalid
|
|
321
|
-
*/
|
|
322
|
-
export function isSnake<T>(input: T): SnakeCase<T> | null;
|
|
323
|
-
|
|
324
|
-
/** @internal */
|
|
325
|
-
export function isSnake<T>(input: unknown): SnakeCase<T> | null;
|
|
326
|
-
|
|
327
|
-
/** @internal */
|
|
328
|
-
export function isSnake(): never {
|
|
329
|
-
return NoTransformConfigurationError("notations.isSnake");
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Converts property names to snake_case with validation.
|
|
334
|
-
*
|
|
335
|
-
* Transforms all property names to snake_case with {@link validate} validation.
|
|
336
|
-
* Returns {@link IValidation.IFailure} with all errors on mismatch, or
|
|
337
|
-
* {@link IValidation.ISuccess} with converted object.
|
|
338
|
-
*
|
|
339
|
-
* Related functions:
|
|
340
|
-
*
|
|
341
|
-
* - {@link snake} — No validation
|
|
342
|
-
* - {@link assertSnake} — Throws on first error
|
|
343
|
-
* - {@link isSnake} — Returns `null` instead of error details
|
|
344
|
-
*
|
|
345
|
-
* @template T Type of input value
|
|
346
|
-
* @param input Object to convert
|
|
347
|
-
* @returns Validation result containing converted object or errors
|
|
348
|
-
*/
|
|
349
|
-
export function validateSnake<T>(input: T): IValidation<SnakeCase<T>>;
|
|
350
|
-
|
|
351
|
-
/** @internal */
|
|
352
|
-
export function validateSnake<T>(input: unknown): IValidation<SnakeCase<T>>;
|
|
353
|
-
|
|
354
|
-
/** @internal */
|
|
355
|
-
export function validateSnake(): never {
|
|
356
|
-
return NoTransformConfigurationError("notations.validateSnake");
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/* -----------------------------------------------------------
|
|
360
|
-
FACTORY FUNCTIONS
|
|
361
|
-
----------------------------------------------------------- */
|
|
362
|
-
/**
|
|
363
|
-
* Creates reusable {@link camel} function.
|
|
364
|
-
*
|
|
365
|
-
* @danger You must configure the generic argument `T`
|
|
366
|
-
*/
|
|
367
|
-
export function createCamel(): never;
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Creates reusable {@link camel} function.
|
|
371
|
-
*
|
|
372
|
-
* @template T Type of input value
|
|
373
|
-
* @returns Reusable conversion function
|
|
374
|
-
*/
|
|
375
|
-
export function createCamel<T>(): (input: T) => CamelCase<T>;
|
|
376
|
-
|
|
377
|
-
/** @internal */
|
|
378
|
-
export function createCamel(): never {
|
|
379
|
-
NoTransformConfigurationError("notations.createCamel");
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Creates reusable {@link assertCamel} function.
|
|
384
|
-
*
|
|
385
|
-
* @danger You must configure the generic argument `T`
|
|
386
|
-
*/
|
|
387
|
-
export function createAssertCamel(
|
|
388
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
389
|
-
): never;
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* Creates reusable {@link assertCamel} function.
|
|
393
|
-
*
|
|
394
|
-
* @template T Type of input value
|
|
395
|
-
* @param errorFactory Custom error factory receiving
|
|
396
|
-
* {@link TypeGuardError.IProps}
|
|
397
|
-
* @returns Reusable conversion function
|
|
398
|
-
*/
|
|
399
|
-
export function createAssertCamel<T>(
|
|
400
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
401
|
-
): (input: T) => CamelCase<T>;
|
|
402
|
-
|
|
403
|
-
/** @internal */
|
|
404
|
-
export function createAssertCamel(): never {
|
|
405
|
-
NoTransformConfigurationError("notations.createAssertCamel");
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* Creates reusable {@link isCamel} function.
|
|
410
|
-
*
|
|
411
|
-
* @danger You must configure the generic argument `T`
|
|
412
|
-
*/
|
|
413
|
-
export function createIsCamel(): never;
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* Creates reusable {@link isCamel} function.
|
|
417
|
-
*
|
|
418
|
-
* @template T Type of input value
|
|
419
|
-
* @returns Reusable conversion function
|
|
420
|
-
*/
|
|
421
|
-
export function createIsCamel<T>(): (input: T) => CamelCase<T> | null;
|
|
422
|
-
|
|
423
|
-
/** @internal */
|
|
424
|
-
export function createIsCamel(): never {
|
|
425
|
-
NoTransformConfigurationError("notations.createIsCamel");
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* Creates reusable {@link validateCamel} function.
|
|
430
|
-
*
|
|
431
|
-
* @danger You must configure the generic argument `T`
|
|
432
|
-
*/
|
|
433
|
-
export function createValidateCamel(): never;
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* Creates reusable {@link validateCamel} function.
|
|
437
|
-
*
|
|
438
|
-
* @template T Type of input value
|
|
439
|
-
* @returns Reusable conversion function
|
|
440
|
-
*/
|
|
441
|
-
export function createValidateCamel<T>(): (
|
|
442
|
-
input: T,
|
|
443
|
-
) => IValidation<CamelCase<T>>;
|
|
444
|
-
|
|
445
|
-
/** @internal */
|
|
446
|
-
export function createValidateCamel(): never {
|
|
447
|
-
NoTransformConfigurationError("notations.createValidateCamel");
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* Creates reusable {@link pascal} function.
|
|
452
|
-
*
|
|
453
|
-
* @danger You must configure the generic argument `T`
|
|
454
|
-
*/
|
|
455
|
-
export function createPascal(): never;
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* Creates reusable {@link pascal} function.
|
|
459
|
-
*
|
|
460
|
-
* @template T Type of input value
|
|
461
|
-
* @returns Reusable conversion function
|
|
462
|
-
*/
|
|
463
|
-
export function createPascal<T>(): (input: T) => PascalCase<T>;
|
|
464
|
-
|
|
465
|
-
/** @internal */
|
|
466
|
-
export function createPascal(): never {
|
|
467
|
-
NoTransformConfigurationError("notations.createPascal");
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* Creates reusable {@link assertPascal} function.
|
|
472
|
-
*
|
|
473
|
-
* @danger You must configure the generic argument `T`
|
|
474
|
-
*/
|
|
475
|
-
export function createAssertPascal(
|
|
476
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
477
|
-
): never;
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* Creates reusable {@link assertPascal} function.
|
|
481
|
-
*
|
|
482
|
-
* @template T Type of input value
|
|
483
|
-
* @param errorFactory Custom error factory receiving
|
|
484
|
-
* {@link TypeGuardError.IProps}
|
|
485
|
-
* @returns Reusable conversion function
|
|
486
|
-
*/
|
|
487
|
-
export function createAssertPascal<T>(
|
|
488
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
489
|
-
): (input: T) => PascalCase<T>;
|
|
490
|
-
|
|
491
|
-
/** @internal */
|
|
492
|
-
export function createAssertPascal(): never {
|
|
493
|
-
NoTransformConfigurationError("notations.createAssertPascal");
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* Creates reusable {@link isPascal} function.
|
|
498
|
-
*
|
|
499
|
-
* @danger You must configure the generic argument `T`
|
|
500
|
-
*/
|
|
501
|
-
export function createIsPascal(): never;
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* Creates reusable {@link isPascal} function.
|
|
505
|
-
*
|
|
506
|
-
* @template T Type of input value
|
|
507
|
-
* @returns Reusable conversion function
|
|
508
|
-
*/
|
|
509
|
-
export function createIsPascal<T>(): (input: T) => PascalCase<T> | null;
|
|
510
|
-
|
|
511
|
-
/** @internal */
|
|
512
|
-
export function createIsPascal(): never {
|
|
513
|
-
NoTransformConfigurationError("notations.createIsPascal");
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* Creates reusable {@link validatePascal} function.
|
|
518
|
-
*
|
|
519
|
-
* @danger You must configure the generic argument `T`
|
|
520
|
-
*/
|
|
521
|
-
export function createValidatePascal(): never;
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* Creates reusable {@link validatePascal} function.
|
|
525
|
-
*
|
|
526
|
-
* @template T Type of input value
|
|
527
|
-
* @returns Reusable conversion function
|
|
528
|
-
*/
|
|
529
|
-
export function createValidatePascal<T>(): (
|
|
530
|
-
input: T,
|
|
531
|
-
) => IValidation<PascalCase<T>>;
|
|
532
|
-
|
|
533
|
-
/** @internal */
|
|
534
|
-
export function createValidatePascal(): never {
|
|
535
|
-
NoTransformConfigurationError("notations.createValidatePascal");
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* Creates reusable {@link snake} function.
|
|
540
|
-
*
|
|
541
|
-
* @danger You must configure the generic argument `T`
|
|
542
|
-
*/
|
|
543
|
-
export function createSnake(): never;
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* Creates reusable {@link snake} function.
|
|
547
|
-
*
|
|
548
|
-
* @template T Type of input value
|
|
549
|
-
* @returns Reusable conversion function
|
|
550
|
-
*/
|
|
551
|
-
export function createSnake<T>(): (input: T) => SnakeCase<T>;
|
|
552
|
-
|
|
553
|
-
/** @internal */
|
|
554
|
-
export function createSnake(): never {
|
|
555
|
-
NoTransformConfigurationError("notations.createSnake");
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
/**
|
|
559
|
-
* Creates reusable {@link assertSnake} function.
|
|
560
|
-
*
|
|
561
|
-
* @danger You must configure the generic argument `T`
|
|
562
|
-
*/
|
|
563
|
-
export function createAssertSnake(
|
|
564
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
565
|
-
): never;
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* Creates reusable {@link assertSnake} function.
|
|
569
|
-
*
|
|
570
|
-
* @template T Type of input value
|
|
571
|
-
* @param errorFactory Custom error factory receiving
|
|
572
|
-
* {@link TypeGuardError.IProps}
|
|
573
|
-
* @returns Reusable conversion function
|
|
574
|
-
*/
|
|
575
|
-
export function createAssertSnake<T>(
|
|
576
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
577
|
-
): (input: T) => SnakeCase<T>;
|
|
578
|
-
|
|
579
|
-
/** @internal */
|
|
580
|
-
export function createAssertSnake(): never {
|
|
581
|
-
NoTransformConfigurationError("notations.createAssertSnake");
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
/**
|
|
585
|
-
* Creates reusable {@link isSnake} function.
|
|
586
|
-
*
|
|
587
|
-
* @danger You must configure the generic argument `T`
|
|
588
|
-
*/
|
|
589
|
-
export function createIsSnake(): never;
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* Creates reusable {@link isSnake} function.
|
|
593
|
-
*
|
|
594
|
-
* @template T Type of input value
|
|
595
|
-
* @returns Reusable conversion function
|
|
596
|
-
*/
|
|
597
|
-
export function createIsSnake<T>(): (input: T) => SnakeCase<T> | null;
|
|
598
|
-
|
|
599
|
-
/** @internal */
|
|
600
|
-
export function createIsSnake(): never {
|
|
601
|
-
NoTransformConfigurationError("notations.createIsSnake");
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
/**
|
|
605
|
-
* Creates reusable {@link validateSnake} function.
|
|
606
|
-
*
|
|
607
|
-
* @danger You must configure the generic argument `T`
|
|
608
|
-
*/
|
|
609
|
-
export function createValidateSnake(): never;
|
|
610
|
-
|
|
611
|
-
/**
|
|
612
|
-
* Creates reusable {@link validateSnake} function.
|
|
613
|
-
*
|
|
614
|
-
* @template T Type of input value
|
|
615
|
-
* @returns Reusable conversion function
|
|
616
|
-
*/
|
|
617
|
-
export function createValidateSnake<T>(): (
|
|
618
|
-
input: T,
|
|
619
|
-
) => IValidation<SnakeCase<T>>;
|
|
620
|
-
|
|
621
|
-
/** @internal */
|
|
622
|
-
export function createValidateSnake(): never {
|
|
623
|
-
NoTransformConfigurationError("notations.createValidateSnake");
|
|
624
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
CamelCase,
|
|
3
|
+
IValidation,
|
|
4
|
+
PascalCase,
|
|
5
|
+
SnakeCase,
|
|
6
|
+
} from "@typia/interface";
|
|
7
|
+
|
|
8
|
+
import { TypeGuardError } from "./TypeGuardError";
|
|
9
|
+
import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";
|
|
10
|
+
|
|
11
|
+
/* ===========================================================
|
|
12
|
+
NOTATIONS (NAMING CONVENTIONS)
|
|
13
|
+
- CAMEL CASE
|
|
14
|
+
- PASCAL CASE
|
|
15
|
+
- SNAKE CASE
|
|
16
|
+
- FACTORY FUNCTIONS
|
|
17
|
+
==============================================================
|
|
18
|
+
CAMEL CASE
|
|
19
|
+
----------------------------------------------------------- */
|
|
20
|
+
/**
|
|
21
|
+
* Converts property names to camelCase.
|
|
22
|
+
*
|
|
23
|
+
* Transforms all property names in the object (including nested) to camelCase
|
|
24
|
+
* convention. Creates a new object with renamed properties.
|
|
25
|
+
*
|
|
26
|
+
* Does not validate the input. For validation, use:
|
|
27
|
+
*
|
|
28
|
+
* - {@link assertCamel} — Throws on type mismatch
|
|
29
|
+
* - {@link isCamel} — Returns `null` on type mismatch
|
|
30
|
+
* - {@link validateCamel} — Returns detailed validation errors
|
|
31
|
+
*
|
|
32
|
+
* @template T Type of input value
|
|
33
|
+
* @param input Object to convert
|
|
34
|
+
* @returns New object with camelCase property names
|
|
35
|
+
*/
|
|
36
|
+
export function camel<T>(input: T): CamelCase<T>;
|
|
37
|
+
|
|
38
|
+
/** @internal */
|
|
39
|
+
export function camel(): never {
|
|
40
|
+
return NoTransformConfigurationError("notations.camel");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Converts property names to camelCase with assertion.
|
|
45
|
+
*
|
|
46
|
+
* Transforms all property names to camelCase with {@link assert} validation.
|
|
47
|
+
* Throws {@link TypeGuardError} on type mismatch.
|
|
48
|
+
*
|
|
49
|
+
* Related functions:
|
|
50
|
+
*
|
|
51
|
+
* - {@link camel} — No validation
|
|
52
|
+
* - {@link isCamel} — Returns `null` instead of throwing
|
|
53
|
+
* - {@link validateCamel} — Returns detailed validation errors
|
|
54
|
+
*
|
|
55
|
+
* @template T Type of input value
|
|
56
|
+
* @param input Object to convert
|
|
57
|
+
* @param errorFactory Custom error factory receiving
|
|
58
|
+
* {@link TypeGuardError.IProps}
|
|
59
|
+
* @returns New object with camelCase property names
|
|
60
|
+
* @throws {TypeGuardError} When input doesn't conform to type `T`
|
|
61
|
+
*/
|
|
62
|
+
export function assertCamel<T>(
|
|
63
|
+
input: T,
|
|
64
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
65
|
+
): CamelCase<T>;
|
|
66
|
+
|
|
67
|
+
/** @internal */
|
|
68
|
+
export function assertCamel<T>(
|
|
69
|
+
input: unknown,
|
|
70
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
71
|
+
): CamelCase<T>;
|
|
72
|
+
|
|
73
|
+
/** @internal */
|
|
74
|
+
export function assertCamel(): never {
|
|
75
|
+
return NoTransformConfigurationError("notations.assertCamel");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Converts property names to camelCase with type checking.
|
|
80
|
+
*
|
|
81
|
+
* Transforms all property names to camelCase with {@link is} validation. Returns
|
|
82
|
+
* `null` on type mismatch.
|
|
83
|
+
*
|
|
84
|
+
* Related functions:
|
|
85
|
+
*
|
|
86
|
+
* - {@link camel} — No validation
|
|
87
|
+
* - {@link assertCamel} — Throws instead of returning `null`
|
|
88
|
+
* - {@link validateCamel} — Returns detailed validation errors
|
|
89
|
+
*
|
|
90
|
+
* @template T Type of input value
|
|
91
|
+
* @param input Object to convert
|
|
92
|
+
* @returns New object with camelCase property names, or `null` if invalid
|
|
93
|
+
*/
|
|
94
|
+
export function isCamel<T>(input: T): CamelCase<T> | null;
|
|
95
|
+
|
|
96
|
+
/** @internal */
|
|
97
|
+
export function isCamel<T>(input: unknown): CamelCase<T> | null;
|
|
98
|
+
|
|
99
|
+
/** @internal */
|
|
100
|
+
export function isCamel(): never {
|
|
101
|
+
return NoTransformConfigurationError("notations.isCamel");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Converts property names to camelCase with validation.
|
|
106
|
+
*
|
|
107
|
+
* Transforms all property names to camelCase with {@link validate} validation.
|
|
108
|
+
* Returns {@link IValidation.IFailure} with all errors on mismatch, or
|
|
109
|
+
* {@link IValidation.ISuccess} with converted object.
|
|
110
|
+
*
|
|
111
|
+
* Related functions:
|
|
112
|
+
*
|
|
113
|
+
* - {@link camel} — No validation
|
|
114
|
+
* - {@link assertCamel} — Throws on first error
|
|
115
|
+
* - {@link isCamel} — Returns `null` instead of error details
|
|
116
|
+
*
|
|
117
|
+
* @template T Type of input value
|
|
118
|
+
* @param input Object to convert
|
|
119
|
+
* @returns Validation result containing converted object or errors
|
|
120
|
+
*/
|
|
121
|
+
export function validateCamel<T>(input: T): IValidation<CamelCase<T>>;
|
|
122
|
+
|
|
123
|
+
/** @internal */
|
|
124
|
+
export function validateCamel<T>(input: unknown): IValidation<CamelCase<T>>;
|
|
125
|
+
|
|
126
|
+
/** @internal */
|
|
127
|
+
export function validateCamel(): never {
|
|
128
|
+
return NoTransformConfigurationError("notations.validateCamel");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* -----------------------------------------------------------
|
|
132
|
+
PASCAL CASE
|
|
133
|
+
----------------------------------------------------------- */
|
|
134
|
+
/**
|
|
135
|
+
* Converts property names to PascalCase.
|
|
136
|
+
*
|
|
137
|
+
* Transforms all property names in the object (including nested) to PascalCase
|
|
138
|
+
* convention. Creates a new object with renamed properties.
|
|
139
|
+
*
|
|
140
|
+
* Does not validate the input. For validation, use:
|
|
141
|
+
*
|
|
142
|
+
* - {@link assertPascal} — Throws on type mismatch
|
|
143
|
+
* - {@link isPascal} — Returns `null` on type mismatch
|
|
144
|
+
* - {@link validatePascal} — Returns detailed validation errors
|
|
145
|
+
*
|
|
146
|
+
* @template T Type of input value
|
|
147
|
+
* @param input Object to convert
|
|
148
|
+
* @returns New object with PascalCase property names
|
|
149
|
+
*/
|
|
150
|
+
export function pascal<T>(input: T): PascalCase<T>;
|
|
151
|
+
|
|
152
|
+
/** @internal */
|
|
153
|
+
export function pascal(): never {
|
|
154
|
+
return NoTransformConfigurationError("notations.pascal");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Converts property names to PascalCase with assertion.
|
|
159
|
+
*
|
|
160
|
+
* Transforms all property names to PascalCase with {@link assert} validation.
|
|
161
|
+
* Throws {@link TypeGuardError} on type mismatch.
|
|
162
|
+
*
|
|
163
|
+
* Related functions:
|
|
164
|
+
*
|
|
165
|
+
* - {@link pascal} — No validation
|
|
166
|
+
* - {@link isPascal} — Returns `null` instead of throwing
|
|
167
|
+
* - {@link validatePascal} — Returns detailed validation errors
|
|
168
|
+
*
|
|
169
|
+
* @template T Type of input value
|
|
170
|
+
* @param input Object to convert
|
|
171
|
+
* @param errorFactory Custom error factory receiving
|
|
172
|
+
* {@link TypeGuardError.IProps}
|
|
173
|
+
* @returns New object with PascalCase property names
|
|
174
|
+
* @throws {TypeGuardError} When input doesn't conform to type `T`
|
|
175
|
+
*/
|
|
176
|
+
export function assertPascal<T>(
|
|
177
|
+
input: T,
|
|
178
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
179
|
+
): PascalCase<T>;
|
|
180
|
+
|
|
181
|
+
/** @internal */
|
|
182
|
+
export function assertPascal<T>(
|
|
183
|
+
input: unknown,
|
|
184
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
185
|
+
): PascalCase<T>;
|
|
186
|
+
|
|
187
|
+
/** @internal */
|
|
188
|
+
export function assertPascal(): never {
|
|
189
|
+
return NoTransformConfigurationError("notations.assertPascal");
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Converts property names to PascalCase with type checking.
|
|
194
|
+
*
|
|
195
|
+
* Transforms all property names to PascalCase with {@link is} validation.
|
|
196
|
+
* Returns `null` on type mismatch.
|
|
197
|
+
*
|
|
198
|
+
* Related functions:
|
|
199
|
+
*
|
|
200
|
+
* - {@link pascal} — No validation
|
|
201
|
+
* - {@link assertPascal} — Throws instead of returning `null`
|
|
202
|
+
* - {@link validatePascal} — Returns detailed validation errors
|
|
203
|
+
*
|
|
204
|
+
* @template T Type of input value
|
|
205
|
+
* @param input Object to convert
|
|
206
|
+
* @returns New object with PascalCase property names, or `null` if invalid
|
|
207
|
+
*/
|
|
208
|
+
export function isPascal<T>(input: T): PascalCase<T> | null;
|
|
209
|
+
|
|
210
|
+
/** @internal */
|
|
211
|
+
export function isPascal<T>(input: unknown): PascalCase<T> | null;
|
|
212
|
+
|
|
213
|
+
/** @internal */
|
|
214
|
+
export function isPascal(): never {
|
|
215
|
+
return NoTransformConfigurationError("notations.isPascal");
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Converts property names to PascalCase with validation.
|
|
220
|
+
*
|
|
221
|
+
* Transforms all property names to PascalCase with {@link validate} validation.
|
|
222
|
+
* Returns {@link IValidation.IFailure} with all errors on mismatch, or
|
|
223
|
+
* {@link IValidation.ISuccess} with converted object.
|
|
224
|
+
*
|
|
225
|
+
* Related functions:
|
|
226
|
+
*
|
|
227
|
+
* - {@link pascal} — No validation
|
|
228
|
+
* - {@link assertPascal} — Throws on first error
|
|
229
|
+
* - {@link isPascal} — Returns `null` instead of error details
|
|
230
|
+
*
|
|
231
|
+
* @template T Type of input value
|
|
232
|
+
* @param input Object to convert
|
|
233
|
+
* @returns Validation result containing converted object or errors
|
|
234
|
+
*/
|
|
235
|
+
export function validatePascal<T>(input: T): IValidation<PascalCase<T>>;
|
|
236
|
+
|
|
237
|
+
/** @internal */
|
|
238
|
+
export function validatePascal<T>(input: unknown): IValidation<PascalCase<T>>;
|
|
239
|
+
|
|
240
|
+
/** @internal */
|
|
241
|
+
export function validatePascal(): never {
|
|
242
|
+
return NoTransformConfigurationError("notations.validatePascal");
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/* -----------------------------------------------------------
|
|
246
|
+
SNAKE CASE
|
|
247
|
+
----------------------------------------------------------- */
|
|
248
|
+
/**
|
|
249
|
+
* Converts property names to snake_case.
|
|
250
|
+
*
|
|
251
|
+
* Transforms all property names in the object (including nested) to snake_case
|
|
252
|
+
* convention. Creates a new object with renamed properties.
|
|
253
|
+
*
|
|
254
|
+
* Does not validate the input. For validation, use:
|
|
255
|
+
*
|
|
256
|
+
* - {@link assertSnake} — Throws on type mismatch
|
|
257
|
+
* - {@link isSnake} — Returns `null` on type mismatch
|
|
258
|
+
* - {@link validateSnake} — Returns detailed validation errors
|
|
259
|
+
*
|
|
260
|
+
* @template T Type of input value
|
|
261
|
+
* @param input Object to convert
|
|
262
|
+
* @returns New object with snake_case property names
|
|
263
|
+
*/
|
|
264
|
+
export function snake<T>(input: T): SnakeCase<T>;
|
|
265
|
+
|
|
266
|
+
/** @internal */
|
|
267
|
+
export function snake(): never {
|
|
268
|
+
return NoTransformConfigurationError("notations.snake");
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Converts property names to snake_case with assertion.
|
|
273
|
+
*
|
|
274
|
+
* Transforms all property names to snake_case with {@link assert} validation.
|
|
275
|
+
* Throws {@link TypeGuardError} on type mismatch.
|
|
276
|
+
*
|
|
277
|
+
* Related functions:
|
|
278
|
+
*
|
|
279
|
+
* - {@link snake} — No validation
|
|
280
|
+
* - {@link isSnake} — Returns `null` instead of throwing
|
|
281
|
+
* - {@link validateSnake} — Returns detailed validation errors
|
|
282
|
+
*
|
|
283
|
+
* @template T Type of input value
|
|
284
|
+
* @param input Object to convert
|
|
285
|
+
* @param errorFactory Custom error factory receiving
|
|
286
|
+
* {@link TypeGuardError.IProps}
|
|
287
|
+
* @returns New object with snake_case property names
|
|
288
|
+
* @throws {TypeGuardError} When input doesn't conform to type `T`
|
|
289
|
+
*/
|
|
290
|
+
export function assertSnake<T>(
|
|
291
|
+
input: T,
|
|
292
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
293
|
+
): SnakeCase<T>;
|
|
294
|
+
|
|
295
|
+
/** @internal */
|
|
296
|
+
export function assertSnake<T>(
|
|
297
|
+
input: unknown,
|
|
298
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
299
|
+
): SnakeCase<T>;
|
|
300
|
+
|
|
301
|
+
/** @internal */
|
|
302
|
+
export function assertSnake(): never {
|
|
303
|
+
return NoTransformConfigurationError("notations.assertSnake");
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Converts property names to snake_case with type checking.
|
|
308
|
+
*
|
|
309
|
+
* Transforms all property names to snake_case with {@link is} validation.
|
|
310
|
+
* Returns `null` on type mismatch.
|
|
311
|
+
*
|
|
312
|
+
* Related functions:
|
|
313
|
+
*
|
|
314
|
+
* - {@link snake} — No validation
|
|
315
|
+
* - {@link assertSnake} — Throws instead of returning `null`
|
|
316
|
+
* - {@link validateSnake} — Returns detailed validation errors
|
|
317
|
+
*
|
|
318
|
+
* @template T Type of input value
|
|
319
|
+
* @param input Object to convert
|
|
320
|
+
* @returns New object with snake_case property names, or `null` if invalid
|
|
321
|
+
*/
|
|
322
|
+
export function isSnake<T>(input: T): SnakeCase<T> | null;
|
|
323
|
+
|
|
324
|
+
/** @internal */
|
|
325
|
+
export function isSnake<T>(input: unknown): SnakeCase<T> | null;
|
|
326
|
+
|
|
327
|
+
/** @internal */
|
|
328
|
+
export function isSnake(): never {
|
|
329
|
+
return NoTransformConfigurationError("notations.isSnake");
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Converts property names to snake_case with validation.
|
|
334
|
+
*
|
|
335
|
+
* Transforms all property names to snake_case with {@link validate} validation.
|
|
336
|
+
* Returns {@link IValidation.IFailure} with all errors on mismatch, or
|
|
337
|
+
* {@link IValidation.ISuccess} with converted object.
|
|
338
|
+
*
|
|
339
|
+
* Related functions:
|
|
340
|
+
*
|
|
341
|
+
* - {@link snake} — No validation
|
|
342
|
+
* - {@link assertSnake} — Throws on first error
|
|
343
|
+
* - {@link isSnake} — Returns `null` instead of error details
|
|
344
|
+
*
|
|
345
|
+
* @template T Type of input value
|
|
346
|
+
* @param input Object to convert
|
|
347
|
+
* @returns Validation result containing converted object or errors
|
|
348
|
+
*/
|
|
349
|
+
export function validateSnake<T>(input: T): IValidation<SnakeCase<T>>;
|
|
350
|
+
|
|
351
|
+
/** @internal */
|
|
352
|
+
export function validateSnake<T>(input: unknown): IValidation<SnakeCase<T>>;
|
|
353
|
+
|
|
354
|
+
/** @internal */
|
|
355
|
+
export function validateSnake(): never {
|
|
356
|
+
return NoTransformConfigurationError("notations.validateSnake");
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/* -----------------------------------------------------------
|
|
360
|
+
FACTORY FUNCTIONS
|
|
361
|
+
----------------------------------------------------------- */
|
|
362
|
+
/**
|
|
363
|
+
* Creates reusable {@link camel} function.
|
|
364
|
+
*
|
|
365
|
+
* @danger You must configure the generic argument `T`
|
|
366
|
+
*/
|
|
367
|
+
export function createCamel(): never;
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Creates reusable {@link camel} function.
|
|
371
|
+
*
|
|
372
|
+
* @template T Type of input value
|
|
373
|
+
* @returns Reusable conversion function
|
|
374
|
+
*/
|
|
375
|
+
export function createCamel<T>(): (input: T) => CamelCase<T>;
|
|
376
|
+
|
|
377
|
+
/** @internal */
|
|
378
|
+
export function createCamel(): never {
|
|
379
|
+
NoTransformConfigurationError("notations.createCamel");
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Creates reusable {@link assertCamel} function.
|
|
384
|
+
*
|
|
385
|
+
* @danger You must configure the generic argument `T`
|
|
386
|
+
*/
|
|
387
|
+
export function createAssertCamel(
|
|
388
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
389
|
+
): never;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Creates reusable {@link assertCamel} function.
|
|
393
|
+
*
|
|
394
|
+
* @template T Type of input value
|
|
395
|
+
* @param errorFactory Custom error factory receiving
|
|
396
|
+
* {@link TypeGuardError.IProps}
|
|
397
|
+
* @returns Reusable conversion function
|
|
398
|
+
*/
|
|
399
|
+
export function createAssertCamel<T>(
|
|
400
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
401
|
+
): (input: T) => CamelCase<T>;
|
|
402
|
+
|
|
403
|
+
/** @internal */
|
|
404
|
+
export function createAssertCamel(): never {
|
|
405
|
+
NoTransformConfigurationError("notations.createAssertCamel");
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Creates reusable {@link isCamel} function.
|
|
410
|
+
*
|
|
411
|
+
* @danger You must configure the generic argument `T`
|
|
412
|
+
*/
|
|
413
|
+
export function createIsCamel(): never;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Creates reusable {@link isCamel} function.
|
|
417
|
+
*
|
|
418
|
+
* @template T Type of input value
|
|
419
|
+
* @returns Reusable conversion function
|
|
420
|
+
*/
|
|
421
|
+
export function createIsCamel<T>(): (input: T) => CamelCase<T> | null;
|
|
422
|
+
|
|
423
|
+
/** @internal */
|
|
424
|
+
export function createIsCamel(): never {
|
|
425
|
+
NoTransformConfigurationError("notations.createIsCamel");
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Creates reusable {@link validateCamel} function.
|
|
430
|
+
*
|
|
431
|
+
* @danger You must configure the generic argument `T`
|
|
432
|
+
*/
|
|
433
|
+
export function createValidateCamel(): never;
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Creates reusable {@link validateCamel} function.
|
|
437
|
+
*
|
|
438
|
+
* @template T Type of input value
|
|
439
|
+
* @returns Reusable conversion function
|
|
440
|
+
*/
|
|
441
|
+
export function createValidateCamel<T>(): (
|
|
442
|
+
input: T,
|
|
443
|
+
) => IValidation<CamelCase<T>>;
|
|
444
|
+
|
|
445
|
+
/** @internal */
|
|
446
|
+
export function createValidateCamel(): never {
|
|
447
|
+
NoTransformConfigurationError("notations.createValidateCamel");
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Creates reusable {@link pascal} function.
|
|
452
|
+
*
|
|
453
|
+
* @danger You must configure the generic argument `T`
|
|
454
|
+
*/
|
|
455
|
+
export function createPascal(): never;
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Creates reusable {@link pascal} function.
|
|
459
|
+
*
|
|
460
|
+
* @template T Type of input value
|
|
461
|
+
* @returns Reusable conversion function
|
|
462
|
+
*/
|
|
463
|
+
export function createPascal<T>(): (input: T) => PascalCase<T>;
|
|
464
|
+
|
|
465
|
+
/** @internal */
|
|
466
|
+
export function createPascal(): never {
|
|
467
|
+
NoTransformConfigurationError("notations.createPascal");
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Creates reusable {@link assertPascal} function.
|
|
472
|
+
*
|
|
473
|
+
* @danger You must configure the generic argument `T`
|
|
474
|
+
*/
|
|
475
|
+
export function createAssertPascal(
|
|
476
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
477
|
+
): never;
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Creates reusable {@link assertPascal} function.
|
|
481
|
+
*
|
|
482
|
+
* @template T Type of input value
|
|
483
|
+
* @param errorFactory Custom error factory receiving
|
|
484
|
+
* {@link TypeGuardError.IProps}
|
|
485
|
+
* @returns Reusable conversion function
|
|
486
|
+
*/
|
|
487
|
+
export function createAssertPascal<T>(
|
|
488
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
489
|
+
): (input: T) => PascalCase<T>;
|
|
490
|
+
|
|
491
|
+
/** @internal */
|
|
492
|
+
export function createAssertPascal(): never {
|
|
493
|
+
NoTransformConfigurationError("notations.createAssertPascal");
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Creates reusable {@link isPascal} function.
|
|
498
|
+
*
|
|
499
|
+
* @danger You must configure the generic argument `T`
|
|
500
|
+
*/
|
|
501
|
+
export function createIsPascal(): never;
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Creates reusable {@link isPascal} function.
|
|
505
|
+
*
|
|
506
|
+
* @template T Type of input value
|
|
507
|
+
* @returns Reusable conversion function
|
|
508
|
+
*/
|
|
509
|
+
export function createIsPascal<T>(): (input: T) => PascalCase<T> | null;
|
|
510
|
+
|
|
511
|
+
/** @internal */
|
|
512
|
+
export function createIsPascal(): never {
|
|
513
|
+
NoTransformConfigurationError("notations.createIsPascal");
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Creates reusable {@link validatePascal} function.
|
|
518
|
+
*
|
|
519
|
+
* @danger You must configure the generic argument `T`
|
|
520
|
+
*/
|
|
521
|
+
export function createValidatePascal(): never;
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Creates reusable {@link validatePascal} function.
|
|
525
|
+
*
|
|
526
|
+
* @template T Type of input value
|
|
527
|
+
* @returns Reusable conversion function
|
|
528
|
+
*/
|
|
529
|
+
export function createValidatePascal<T>(): (
|
|
530
|
+
input: T,
|
|
531
|
+
) => IValidation<PascalCase<T>>;
|
|
532
|
+
|
|
533
|
+
/** @internal */
|
|
534
|
+
export function createValidatePascal(): never {
|
|
535
|
+
NoTransformConfigurationError("notations.createValidatePascal");
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Creates reusable {@link snake} function.
|
|
540
|
+
*
|
|
541
|
+
* @danger You must configure the generic argument `T`
|
|
542
|
+
*/
|
|
543
|
+
export function createSnake(): never;
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Creates reusable {@link snake} function.
|
|
547
|
+
*
|
|
548
|
+
* @template T Type of input value
|
|
549
|
+
* @returns Reusable conversion function
|
|
550
|
+
*/
|
|
551
|
+
export function createSnake<T>(): (input: T) => SnakeCase<T>;
|
|
552
|
+
|
|
553
|
+
/** @internal */
|
|
554
|
+
export function createSnake(): never {
|
|
555
|
+
NoTransformConfigurationError("notations.createSnake");
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Creates reusable {@link assertSnake} function.
|
|
560
|
+
*
|
|
561
|
+
* @danger You must configure the generic argument `T`
|
|
562
|
+
*/
|
|
563
|
+
export function createAssertSnake(
|
|
564
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
565
|
+
): never;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Creates reusable {@link assertSnake} function.
|
|
569
|
+
*
|
|
570
|
+
* @template T Type of input value
|
|
571
|
+
* @param errorFactory Custom error factory receiving
|
|
572
|
+
* {@link TypeGuardError.IProps}
|
|
573
|
+
* @returns Reusable conversion function
|
|
574
|
+
*/
|
|
575
|
+
export function createAssertSnake<T>(
|
|
576
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
577
|
+
): (input: T) => SnakeCase<T>;
|
|
578
|
+
|
|
579
|
+
/** @internal */
|
|
580
|
+
export function createAssertSnake(): never {
|
|
581
|
+
NoTransformConfigurationError("notations.createAssertSnake");
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Creates reusable {@link isSnake} function.
|
|
586
|
+
*
|
|
587
|
+
* @danger You must configure the generic argument `T`
|
|
588
|
+
*/
|
|
589
|
+
export function createIsSnake(): never;
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Creates reusable {@link isSnake} function.
|
|
593
|
+
*
|
|
594
|
+
* @template T Type of input value
|
|
595
|
+
* @returns Reusable conversion function
|
|
596
|
+
*/
|
|
597
|
+
export function createIsSnake<T>(): (input: T) => SnakeCase<T> | null;
|
|
598
|
+
|
|
599
|
+
/** @internal */
|
|
600
|
+
export function createIsSnake(): never {
|
|
601
|
+
NoTransformConfigurationError("notations.createIsSnake");
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Creates reusable {@link validateSnake} function.
|
|
606
|
+
*
|
|
607
|
+
* @danger You must configure the generic argument `T`
|
|
608
|
+
*/
|
|
609
|
+
export function createValidateSnake(): never;
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Creates reusable {@link validateSnake} function.
|
|
613
|
+
*
|
|
614
|
+
* @template T Type of input value
|
|
615
|
+
* @returns Reusable conversion function
|
|
616
|
+
*/
|
|
617
|
+
export function createValidateSnake<T>(): (
|
|
618
|
+
input: T,
|
|
619
|
+
) => IValidation<SnakeCase<T>>;
|
|
620
|
+
|
|
621
|
+
/** @internal */
|
|
622
|
+
export function createValidateSnake(): never {
|
|
623
|
+
NoTransformConfigurationError("notations.createValidateSnake");
|
|
624
|
+
}
|