typia 3.5.0-dev.20221222 → 3.5.0-dev.20230107

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 (150) hide show
  1. package/README.md +5 -2
  2. package/lib/executable/internal/TypiaSetupWizard.d.ts +6 -2
  3. package/lib/executable/internal/TypiaSetupWizard.js +23 -22
  4. package/lib/executable/internal/TypiaSetupWizard.js.map +1 -1
  5. package/lib/executable/typia.js +11 -10
  6. package/lib/executable/typia.js.map +1 -1
  7. package/lib/metadata/Metadata.js +32 -29
  8. package/lib/metadata/Metadata.js.map +1 -1
  9. package/lib/programmers/AssertProgrammer.js +1 -1
  10. package/lib/programmers/AssertProgrammer.js.map +1 -1
  11. package/lib/programmers/CheckerProgrammer.d.ts +1 -0
  12. package/lib/programmers/CheckerProgrammer.js +147 -138
  13. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  14. package/lib/programmers/ValidateProgrammer.js +1 -1
  15. package/lib/programmers/ValidateProgrammer.js.map +1 -1
  16. package/lib/programmers/helpers/UnionExplorer.d.ts +23 -29
  17. package/lib/programmers/helpers/UnionExplorer.js +29 -41
  18. package/lib/programmers/helpers/UnionExplorer.js.map +1 -1
  19. package/lib/programmers/internal/application_schema.js +2 -0
  20. package/lib/programmers/internal/application_schema.js.map +1 -1
  21. package/lib/programmers/internal/check_array.js +4 -32
  22. package/lib/programmers/internal/check_array.js.map +1 -1
  23. package/lib/programmers/internal/check_array_length.d.ts +1 -0
  24. package/lib/programmers/internal/check_array_length.js +47 -0
  25. package/lib/programmers/internal/check_array_length.js.map +1 -0
  26. package/lib/programmers/internal/check_union_array_like.d.ts +21 -0
  27. package/lib/programmers/internal/check_union_array_like.js +83 -0
  28. package/lib/programmers/internal/check_union_array_like.js.map +1 -0
  29. package/lib/programmers/internal/check_union_tuple.d.ts +1 -0
  30. package/lib/programmers/internal/check_union_tuple.js +11 -0
  31. package/lib/programmers/internal/check_union_tuple.js.map +1 -0
  32. package/package.json +4 -4
  33. package/src/IValidation.ts +21 -21
  34. package/src/Primitive.ts +82 -82
  35. package/src/TypeGuardError.ts +36 -36
  36. package/src/executable/internal/CommandParser.ts +15 -15
  37. package/src/executable/internal/TypiaSetupWizard.ts +30 -21
  38. package/src/executable/typia.ts +48 -46
  39. package/src/factories/CommentFactory.ts +10 -10
  40. package/src/factories/ExpressionFactory.ts +66 -66
  41. package/src/factories/IdentifierFactory.ts +72 -72
  42. package/src/factories/LiteralFactory.ts +44 -44
  43. package/src/factories/StatementFactory.ts +60 -60
  44. package/src/factories/TemplateFactory.ts +56 -56
  45. package/src/factories/TypeFactory.ts +101 -101
  46. package/src/factories/ValueFactory.ts +12 -12
  47. package/src/functional/$every.ts +11 -11
  48. package/src/functional/$guard.ts +35 -35
  49. package/src/functional/$is_email.ts +5 -5
  50. package/src/functional/$is_ipv4.ts +5 -5
  51. package/src/functional/$is_ipv6.ts +5 -5
  52. package/src/functional/$is_url.ts +5 -5
  53. package/src/functional/$is_uuid.ts +5 -5
  54. package/src/functional/$join.ts +50 -50
  55. package/src/functional/$report.ts +15 -15
  56. package/src/functional/$rest.ts +3 -3
  57. package/src/functional/$string.ts +37 -37
  58. package/src/functional/$tail.ts +6 -6
  59. package/src/index.ts +4 -4
  60. package/src/metadata/IJsDocTagInfo.ts +10 -10
  61. package/src/metadata/IMetadata.ts +25 -25
  62. package/src/metadata/IMetadataApplication.ts +7 -7
  63. package/src/metadata/IMetadataConstant.ts +16 -16
  64. package/src/metadata/IMetadataEntry.ts +6 -6
  65. package/src/metadata/IMetadataObject.ts +29 -29
  66. package/src/metadata/IMetadataProperty.ts +11 -11
  67. package/src/metadata/Metadata.ts +10 -7
  68. package/src/metadata/MetadataConstant.ts +3 -3
  69. package/src/metadata/MetadataObject.ts +131 -131
  70. package/src/metadata/MetadataProperty.ts +64 -64
  71. package/src/programmers/ApplicationProgrammer.ts +55 -55
  72. package/src/programmers/AssertProgrammer.ts +1 -1
  73. package/src/programmers/CheckerProgrammer.ts +252 -200
  74. package/src/programmers/FeatureProgrammer.ts +327 -327
  75. package/src/programmers/ValidateProgrammer.ts +1 -1
  76. package/src/programmers/helpers/AtomicPredicator.ts +15 -15
  77. package/src/programmers/helpers/FunctionImporeter.ts +31 -31
  78. package/src/programmers/helpers/IExpressionEntry.ts +10 -10
  79. package/src/programmers/helpers/StringifyJoinder.ts +111 -111
  80. package/src/programmers/helpers/StringifyPredicator.ts +18 -18
  81. package/src/programmers/helpers/UnionExplorer.ts +274 -437
  82. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  83. package/src/programmers/internal/application_array.ts +45 -45
  84. package/src/programmers/internal/application_boolean.ts +17 -17
  85. package/src/programmers/internal/application_constant.ts +29 -29
  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 +76 -76
  89. package/src/programmers/internal/application_object.ts +103 -103
  90. package/src/programmers/internal/application_schema.ts +5 -0
  91. package/src/programmers/internal/application_string.ts +49 -49
  92. package/src/programmers/internal/application_templates.ts +27 -27
  93. package/src/programmers/internal/application_tuple.ts +25 -25
  94. package/src/programmers/internal/check_array.ts +22 -44
  95. package/src/programmers/internal/check_array_length.ts +45 -0
  96. package/src/programmers/internal/check_dynamic_properties.ts +146 -146
  97. package/src/programmers/internal/check_everything.ts +25 -25
  98. package/src/programmers/internal/check_length.ts +46 -46
  99. package/src/programmers/internal/check_native.ts +9 -9
  100. package/src/programmers/internal/check_object.ts +42 -42
  101. package/src/programmers/internal/check_string.ts +24 -24
  102. package/src/programmers/internal/check_string_tags.ts +63 -63
  103. package/src/programmers/internal/check_template.ts +50 -50
  104. package/src/programmers/internal/check_union_array_like.ts +242 -0
  105. package/src/programmers/internal/check_union_tuple.ts +33 -0
  106. package/src/programmers/internal/decode_union_object.ts +73 -73
  107. package/src/programmers/internal/feature_object_entries.ts +49 -49
  108. package/src/programmers/internal/metadata_to_pattern.ts +31 -31
  109. package/src/programmers/internal/stringify_dynamic_properties.ts +164 -164
  110. package/src/programmers/internal/stringify_native.ts +8 -8
  111. package/src/programmers/internal/stringify_regular_properties.ts +81 -81
  112. package/src/programmers/internal/template_to_pattern.ts +15 -15
  113. package/src/schemas/IJsonApplication.ts +9 -9
  114. package/src/schemas/IJsonComponents.ts +24 -24
  115. package/src/transform.ts +20 -20
  116. package/src/transformers/ExpressionWithArgumentTransformer.ts +66 -66
  117. package/src/transformers/FileTransformer.ts +49 -49
  118. package/src/transformers/IProject.ts +11 -11
  119. package/src/transformers/NodeTransformer.ts +19 -19
  120. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +1 -0
  121. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +55 -55
  122. package/src/transformers/features/parsers/AssertParseTransformer.ts +36 -36
  123. package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +32 -32
  124. package/src/transformers/features/parsers/CreateIsParseTransformer.ts +32 -32
  125. package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +32 -32
  126. package/src/transformers/features/parsers/IsParseTransformer.ts +36 -36
  127. package/src/transformers/features/parsers/ValidateParseTransformer.ts +36 -36
  128. package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +38 -38
  129. package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +32 -32
  130. package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +32 -32
  131. package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +31 -31
  132. package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +32 -32
  133. package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +38 -38
  134. package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +38 -38
  135. package/src/transformers/features/validators/AssertTransformer.ts +43 -43
  136. package/src/transformers/features/validators/CreateAssertTransformer.ts +35 -35
  137. package/src/transformers/features/validators/CreateIsTransformer.ts +35 -35
  138. package/src/transformers/features/validators/CreateValidateTransformer.ts +35 -35
  139. package/src/transformers/features/validators/IsTransformer.ts +43 -43
  140. package/src/transformers/features/validators/ValidateTransformer.ts +43 -43
  141. package/src/typings/Atomic.ts +17 -17
  142. package/src/typings/ClassProperties.ts +5 -5
  143. package/src/typings/OmitNever.ts +3 -3
  144. package/src/typings/SpecialFields.ts +3 -3
  145. package/src/typings/Writable.ts +11 -11
  146. package/src/utils/ArrayUtil.ts +49 -49
  147. package/src/utils/Escaper.ts +50 -50
  148. package/src/utils/MapUtil.ts +14 -14
  149. package/src/utils/PatternUtil.ts +30 -30
  150. package/src/utils/Singleton.ts +17 -17
@@ -1,12 +1,12 @@
1
- import ts from "typescript";
2
-
3
- export namespace ValueFactory {
4
- export const NULL = () => ts.factory.createNull();
5
- export const UNDEFINED = () => ts.factory.createIdentifier("undefined");
6
- export const BOOLEAN = (value: boolean) =>
7
- value ? ts.factory.createTrue() : ts.factory.createFalse();
8
- export const INPUT = (str: string = "input") =>
9
- ts.factory.createIdentifier(str);
10
- export const TYPEOF = (input: ts.Expression) =>
11
- ts.factory.createTypeOfExpression(input);
12
- }
1
+ import ts from "typescript";
2
+
3
+ export namespace ValueFactory {
4
+ export const NULL = () => ts.factory.createNull();
5
+ export const UNDEFINED = () => ts.factory.createIdentifier("undefined");
6
+ export const BOOLEAN = (value: boolean) =>
7
+ value ? ts.factory.createTrue() : ts.factory.createFalse();
8
+ export const INPUT = (str: string = "input") =>
9
+ ts.factory.createIdentifier(str);
10
+ export const TYPEOF = (input: ts.Expression) =>
11
+ ts.factory.createTypeOfExpression(input);
12
+ }
@@ -1,11 +1,11 @@
1
- import { TypeGuardError } from "../TypeGuardError";
2
-
3
- export const $every = <T>(
4
- array: T[],
5
- pred: (value: T, i: number) => null | Omit<TypeGuardError.IProps, "method">,
6
- ): null | Omit<TypeGuardError.IProps, "method"> => {
7
- let error: null | Omit<TypeGuardError.IProps, "method"> = null;
8
- for (let i: number = 0; i < array.length; ++i)
9
- if (null !== (error = pred(array[i]!, i))) return error;
10
- return null;
11
- };
1
+ import { TypeGuardError } from "../TypeGuardError";
2
+
3
+ export const $every = <T>(
4
+ array: T[],
5
+ pred: (value: T, i: number) => null | Omit<TypeGuardError.IProps, "method">,
6
+ ): null | Omit<TypeGuardError.IProps, "method"> => {
7
+ let error: null | Omit<TypeGuardError.IProps, "method"> = null;
8
+ for (let i: number = 0; i < array.length; ++i)
9
+ if (null !== (error = pred(array[i]!, i))) return error;
10
+ return null;
11
+ };
@@ -1,35 +1,35 @@
1
- import { TypeGuardError } from "../TypeGuardError";
2
-
3
- /* -----------------------------------------------------------
4
- ASSERT V2 -> USE (NULL OR ERROR) CONDITION
5
- ----------------------------------------------------------- */
6
- // /**
7
- // * @internal
8
- // */
9
- // export const $guardV2 =
10
- // (method: string) => (props: Omit<TypeGuardError.IProps, "method">) =>
11
- // new TypeGuardError({
12
- // method,
13
- // path: props.path,
14
- // expected: props.expected,
15
- // value: props.value,
16
- // });
17
-
18
- /* -----------------------------------------------------------
19
- ASSERT V3 -> (CONDITION OR THROW(exceptable): FALSE)
20
- ----------------------------------------------------------- */
21
- /**
22
- * @internal
23
- */
24
- export const $guard =
25
- (method: string) =>
26
- (exceptionable: boolean, props: Omit<TypeGuardError.IProps, "method">) => {
27
- if (exceptionable === true)
28
- throw new TypeGuardError({
29
- method,
30
- path: props.path,
31
- expected: props.expected,
32
- value: props.value,
33
- });
34
- return false;
35
- };
1
+ import { TypeGuardError } from "../TypeGuardError";
2
+
3
+ /* -----------------------------------------------------------
4
+ ASSERT V2 -> USE (NULL OR ERROR) CONDITION
5
+ ----------------------------------------------------------- */
6
+ // /**
7
+ // * @internal
8
+ // */
9
+ // export const $guardV2 =
10
+ // (method: string) => (props: Omit<TypeGuardError.IProps, "method">) =>
11
+ // new TypeGuardError({
12
+ // method,
13
+ // path: props.path,
14
+ // expected: props.expected,
15
+ // value: props.value,
16
+ // });
17
+
18
+ /* -----------------------------------------------------------
19
+ ASSERT V3 -> (CONDITION OR THROW(exceptable): FALSE)
20
+ ----------------------------------------------------------- */
21
+ /**
22
+ * @internal
23
+ */
24
+ export const $guard =
25
+ (method: string) =>
26
+ (exceptionable: boolean, props: Omit<TypeGuardError.IProps, "method">) => {
27
+ if (exceptionable === true)
28
+ throw new TypeGuardError({
29
+ method,
30
+ path: props.path,
31
+ expected: props.expected,
32
+ value: props.value,
33
+ });
34
+ return false;
35
+ };
@@ -1,5 +1,5 @@
1
- export function $is_email(str: string): boolean {
2
- return REGEX.test(str);
3
- }
4
- const REGEX =
5
- /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
1
+ export function $is_email(str: string): boolean {
2
+ return REGEX.test(str);
3
+ }
4
+ const REGEX =
5
+ /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
@@ -1,5 +1,5 @@
1
- export function $is_ipv4(str: string): boolean {
2
- return REGEX.test(str);
3
- }
4
- const REGEX =
5
- /^(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
1
+ export function $is_ipv4(str: string): boolean {
2
+ return REGEX.test(str);
3
+ }
4
+ const REGEX =
5
+ /^(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
@@ -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,5 @@
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 =
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,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,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
+ }
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
+ }
@@ -1,6 +1,6 @@
1
- import { IMetadata } from "./IMetadata";
2
-
3
- export interface IMetadataEntry {
4
- key: IMetadata;
5
- value: IMetadata;
6
- }
1
+ import { IMetadata } from "./IMetadata";
2
+
3
+ export interface IMetadataEntry {
4
+ key: IMetadata;
5
+ value: IMetadata;
6
+ }
@@ -1,29 +1,29 @@
1
- import { IJsDocTagInfo } from "./IJsDocTagInfo";
2
- import { IMetadataProperty } from "./IMetadataProperty";
3
-
4
- export interface IMetadataObject {
5
- name: string;
6
- properties: IMetadataProperty[];
7
- description?: string;
8
- jsDocTags: IJsDocTagInfo[];
9
-
10
- /**
11
- * @internal
12
- */
13
- index: number;
14
-
15
- /**
16
- * @internal
17
- */
18
- validated: boolean;
19
-
20
- /**
21
- * @internal
22
- */
23
- recursive: boolean;
24
-
25
- /**
26
- * @internal
27
- */
28
- nullables: boolean[];
29
- }
1
+ import { IJsDocTagInfo } from "./IJsDocTagInfo";
2
+ import { IMetadataProperty } from "./IMetadataProperty";
3
+
4
+ export interface IMetadataObject {
5
+ name: string;
6
+ properties: IMetadataProperty[];
7
+ description?: string;
8
+ jsDocTags: IJsDocTagInfo[];
9
+
10
+ /**
11
+ * @internal
12
+ */
13
+ index: number;
14
+
15
+ /**
16
+ * @internal
17
+ */
18
+ validated: boolean;
19
+
20
+ /**
21
+ * @internal
22
+ */
23
+ recursive: boolean;
24
+
25
+ /**
26
+ * @internal
27
+ */
28
+ nullables: boolean[];
29
+ }
@@ -1,11 +1,11 @@
1
- import { IJsDocTagInfo } from "./IJsDocTagInfo";
2
- import { IMetadata } from "./IMetadata";
3
- import { IMetadataTag } from "./IMetadataTag";
4
-
5
- export interface IMetadataProperty {
6
- key: IMetadata;
7
- value: IMetadata;
8
- description?: string;
9
- tags: IMetadataTag[];
10
- jsDocTags: IJsDocTagInfo[];
11
- }
1
+ import { IJsDocTagInfo } from "./IJsDocTagInfo";
2
+ import { IMetadata } from "./IMetadata";
3
+ import { IMetadataTag } from "./IMetadataTag";
4
+
5
+ export interface IMetadataProperty {
6
+ key: IMetadata;
7
+ value: IMetadata;
8
+ description?: string;
9
+ tags: IMetadataTag[];
10
+ jsDocTags: IJsDocTagInfo[];
11
+ }