typia 3.6.3 → 3.6.4

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.
Files changed (138) hide show
  1. package/lib/functional/$is_uuid.js +1 -1
  2. package/lib/functional/$is_uuid.js.map +1 -1
  3. package/package.json +1 -1
  4. package/src/IRandomGenerator.ts +16 -16
  5. package/src/IValidation.ts +21 -21
  6. package/src/Primitive.ts +104 -104
  7. package/src/TypeGuardError.ts +36 -36
  8. package/src/executable/TypiaGenerateWizard.ts +87 -87
  9. package/src/executable/TypiaSetupWizard.ts +142 -142
  10. package/src/executable/setup/CommandExecutor.ts +8 -8
  11. package/src/executable/typia.ts +38 -38
  12. package/src/factories/CommentFactory.ts +10 -10
  13. package/src/factories/ExpressionFactory.ts +77 -77
  14. package/src/factories/IdentifierFactory.ts +73 -73
  15. package/src/factories/LiteralFactory.ts +44 -44
  16. package/src/factories/MetadataCollection.ts +122 -122
  17. package/src/factories/MetadataFactory.ts +51 -51
  18. package/src/factories/MetadataTagFactory.ts +265 -265
  19. package/src/factories/StatementFactory.ts +60 -60
  20. package/src/factories/TemplateFactory.ts +56 -56
  21. package/src/factories/TypeFactory.ts +129 -129
  22. package/src/factories/TypiaFileFactory.ts +117 -117
  23. package/src/factories/ValueFactory.ts +12 -12
  24. package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
  25. package/src/factories/internal/metadata/explore_metadata.ts +92 -92
  26. package/src/factories/internal/metadata/iterate_metadata.ts +80 -80
  27. package/src/factories/internal/metadata/iterate_metadata_array.ts +29 -29
  28. package/src/factories/internal/metadata/iterate_metadata_atomic.ts +59 -59
  29. package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
  30. package/src/factories/internal/metadata/iterate_metadata_constant.ts +58 -58
  31. package/src/factories/internal/metadata/iterate_metadata_map.ts +41 -41
  32. package/src/factories/internal/metadata/iterate_metadata_native.ts +222 -222
  33. package/src/factories/internal/metadata/iterate_metadata_object.ts +48 -48
  34. package/src/factories/internal/metadata/iterate_metadata_resolve.ts +27 -27
  35. package/src/factories/internal/metadata/iterate_metadata_set.ts +33 -33
  36. package/src/factories/internal/metadata/iterate_metadata_template.ts +38 -38
  37. package/src/factories/internal/metadata/iterate_metadata_tuple.ts +45 -45
  38. package/src/factories/internal/metadata/iterate_metadata_union.ts +59 -59
  39. package/src/functional/$any.ts +3 -3
  40. package/src/functional/$every.ts +11 -11
  41. package/src/functional/$guard.ts +35 -35
  42. package/src/functional/$is_between.ts +7 -7
  43. package/src/functional/$is_email.ts +5 -5
  44. package/src/functional/$is_ipv4.ts +5 -5
  45. package/src/functional/$is_ipv6.ts +5 -5
  46. package/src/functional/$is_url.ts +5 -5
  47. package/src/functional/$is_uuid.ts +4 -5
  48. package/src/functional/$join.ts +50 -50
  49. package/src/functional/$number.ts +12 -12
  50. package/src/functional/$report.ts +15 -15
  51. package/src/functional/$rest.ts +3 -3
  52. package/src/functional/$string.ts +37 -37
  53. package/src/functional/$tail.ts +6 -6
  54. package/src/functional/Namespace.ts +121 -121
  55. package/src/index.ts +4 -4
  56. package/src/metadata/IJsDocTagInfo.ts +10 -10
  57. package/src/metadata/IMetadata.ts +25 -25
  58. package/src/metadata/IMetadataApplication.ts +7 -7
  59. package/src/metadata/IMetadataConstant.ts +16 -16
  60. package/src/metadata/IMetadataEntry.ts +6 -6
  61. package/src/metadata/IMetadataObject.ts +29 -29
  62. package/src/metadata/IMetadataProperty.ts +11 -11
  63. package/src/metadata/IMetadataTag.ts +113 -113
  64. package/src/metadata/Metadata.ts +534 -534
  65. package/src/metadata/MetadataConstant.ts +3 -3
  66. package/src/metadata/MetadataObject.ts +131 -131
  67. package/src/metadata/MetadataProperty.ts +64 -64
  68. package/src/programmers/ApplicationProgrammer.ts +55 -55
  69. package/src/programmers/IsProgrammer.ts +200 -200
  70. package/src/programmers/helpers/AtomicPredicator.ts +31 -31
  71. package/src/programmers/helpers/CloneJoiner.ts +134 -134
  72. package/src/programmers/helpers/FunctionImporeter.ts +55 -55
  73. package/src/programmers/helpers/IExpressionEntry.ts +12 -12
  74. package/src/programmers/helpers/OptionPredicator.ts +19 -19
  75. package/src/programmers/helpers/PruneJoiner.ts +52 -52
  76. package/src/programmers/helpers/RandomJoiner.ts +149 -149
  77. package/src/programmers/helpers/RandomRanger.ts +216 -216
  78. package/src/programmers/helpers/StringifyJoinder.ts +114 -114
  79. package/src/programmers/helpers/StringifyPredicator.ts +18 -18
  80. package/src/programmers/helpers/UnionExplorer.ts +274 -274
  81. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  82. package/src/programmers/internal/application_array.ts +37 -37
  83. package/src/programmers/internal/application_boolean.ts +17 -17
  84. package/src/programmers/internal/application_constant.ts +29 -29
  85. package/src/programmers/internal/application_default.ts +17 -17
  86. package/src/programmers/internal/application_default_string.ts +32 -32
  87. package/src/programmers/internal/application_native.ts +29 -29
  88. package/src/programmers/internal/application_number.ts +70 -70
  89. package/src/programmers/internal/application_object.ts +153 -153
  90. package/src/programmers/internal/application_schema.ts +184 -184
  91. package/src/programmers/internal/application_string.ts +41 -41
  92. package/src/programmers/internal/application_templates.ts +27 -27
  93. package/src/programmers/internal/application_tuple.ts +29 -29
  94. package/src/programmers/internal/check_array.ts +22 -22
  95. package/src/programmers/internal/check_array_length.ts +44 -44
  96. package/src/programmers/internal/check_bigint.ts +64 -64
  97. package/src/programmers/internal/check_dynamic_properties.ts +197 -197
  98. package/src/programmers/internal/check_everything.ts +28 -28
  99. package/src/programmers/internal/check_native.ts +21 -21
  100. package/src/programmers/internal/check_number.ts +145 -145
  101. package/src/programmers/internal/check_object.ts +48 -48
  102. package/src/programmers/internal/check_string.ts +24 -24
  103. package/src/programmers/internal/check_string_tags.ts +63 -63
  104. package/src/programmers/internal/check_template.ts +50 -50
  105. package/src/programmers/internal/check_union_array_like.ts +260 -260
  106. package/src/programmers/internal/check_union_tuple.ts +33 -33
  107. package/src/programmers/internal/decode_union_object.ts +73 -73
  108. package/src/programmers/internal/feature_object_entries.ts +59 -59
  109. package/src/programmers/internal/metadata_to_pattern.ts +31 -31
  110. package/src/programmers/internal/prune_object_properties.ts +60 -60
  111. package/src/programmers/internal/stringify_dynamic_properties.ts +165 -165
  112. package/src/programmers/internal/stringify_native.ts +8 -8
  113. package/src/programmers/internal/stringify_regular_properties.ts +81 -81
  114. package/src/programmers/internal/template_to_pattern.ts +15 -15
  115. package/src/schemas/IJsonApplication.ts +9 -9
  116. package/src/schemas/IJsonComponents.ts +26 -26
  117. package/src/schemas/IJsonSchema.ts +127 -127
  118. package/src/transform.ts +21 -21
  119. package/src/transformers/CallExpressionTransformer.ts +172 -172
  120. package/src/transformers/ExpressionWithArgumentTransformer.ts +66 -66
  121. package/src/transformers/FileTransformer.ts +49 -49
  122. package/src/transformers/IProject.ts +11 -11
  123. package/src/transformers/ITransformOptions.ts +62 -62
  124. package/src/transformers/ImportTransformer.ts +60 -60
  125. package/src/transformers/NodeTransformer.ts +19 -19
  126. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +120 -120
  127. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +55 -55
  128. package/src/typings/Atomic.ts +17 -17
  129. package/src/typings/ClassProperties.ts +5 -5
  130. package/src/typings/OmitNever.ts +3 -3
  131. package/src/typings/SpecialFields.ts +3 -3
  132. package/src/typings/Writable.ts +11 -11
  133. package/src/utils/ArrayUtil.ts +49 -49
  134. package/src/utils/Escaper.ts +50 -50
  135. package/src/utils/MapUtil.ts +14 -14
  136. package/src/utils/PatternUtil.ts +30 -30
  137. package/src/utils/RandomGenerator.ts +90 -90
  138. package/src/utils/Singleton.ts +17 -17
@@ -1,5 +1,5 @@
1
- export function $is_ipv6(str: string): boolean {
2
- return REGEX.test(str);
3
- }
4
- const REGEX =
5
- /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
1
+ export function $is_ipv6(str: string): boolean {
2
+ return REGEX.test(str);
3
+ }
4
+ const REGEX =
5
+ /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
@@ -1,5 +1,5 @@
1
- export function $is_url(str: string): boolean {
2
- return REGEX.test(str);
3
- }
4
- const REGEX =
5
- /^[a-zA-Z0-9]+:\/\/(?:www.)?[-a-zA-Z0-9@:%._+~#=]{1,256}.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)$/;
1
+ export function $is_url(str: string): boolean {
2
+ return REGEX.test(str);
3
+ }
4
+ const REGEX =
5
+ /^[a-zA-Z0-9]+:\/\/(?:www.)?[-a-zA-Z0-9@:%._+~#=]{1,256}.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)$/;
@@ -1,5 +1,4 @@
1
- export function $is_uuid(str: string): boolean {
2
- return REGEX.test(str);
3
- }
4
- const REGEX =
5
- /[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;
1
+ export function $is_uuid(str: string): boolean {
2
+ return REGEX.test(str);
3
+ }
4
+ const REGEX = /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i;
@@ -1,50 +1,50 @@
1
- export function $join(str: string): string {
2
- return variable(str) ? `.${str}` : `[${JSON.stringify(str)}]`;
3
- }
4
-
5
- function variable(str: string): boolean {
6
- return reserved(str) === false && /^[a-zA-Z_$][a-zA-Z_$0-9]*$/g.test(str);
7
- }
8
-
9
- function reserved(str: string): boolean {
10
- return RESERVED.has(str);
11
- }
12
-
13
- const RESERVED: Set<string> = new Set([
14
- "break",
15
- "case",
16
- "catch",
17
- "class",
18
- "const",
19
- "continue",
20
- "debugger",
21
- "default",
22
- "delete",
23
- "do",
24
- "else",
25
- "enum",
26
- "export",
27
- "extends",
28
- "false",
29
- "finally",
30
- "for",
31
- "function",
32
- "if",
33
- "import",
34
- "in",
35
- "instanceof",
36
- "new",
37
- "null",
38
- "return",
39
- "super",
40
- "switch",
41
- "this",
42
- "throw",
43
- "true",
44
- "try",
45
- "typeof",
46
- "var",
47
- "void",
48
- "while",
49
- "with",
50
- ]);
1
+ export function $join(str: string): string {
2
+ return variable(str) ? `.${str}` : `[${JSON.stringify(str)}]`;
3
+ }
4
+
5
+ function variable(str: string): boolean {
6
+ return reserved(str) === false && /^[a-zA-Z_$][a-zA-Z_$0-9]*$/g.test(str);
7
+ }
8
+
9
+ function reserved(str: string): boolean {
10
+ return RESERVED.has(str);
11
+ }
12
+
13
+ const RESERVED: Set<string> = new Set([
14
+ "break",
15
+ "case",
16
+ "catch",
17
+ "class",
18
+ "const",
19
+ "continue",
20
+ "debugger",
21
+ "default",
22
+ "delete",
23
+ "do",
24
+ "else",
25
+ "enum",
26
+ "export",
27
+ "extends",
28
+ "false",
29
+ "finally",
30
+ "for",
31
+ "function",
32
+ "if",
33
+ "import",
34
+ "in",
35
+ "instanceof",
36
+ "new",
37
+ "null",
38
+ "return",
39
+ "super",
40
+ "switch",
41
+ "this",
42
+ "throw",
43
+ "true",
44
+ "try",
45
+ "typeof",
46
+ "var",
47
+ "void",
48
+ "while",
49
+ "with",
50
+ ]);
@@ -1,12 +1,12 @@
1
- import { TypeGuardError } from "../TypeGuardError";
2
-
3
- export function $number(value: number): number {
4
- if (isFinite(value) === false)
5
- throw new TypeGuardError({
6
- method: "typia.stringify",
7
- expected: "number",
8
- value,
9
- message: "Error on typia.stringify(): infinite or not a number.",
10
- });
11
- return value;
12
- }
1
+ import { TypeGuardError } from "../TypeGuardError";
2
+
3
+ export function $number(value: number): number {
4
+ if (isFinite(value) === false)
5
+ throw new TypeGuardError({
6
+ method: "typia.stringify",
7
+ expected: "number",
8
+ value,
9
+ message: "Error on typia.stringify(): infinite or not a number.",
10
+ });
11
+ return value;
12
+ }
@@ -1,15 +1,15 @@
1
- import { IValidation } from "../IValidation";
2
-
3
- export const $report = (array: IValidation.IError[]) => {
4
- const reportable = (path: string): boolean => {
5
- if (array.length === 0) return true;
6
- const last: string = array[array.length - 1]!.path;
7
- return (
8
- path.length > last.length || last.substring(0, path.length) !== path
9
- );
10
- };
11
- return (exceptable: boolean, error: IValidation.IError): false => {
12
- if (exceptable && reportable(error.path)) array.push(error);
13
- return false;
14
- };
15
- };
1
+ import { IValidation } from "../IValidation";
2
+
3
+ export const $report = (array: IValidation.IError[]) => {
4
+ const reportable = (path: string): boolean => {
5
+ if (array.length === 0) return true;
6
+ const last: string = array[array.length - 1]!.path;
7
+ return (
8
+ path.length > last.length || last.substring(0, path.length) !== path
9
+ );
10
+ };
11
+ return (exceptable: boolean, error: IValidation.IError): false => {
12
+ if (exceptable && reportable(error.path)) array.push(error);
13
+ return false;
14
+ };
15
+ };
@@ -1,3 +1,3 @@
1
- export function $rest(str: string): string {
2
- return str.length === 2 ? "" : "," + str.substring(1, str.length - 1);
3
- }
1
+ export function $rest(str: string): string {
2
+ return str.length === 2 ? "" : "," + str.substring(1, str.length - 1);
3
+ }
@@ -1,37 +1,37 @@
1
- /**
2
- * @internal
3
- */
4
- export function $string(str: string): string {
5
- if (str.length > 41) return JSON.stringify(str);
6
-
7
- const length = str.length;
8
- let result = "";
9
- let last = 0;
10
- let found = false;
11
- let surrogateFound = false;
12
- let point = 255;
13
-
14
- // eslint-disable-next-line
15
- for (let i = 0; i < length && point >= 32; i++) {
16
- point = str.charCodeAt(i);
17
- if (0xd800 <= point && point <= 0xdfff) {
18
- // The current character is a surrogate.
19
- surrogateFound = true;
20
- break;
21
- }
22
- if (point === 34 || point === 92) {
23
- result += str.slice(last, i) + "\\";
24
- last = i;
25
- found = true;
26
- }
27
- }
28
-
29
- if (!found) {
30
- result = str;
31
- } else {
32
- result += str.slice(last);
33
- }
34
- return point < 32 || surrogateFound === true
35
- ? JSON.stringify(str)
36
- : `"${result}"`;
37
- }
1
+ /**
2
+ * @internal
3
+ */
4
+ export function $string(str: string): string {
5
+ if (str.length > 41) return JSON.stringify(str);
6
+
7
+ const length = str.length;
8
+ let result = "";
9
+ let last = 0;
10
+ let found = false;
11
+ let surrogateFound = false;
12
+ let point = 255;
13
+
14
+ // eslint-disable-next-line
15
+ for (let i = 0; i < length && point >= 32; i++) {
16
+ point = str.charCodeAt(i);
17
+ if (0xd800 <= point && point <= 0xdfff) {
18
+ // The current character is a surrogate.
19
+ surrogateFound = true;
20
+ break;
21
+ }
22
+ if (point === 34 || point === 92) {
23
+ result += str.slice(last, i) + "\\";
24
+ last = i;
25
+ found = true;
26
+ }
27
+ }
28
+
29
+ if (!found) {
30
+ result = str;
31
+ } else {
32
+ result += str.slice(last);
33
+ }
34
+ return point < 32 || surrogateFound === true
35
+ ? JSON.stringify(str)
36
+ : `"${result}"`;
37
+ }
@@ -1,6 +1,6 @@
1
- /**
2
- * @internal
3
- */
4
- export function $tail(str: string): string {
5
- return str[str.length - 1] === "," ? str.substring(0, str.length - 1) : str;
6
- }
1
+ /**
2
+ * @internal
3
+ */
4
+ export function $tail(str: string): string {
5
+ return str[str.length - 1] === "," ? str.substring(0, str.length - 1) : str;
6
+ }
@@ -1,121 +1,121 @@
1
- import { RandomGenerator } from "../utils/RandomGenerator";
2
-
3
- import { IValidation } from "../IValidation";
4
- import { TypeGuardError } from "../TypeGuardError";
5
- import { $any } from "./$any";
6
- import { $every } from "./$every";
7
- import { $guard } from "./$guard";
8
- import { $is_between } from "./$is_between";
9
- import { $is_email } from "./$is_email";
10
- import { $is_ipv4 } from "./$is_ipv4";
11
- import { $is_ipv6 } from "./$is_ipv6";
12
- import { $is_url } from "./$is_url";
13
- import { $is_uuid } from "./$is_uuid";
14
- import { $join } from "./$join";
15
- import { $number } from "./$number";
16
- import { $report } from "./$report";
17
- import { $rest } from "./$rest";
18
- import { $string } from "./$string";
19
- import { $tail } from "./$tail";
20
-
21
- /**
22
- * @internal
23
- */
24
- export namespace Namespace {
25
- export const is = () => ({
26
- is_uuid: $is_uuid,
27
- is_email: $is_email,
28
- is_url: $is_url,
29
- is_ipv4: $is_ipv4,
30
- is_ipv6: $is_ipv6,
31
- is_between: $is_between,
32
- });
33
-
34
- export const assert = (method: string) => ({
35
- ...is(),
36
- join: $join,
37
- every: $every,
38
- guard: $guard(`typia.${method}`),
39
- predicate: (
40
- matched: boolean,
41
- exceptionable: boolean,
42
- closure: () => Omit<TypeGuardError.IProps, "method">,
43
- ): boolean => {
44
- if (matched === false && exceptionable === true)
45
- throw new TypeGuardError({
46
- ...closure(),
47
- method: `typia.${method}`,
48
- });
49
- return matched;
50
- },
51
- });
52
-
53
- export const validate = () => ({
54
- ...is(),
55
- join: $join,
56
- report: $report,
57
- predicate:
58
- (res: IValidation) =>
59
- (
60
- matched: boolean,
61
- exceptionable: boolean,
62
- closure: () => IValidation.IError,
63
- ) => {
64
- // CHECK FAILURE
65
- if (matched === false && exceptionable === true)
66
- (() => {
67
- res.success &&= false;
68
- const errorList = (res as IValidation.IFailure).errors;
69
-
70
- // TRACE ERROR
71
- const error = closure();
72
- if (errorList.length) {
73
- const last = errorList[errorList.length - 1]!.path;
74
- if (
75
- last.length >= error.path.length &&
76
- last.substring(0, error.path.length) ===
77
- error.path
78
- )
79
- return;
80
- }
81
- errorList.push(error);
82
- return;
83
- })();
84
- return matched;
85
- },
86
- });
87
-
88
- export const stringify = (method: string) => ({
89
- ...is(),
90
- number: $number,
91
- string: $string,
92
- tail: $tail,
93
- rest: $rest,
94
- throws: $throws(method),
95
- });
96
-
97
- export const clone = (method: string) => ({
98
- ...is(),
99
- throws: $throws(method),
100
- any: $any,
101
- });
102
-
103
- export const prune = (method: string) => ({
104
- ...is(),
105
- throws: $throws(method),
106
- });
107
-
108
- export const random = () => ({
109
- generator: RandomGenerator,
110
- pick: RandomGenerator.pick,
111
- });
112
-
113
- const $throws =
114
- (method: string) =>
115
- (props: Pick<TypeGuardError.IProps, "expected" | "value">) => {
116
- throw new TypeGuardError({
117
- ...props,
118
- method: `typia.${method}`,
119
- });
120
- };
121
- }
1
+ import { RandomGenerator } from "../utils/RandomGenerator";
2
+
3
+ import { IValidation } from "../IValidation";
4
+ import { TypeGuardError } from "../TypeGuardError";
5
+ import { $any } from "./$any";
6
+ import { $every } from "./$every";
7
+ import { $guard } from "./$guard";
8
+ import { $is_between } from "./$is_between";
9
+ import { $is_email } from "./$is_email";
10
+ import { $is_ipv4 } from "./$is_ipv4";
11
+ import { $is_ipv6 } from "./$is_ipv6";
12
+ import { $is_url } from "./$is_url";
13
+ import { $is_uuid } from "./$is_uuid";
14
+ import { $join } from "./$join";
15
+ import { $number } from "./$number";
16
+ import { $report } from "./$report";
17
+ import { $rest } from "./$rest";
18
+ import { $string } from "./$string";
19
+ import { $tail } from "./$tail";
20
+
21
+ /**
22
+ * @internal
23
+ */
24
+ export namespace Namespace {
25
+ export const is = () => ({
26
+ is_uuid: $is_uuid,
27
+ is_email: $is_email,
28
+ is_url: $is_url,
29
+ is_ipv4: $is_ipv4,
30
+ is_ipv6: $is_ipv6,
31
+ is_between: $is_between,
32
+ });
33
+
34
+ export const assert = (method: string) => ({
35
+ ...is(),
36
+ join: $join,
37
+ every: $every,
38
+ guard: $guard(`typia.${method}`),
39
+ predicate: (
40
+ matched: boolean,
41
+ exceptionable: boolean,
42
+ closure: () => Omit<TypeGuardError.IProps, "method">,
43
+ ): boolean => {
44
+ if (matched === false && exceptionable === true)
45
+ throw new TypeGuardError({
46
+ ...closure(),
47
+ method: `typia.${method}`,
48
+ });
49
+ return matched;
50
+ },
51
+ });
52
+
53
+ export const validate = () => ({
54
+ ...is(),
55
+ join: $join,
56
+ report: $report,
57
+ predicate:
58
+ (res: IValidation) =>
59
+ (
60
+ matched: boolean,
61
+ exceptionable: boolean,
62
+ closure: () => IValidation.IError,
63
+ ) => {
64
+ // CHECK FAILURE
65
+ if (matched === false && exceptionable === true)
66
+ (() => {
67
+ res.success &&= false;
68
+ const errorList = (res as IValidation.IFailure).errors;
69
+
70
+ // TRACE ERROR
71
+ const error = closure();
72
+ if (errorList.length) {
73
+ const last = errorList[errorList.length - 1]!.path;
74
+ if (
75
+ last.length >= error.path.length &&
76
+ last.substring(0, error.path.length) ===
77
+ error.path
78
+ )
79
+ return;
80
+ }
81
+ errorList.push(error);
82
+ return;
83
+ })();
84
+ return matched;
85
+ },
86
+ });
87
+
88
+ export const stringify = (method: string) => ({
89
+ ...is(),
90
+ number: $number,
91
+ string: $string,
92
+ tail: $tail,
93
+ rest: $rest,
94
+ throws: $throws(method),
95
+ });
96
+
97
+ export const clone = (method: string) => ({
98
+ ...is(),
99
+ throws: $throws(method),
100
+ any: $any,
101
+ });
102
+
103
+ export const prune = (method: string) => ({
104
+ ...is(),
105
+ throws: $throws(method),
106
+ });
107
+
108
+ export const random = () => ({
109
+ generator: RandomGenerator,
110
+ pick: RandomGenerator.pick,
111
+ });
112
+
113
+ const $throws =
114
+ (method: string) =>
115
+ (props: Pick<TypeGuardError.IProps, "expected" | "value">) => {
116
+ throw new TypeGuardError({
117
+ ...props,
118
+ method: `typia.${method}`,
119
+ });
120
+ };
121
+ }
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as typia from "./module";
2
-
3
- export default typia;
4
- export * from "./module";
1
+ import * as typia from "./module";
2
+
3
+ export default typia;
4
+ export * from "./module";
@@ -1,10 +1,10 @@
1
- export interface IJsDocTagInfo {
2
- name: string;
3
- text?: IJsDocTagInfo.IText[];
4
- }
5
- export namespace IJsDocTagInfo {
6
- export interface IText {
7
- text: string;
8
- kind: string;
9
- }
10
- }
1
+ export interface IJsDocTagInfo {
2
+ name: string;
3
+ text?: IJsDocTagInfo.IText[];
4
+ }
5
+ export namespace IJsDocTagInfo {
6
+ export interface IText {
7
+ text: string;
8
+ kind: string;
9
+ }
10
+ }
@@ -1,25 +1,25 @@
1
- import { Atomic } from "../typings/Atomic";
2
-
3
- import { IMetadataConstant } from "./IMetadataConstant";
4
- import { IMetadataEntry } from "./IMetadataEntry";
5
-
6
- export interface IMetadata {
7
- any: boolean;
8
- required: boolean;
9
- nullable: boolean;
10
- functional: boolean;
11
-
12
- atomics: Atomic.Literal[];
13
- constants: IMetadataConstant[];
14
- templates: IMetadata[][];
15
- resolved: IMetadata | null;
16
-
17
- rest: IMetadata | null;
18
- arrays: IMetadata[];
19
- tuples: IMetadata[][];
20
- objects: string[];
21
-
22
- natives: string[];
23
- sets: IMetadata[];
24
- maps: IMetadataEntry[];
25
- }
1
+ import { Atomic } from "../typings/Atomic";
2
+
3
+ import { IMetadataConstant } from "./IMetadataConstant";
4
+ import { IMetadataEntry } from "./IMetadataEntry";
5
+
6
+ export interface IMetadata {
7
+ any: boolean;
8
+ required: boolean;
9
+ nullable: boolean;
10
+ functional: boolean;
11
+
12
+ atomics: Atomic.Literal[];
13
+ constants: IMetadataConstant[];
14
+ templates: IMetadata[][];
15
+ resolved: IMetadata | null;
16
+
17
+ rest: IMetadata | null;
18
+ arrays: IMetadata[];
19
+ tuples: IMetadata[][];
20
+ objects: string[];
21
+
22
+ natives: string[];
23
+ sets: IMetadata[];
24
+ maps: IMetadataEntry[];
25
+ }
@@ -1,7 +1,7 @@
1
- import { IMetadata } from "./IMetadata";
2
- import { IMetadataObject } from "./IMetadataObject";
3
-
4
- export interface IMetadataApplication {
5
- metadatas: IMetadata[];
6
- collection: IMetadataObject[];
7
- }
1
+ import { IMetadata } from "./IMetadata";
2
+ import { IMetadataObject } from "./IMetadataObject";
3
+
4
+ export interface IMetadataApplication {
5
+ metadatas: IMetadata[];
6
+ collection: IMetadataObject[];
7
+ }
@@ -1,16 +1,16 @@
1
- import { Atomic } from "../typings/Atomic";
2
-
3
- export type IMetadataConstant =
4
- | IMetadataConstant.IBase<"boolean", boolean>
5
- | IMetadataConstant.IBase<"number", number>
6
- | IMetadataConstant.IBase<"string", string>
7
- | IMetadataConstant.IBase<"bigint", bigint>;
8
- export namespace IMetadataConstant {
9
- export interface IBase<
10
- Type extends Atomic.Literal,
11
- Value extends Atomic.Type,
12
- > {
13
- type: Type;
14
- values: Value[];
15
- }
16
- }
1
+ import { Atomic } from "../typings/Atomic";
2
+
3
+ export type IMetadataConstant =
4
+ | IMetadataConstant.IBase<"boolean", boolean>
5
+ | IMetadataConstant.IBase<"number", number>
6
+ | IMetadataConstant.IBase<"string", string>
7
+ | IMetadataConstant.IBase<"bigint", bigint>;
8
+ export namespace IMetadataConstant {
9
+ export interface IBase<
10
+ Type extends Atomic.Literal,
11
+ Value extends Atomic.Type,
12
+ > {
13
+ type: Type;
14
+ values: Value[];
15
+ }
16
+ }