typia 3.7.3-dev.20230408 → 3.7.4-dev.20230410

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 (215) hide show
  1. package/README.md +5 -56
  2. package/package.json +8 -8
  3. package/src/CustomValidatorMap.ts +126 -126
  4. package/src/IRandomGenerator.ts +33 -33
  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 +152 -152
  10. package/src/executable/setup/ArgumentParser.ts +91 -91
  11. package/src/executable/setup/CommandExecutor.ts +8 -8
  12. package/src/executable/setup/FileRetriever.ts +33 -33
  13. package/src/executable/setup/PackageManager.ts +92 -92
  14. package/src/executable/setup/PluginConfigurator.ts +99 -99
  15. package/src/executable/typia.ts +38 -38
  16. package/src/factories/CommentFactory.ts +10 -10
  17. package/src/factories/ExpressionFactory.ts +77 -77
  18. package/src/factories/IdentifierFactory.ts +81 -81
  19. package/src/factories/LiteralFactory.ts +44 -44
  20. package/src/factories/MetadataCollection.ts +122 -122
  21. package/src/factories/MetadataFactory.ts +51 -51
  22. package/src/factories/MetadataTagFactory.ts +302 -302
  23. package/src/factories/StatementFactory.ts +60 -60
  24. package/src/factories/TemplateFactory.ts +56 -56
  25. package/src/factories/TypeFactory.ts +129 -129
  26. package/src/factories/TypiaFileFactory.ts +120 -120
  27. package/src/factories/ValueFactory.ts +12 -12
  28. package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
  29. package/src/factories/internal/metadata/emplace_metadata_object.ts +142 -142
  30. package/src/factories/internal/metadata/explore_metadata.ts +92 -92
  31. package/src/factories/internal/metadata/iterate_metadata.ts +80 -80
  32. package/src/factories/internal/metadata/iterate_metadata_array.ts +29 -29
  33. package/src/factories/internal/metadata/iterate_metadata_atomic.ts +59 -59
  34. package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
  35. package/src/factories/internal/metadata/iterate_metadata_constant.ts +58 -58
  36. package/src/factories/internal/metadata/iterate_metadata_map.ts +41 -41
  37. package/src/factories/internal/metadata/iterate_metadata_native.ts +222 -222
  38. package/src/factories/internal/metadata/iterate_metadata_object.ts +48 -48
  39. package/src/factories/internal/metadata/iterate_metadata_resolve.ts +27 -27
  40. package/src/factories/internal/metadata/iterate_metadata_set.ts +33 -33
  41. package/src/factories/internal/metadata/iterate_metadata_template.ts +38 -38
  42. package/src/factories/internal/metadata/iterate_metadata_tuple.ts +45 -45
  43. package/src/factories/internal/metadata/iterate_metadata_union.ts +59 -59
  44. package/src/functional/$any.ts +3 -3
  45. package/src/functional/$dictionary.ts +20 -20
  46. package/src/functional/$every.ts +11 -11
  47. package/src/functional/$guard.ts +35 -35
  48. package/src/functional/$is_between.ts +7 -7
  49. package/src/functional/$is_custom.ts +14 -14
  50. package/src/functional/$is_date.ts +4 -4
  51. package/src/functional/$is_datetime.ts +3 -3
  52. package/src/functional/$is_email.ts +5 -5
  53. package/src/functional/$is_ipv4.ts +5 -5
  54. package/src/functional/$is_ipv6.ts +5 -5
  55. package/src/functional/$is_url.ts +5 -5
  56. package/src/functional/$is_uuid.ts +5 -5
  57. package/src/functional/$join.ts +50 -50
  58. package/src/functional/$number.ts +12 -12
  59. package/src/functional/$report.ts +15 -15
  60. package/src/functional/$rest.ts +3 -3
  61. package/src/functional/$string.ts +37 -37
  62. package/src/functional/$tail.ts +6 -6
  63. package/src/functional/Namespace.ts +127 -127
  64. package/src/index.ts +4 -4
  65. package/src/metadata/ICommentTag.ts +4 -4
  66. package/src/metadata/IJsDocTagInfo.ts +10 -10
  67. package/src/metadata/IMetadata.ts +25 -25
  68. package/src/metadata/IMetadataApplication.ts +7 -7
  69. package/src/metadata/IMetadataConstant.ts +16 -16
  70. package/src/metadata/IMetadataEntry.ts +6 -6
  71. package/src/metadata/IMetadataObject.ts +29 -29
  72. package/src/metadata/IMetadataProperty.ts +11 -11
  73. package/src/metadata/IMetadataTag.ts +105 -105
  74. package/src/metadata/Metadata.ts +534 -534
  75. package/src/metadata/MetadataConstant.ts +3 -3
  76. package/src/metadata/MetadataObject.ts +131 -131
  77. package/src/metadata/MetadataProperty.ts +64 -64
  78. package/src/module.ts +2043 -2043
  79. package/src/programmers/ApplicationProgrammer.ts +55 -55
  80. package/src/programmers/AssertCloneProgrammer.ts +70 -70
  81. package/src/programmers/AssertParseProgrammer.ts +65 -65
  82. package/src/programmers/AssertProgrammer.ts +284 -284
  83. package/src/programmers/AssertPruneProgrammer.ts +67 -67
  84. package/src/programmers/AssertStringifyProgrammer.ts +71 -71
  85. package/src/programmers/CheckerProgrammer.ts +922 -922
  86. package/src/programmers/CloneProgrammer.ts +388 -388
  87. package/src/programmers/FeatureProgrammer.ts +512 -512
  88. package/src/programmers/IsCloneProgrammer.ts +80 -80
  89. package/src/programmers/IsParseProgrammer.ts +74 -74
  90. package/src/programmers/IsProgrammer.ts +206 -206
  91. package/src/programmers/IsPruneProgrammer.ts +75 -75
  92. package/src/programmers/IsStringifyProgrammer.ts +81 -81
  93. package/src/programmers/LiteralsProgrammer.ts +65 -65
  94. package/src/programmers/PruneProgrammer.ts +343 -343
  95. package/src/programmers/RandomProgrammer.ts +413 -413
  96. package/src/programmers/StringifyProgrammer.ts +801 -801
  97. package/src/programmers/ValidateCloneProgrammer.ts +90 -90
  98. package/src/programmers/ValidateParseProgrammer.ts +69 -69
  99. package/src/programmers/ValidateProgrammer.ts +317 -317
  100. package/src/programmers/ValidatePruneProgrammer.ts +83 -83
  101. package/src/programmers/ValidateStringifyProgrammer.ts +89 -89
  102. package/src/programmers/helpers/AtomicPredicator.ts +31 -31
  103. package/src/programmers/helpers/CloneJoiner.ts +134 -134
  104. package/src/programmers/helpers/FunctionImporeter.ts +55 -55
  105. package/src/programmers/helpers/ICheckEntry.ts +12 -12
  106. package/src/programmers/helpers/IExpressionEntry.ts +12 -12
  107. package/src/programmers/helpers/OptionPredicator.ts +19 -19
  108. package/src/programmers/helpers/PruneJoiner.ts +52 -52
  109. package/src/programmers/helpers/RandomJoiner.ts +161 -161
  110. package/src/programmers/helpers/RandomRanger.ts +216 -216
  111. package/src/programmers/helpers/StringifyJoinder.ts +114 -114
  112. package/src/programmers/helpers/StringifyPredicator.ts +18 -18
  113. package/src/programmers/helpers/UnionExplorer.ts +281 -281
  114. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  115. package/src/programmers/internal/application_array.ts +37 -37
  116. package/src/programmers/internal/application_boolean.ts +17 -17
  117. package/src/programmers/internal/application_constant.ts +29 -29
  118. package/src/programmers/internal/application_default.ts +17 -17
  119. package/src/programmers/internal/application_default_string.ts +32 -32
  120. package/src/programmers/internal/application_native.ts +32 -32
  121. package/src/programmers/internal/application_number.ts +73 -73
  122. package/src/programmers/internal/application_object.ts +153 -153
  123. package/src/programmers/internal/application_schema.ts +184 -184
  124. package/src/programmers/internal/application_string.ts +45 -45
  125. package/src/programmers/internal/application_templates.ts +27 -27
  126. package/src/programmers/internal/application_tuple.ts +29 -29
  127. package/src/programmers/internal/check_array.ts +30 -30
  128. package/src/programmers/internal/check_array_length.ts +35 -35
  129. package/src/programmers/internal/check_bigint.ts +82 -82
  130. package/src/programmers/internal/check_custom.ts +33 -33
  131. package/src/programmers/internal/check_dynamic_properties.ts +197 -197
  132. package/src/programmers/internal/check_everything.ts +28 -28
  133. package/src/programmers/internal/check_native.ts +21 -21
  134. package/src/programmers/internal/check_number.ts +177 -177
  135. package/src/programmers/internal/check_object.ts +55 -55
  136. package/src/programmers/internal/check_string.ts +25 -25
  137. package/src/programmers/internal/check_string_tags.ts +73 -73
  138. package/src/programmers/internal/check_template.ts +59 -59
  139. package/src/programmers/internal/check_union_array_like.ts +272 -272
  140. package/src/programmers/internal/check_union_tuple.ts +35 -35
  141. package/src/programmers/internal/decode_union_object.ts +73 -73
  142. package/src/programmers/internal/feature_object_entries.ts +63 -63
  143. package/src/programmers/internal/get_comment_tags.ts +23 -23
  144. package/src/programmers/internal/metadata_to_pattern.ts +34 -34
  145. package/src/programmers/internal/prune_object_properties.ts +60 -60
  146. package/src/programmers/internal/random_custom.ts +30 -30
  147. package/src/programmers/internal/stringify_dynamic_properties.ts +168 -168
  148. package/src/programmers/internal/stringify_native.ts +8 -8
  149. package/src/programmers/internal/stringify_regular_properties.ts +84 -84
  150. package/src/programmers/internal/template_to_pattern.ts +15 -15
  151. package/src/schemas/IJsonApplication.ts +9 -9
  152. package/src/schemas/IJsonComponents.ts +26 -26
  153. package/src/schemas/IJsonSchema.ts +121 -121
  154. package/src/transform.ts +21 -21
  155. package/src/transformers/CallExpressionTransformer.ts +174 -174
  156. package/src/transformers/ExpressionWithArgumentTransformer.ts +66 -66
  157. package/src/transformers/FileTransformer.ts +49 -49
  158. package/src/transformers/IProject.ts +11 -11
  159. package/src/transformers/ITransformOptions.ts +62 -62
  160. package/src/transformers/ImportTransformer.ts +66 -66
  161. package/src/transformers/NodeTransformer.ts +19 -19
  162. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +119 -119
  163. package/src/transformers/features/miscellaneous/AssertCloneTransformer.ts +9 -9
  164. package/src/transformers/features/miscellaneous/AssertPruneTransformer.ts +9 -9
  165. package/src/transformers/features/miscellaneous/CloneTransformer.ts +9 -9
  166. package/src/transformers/features/miscellaneous/CreateAssertCloneTransformer.ts +9 -9
  167. package/src/transformers/features/miscellaneous/CreateAssertPruneTransformer.ts +9 -9
  168. package/src/transformers/features/miscellaneous/CreateCloneTransformer.ts +9 -9
  169. package/src/transformers/features/miscellaneous/CreateIsCloneTransformer.ts +9 -9
  170. package/src/transformers/features/miscellaneous/CreateIsPruneTransformer.ts +9 -9
  171. package/src/transformers/features/miscellaneous/CreatePruneTransformer.ts +9 -9
  172. package/src/transformers/features/miscellaneous/CreateRandomTransformer.ts +41 -41
  173. package/src/transformers/features/miscellaneous/CreateValidateCloneTransformer.ts +9 -9
  174. package/src/transformers/features/miscellaneous/CreateValidatePruneTransformer.ts +9 -9
  175. package/src/transformers/features/miscellaneous/IsCloneTransformer.ts +9 -9
  176. package/src/transformers/features/miscellaneous/IsPruneTransformer.ts +9 -9
  177. package/src/transformers/features/miscellaneous/LiteralsTransformer.ts +30 -30
  178. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +54 -54
  179. package/src/transformers/features/miscellaneous/PruneTransformer.ts +9 -9
  180. package/src/transformers/features/miscellaneous/RandomTransformer.ts +46 -46
  181. package/src/transformers/features/miscellaneous/ValidateCloneTransformer.ts +9 -9
  182. package/src/transformers/features/miscellaneous/ValidatePruneTransformer.ts +9 -9
  183. package/src/transformers/features/parsers/AssertParseTransformer.ts +9 -9
  184. package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +9 -9
  185. package/src/transformers/features/parsers/CreateIsParseTransformer.ts +9 -9
  186. package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +9 -9
  187. package/src/transformers/features/parsers/IsParseTransformer.ts +9 -9
  188. package/src/transformers/features/parsers/ValidateParseTransformer.ts +9 -9
  189. package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +10 -10
  190. package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +9 -9
  191. package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +9 -9
  192. package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +9 -9
  193. package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +11 -11
  194. package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +9 -9
  195. package/src/transformers/features/stringifiers/StringifyTransformer.ts +9 -9
  196. package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +10 -10
  197. package/src/transformers/features/validators/AssertTransformer.ts +11 -11
  198. package/src/transformers/features/validators/CreateAssertTransformer.ts +12 -12
  199. package/src/transformers/features/validators/CreateIsTransformer.ts +10 -10
  200. package/src/transformers/features/validators/CreateValidateTransformer.ts +12 -12
  201. package/src/transformers/features/validators/IsTransformer.ts +10 -10
  202. package/src/transformers/features/validators/ValidateTransformer.ts +11 -11
  203. package/src/transformers/internal/GenericTransformer.ts +99 -99
  204. package/src/typings/Atomic.ts +17 -17
  205. package/src/typings/ClassProperties.ts +5 -5
  206. package/src/typings/Customizable.ts +5 -5
  207. package/src/typings/OmitNever.ts +3 -3
  208. package/src/typings/SpecialFields.ts +3 -3
  209. package/src/typings/Writable.ts +11 -11
  210. package/src/utils/ArrayUtil.ts +49 -49
  211. package/src/utils/Escaper.ts +50 -50
  212. package/src/utils/MapUtil.ts +14 -14
  213. package/src/utils/PatternUtil.ts +30 -30
  214. package/src/utils/RandomGenerator.ts +96 -96
  215. package/src/utils/Singleton.ts +17 -17
@@ -1,7 +1,7 @@
1
- export function $is_between(
2
- value: number,
3
- minimum: number,
4
- maximum: number,
5
- ): boolean {
6
- return minimum <= value && value <= maximum;
7
- }
1
+ export function $is_between(
2
+ value: number,
3
+ minimum: number,
4
+ maximum: number,
5
+ ): boolean {
6
+ return minimum <= value && value <= maximum;
7
+ }
@@ -1,14 +1,14 @@
1
- import { Customizable } from "../typings/Customizable";
2
-
3
- import { $dictionary } from "./$dictionary";
4
-
5
- export function $is_custom<Type extends keyof Customizable>(
6
- name: string,
7
- type: Type,
8
- text: string,
9
- value: Customizable[Type],
10
- ): boolean {
11
- const validator = $dictionary.get(name)?.get(type);
12
- if (validator === undefined) return true;
13
- return validator(text)(value);
14
- }
1
+ import { Customizable } from "../typings/Customizable";
2
+
3
+ import { $dictionary } from "./$dictionary";
4
+
5
+ export function $is_custom<Type extends keyof Customizable>(
6
+ name: string,
7
+ type: Type,
8
+ text: string,
9
+ value: Customizable[Type],
10
+ ): boolean {
11
+ const validator = $dictionary.get(name)?.get(type);
12
+ if (validator === undefined) return true;
13
+ return validator(text)(value);
14
+ }
@@ -1,4 +1,4 @@
1
- export function $is_date(value: string): boolean {
2
- return REGEX.test(value);
3
- }
4
- const REGEX = /^(\d{4})-(\d{2})-(\d{2})$/;
1
+ export function $is_date(value: string): boolean {
2
+ return REGEX.test(value);
3
+ }
4
+ const REGEX = /^(\d{4})-(\d{2})-(\d{2})$/;
@@ -1,3 +1,3 @@
1
- export function $is_datetime(value: string): boolean {
2
- return !isNaN(new Date(value).getTime());
3
- }
1
+ export function $is_datetime(value: string): boolean {
2
+ return !isNaN(new Date(value).getTime());
3
+ }
@@ -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}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/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}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/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,127 +1,127 @@
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_custom } from "./$is_custom";
10
- import { $is_date } from "./$is_date";
11
- import { $is_datetime } from "./$is_datetime";
12
- import { $is_email } from "./$is_email";
13
- import { $is_ipv4 } from "./$is_ipv4";
14
- import { $is_ipv6 } from "./$is_ipv6";
15
- import { $is_url } from "./$is_url";
16
- import { $is_uuid } from "./$is_uuid";
17
- import { $join } from "./$join";
18
- import { $number } from "./$number";
19
- import { $report } from "./$report";
20
- import { $rest } from "./$rest";
21
- import { $string } from "./$string";
22
- import { $tail } from "./$tail";
23
-
24
- /**
25
- * @internal
26
- */
27
- export namespace Namespace {
28
- export const is = () => ({
29
- is_uuid: $is_uuid,
30
- is_email: $is_email,
31
- is_url: $is_url,
32
- is_ipv4: $is_ipv4,
33
- is_ipv6: $is_ipv6,
34
- is_between: $is_between,
35
- is_date: $is_date,
36
- is_datetime: $is_datetime,
37
- is_custom: $is_custom,
38
- });
39
-
40
- export const assert = (method: string) => ({
41
- ...is(),
42
- join: $join,
43
- every: $every,
44
- guard: $guard(`typia.${method}`),
45
- predicate: (
46
- matched: boolean,
47
- exceptionable: boolean,
48
- closure: () => Omit<TypeGuardError.IProps, "method">,
49
- ): boolean => {
50
- if (matched === false && exceptionable === true)
51
- throw new TypeGuardError({
52
- ...closure(),
53
- method: `typia.${method}`,
54
- });
55
- return matched;
56
- },
57
- });
58
-
59
- export const validate = () => ({
60
- ...is(),
61
- join: $join,
62
- report: $report,
63
- predicate:
64
- (res: IValidation) =>
65
- (
66
- matched: boolean,
67
- exceptionable: boolean,
68
- closure: () => IValidation.IError,
69
- ) => {
70
- // CHECK FAILURE
71
- if (matched === false && exceptionable === true)
72
- (() => {
73
- res.success &&= false;
74
- const errorList = (res as IValidation.IFailure).errors;
75
-
76
- // TRACE ERROR
77
- const error = closure();
78
- if (errorList.length) {
79
- const last = errorList[errorList.length - 1]!.path;
80
- if (
81
- last.length >= error.path.length &&
82
- last.substring(0, error.path.length) ===
83
- error.path
84
- )
85
- return;
86
- }
87
- errorList.push(error);
88
- return;
89
- })();
90
- return matched;
91
- },
92
- });
93
-
94
- export const stringify = (method: string) => ({
95
- ...is(),
96
- number: $number,
97
- string: $string,
98
- tail: $tail,
99
- rest: $rest,
100
- throws: $throws(method),
101
- });
102
-
103
- export const clone = (method: string) => ({
104
- ...is(),
105
- throws: $throws(method),
106
- any: $any,
107
- });
108
-
109
- export const prune = (method: string) => ({
110
- ...is(),
111
- throws: $throws(method),
112
- });
113
-
114
- export const random = () => ({
115
- generator: RandomGenerator,
116
- pick: RandomGenerator.pick,
117
- });
118
-
119
- const $throws =
120
- (method: string) =>
121
- (props: Pick<TypeGuardError.IProps, "expected" | "value">) => {
122
- throw new TypeGuardError({
123
- ...props,
124
- method: `typia.${method}`,
125
- });
126
- };
127
- }
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_custom } from "./$is_custom";
10
+ import { $is_date } from "./$is_date";
11
+ import { $is_datetime } from "./$is_datetime";
12
+ import { $is_email } from "./$is_email";
13
+ import { $is_ipv4 } from "./$is_ipv4";
14
+ import { $is_ipv6 } from "./$is_ipv6";
15
+ import { $is_url } from "./$is_url";
16
+ import { $is_uuid } from "./$is_uuid";
17
+ import { $join } from "./$join";
18
+ import { $number } from "./$number";
19
+ import { $report } from "./$report";
20
+ import { $rest } from "./$rest";
21
+ import { $string } from "./$string";
22
+ import { $tail } from "./$tail";
23
+
24
+ /**
25
+ * @internal
26
+ */
27
+ export namespace Namespace {
28
+ export const is = () => ({
29
+ is_uuid: $is_uuid,
30
+ is_email: $is_email,
31
+ is_url: $is_url,
32
+ is_ipv4: $is_ipv4,
33
+ is_ipv6: $is_ipv6,
34
+ is_between: $is_between,
35
+ is_date: $is_date,
36
+ is_datetime: $is_datetime,
37
+ is_custom: $is_custom,
38
+ });
39
+
40
+ export const assert = (method: string) => ({
41
+ ...is(),
42
+ join: $join,
43
+ every: $every,
44
+ guard: $guard(`typia.${method}`),
45
+ predicate: (
46
+ matched: boolean,
47
+ exceptionable: boolean,
48
+ closure: () => Omit<TypeGuardError.IProps, "method">,
49
+ ): boolean => {
50
+ if (matched === false && exceptionable === true)
51
+ throw new TypeGuardError({
52
+ ...closure(),
53
+ method: `typia.${method}`,
54
+ });
55
+ return matched;
56
+ },
57
+ });
58
+
59
+ export const validate = () => ({
60
+ ...is(),
61
+ join: $join,
62
+ report: $report,
63
+ predicate:
64
+ (res: IValidation) =>
65
+ (
66
+ matched: boolean,
67
+ exceptionable: boolean,
68
+ closure: () => IValidation.IError,
69
+ ) => {
70
+ // CHECK FAILURE
71
+ if (matched === false && exceptionable === true)
72
+ (() => {
73
+ res.success &&= false;
74
+ const errorList = (res as IValidation.IFailure).errors;
75
+
76
+ // TRACE ERROR
77
+ const error = closure();
78
+ if (errorList.length) {
79
+ const last = errorList[errorList.length - 1]!.path;
80
+ if (
81
+ last.length >= error.path.length &&
82
+ last.substring(0, error.path.length) ===
83
+ error.path
84
+ )
85
+ return;
86
+ }
87
+ errorList.push(error);
88
+ return;
89
+ })();
90
+ return matched;
91
+ },
92
+ });
93
+
94
+ export const stringify = (method: string) => ({
95
+ ...is(),
96
+ number: $number,
97
+ string: $string,
98
+ tail: $tail,
99
+ rest: $rest,
100
+ throws: $throws(method),
101
+ });
102
+
103
+ export const clone = (method: string) => ({
104
+ ...is(),
105
+ throws: $throws(method),
106
+ any: $any,
107
+ });
108
+
109
+ export const prune = (method: string) => ({
110
+ ...is(),
111
+ throws: $throws(method),
112
+ });
113
+
114
+ export const random = () => ({
115
+ generator: RandomGenerator,
116
+ pick: RandomGenerator.pick,
117
+ });
118
+
119
+ const $throws =
120
+ (method: string) =>
121
+ (props: Pick<TypeGuardError.IProps, "expected" | "value">) => {
122
+ throw new TypeGuardError({
123
+ ...props,
124
+ method: `typia.${method}`,
125
+ });
126
+ };
127
+ }
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,4 +1,4 @@
1
- export interface ICommentTag {
2
- name: string;
3
- value?: string;
4
- }
1
+ export interface ICommentTag {
2
+ name: string;
3
+ value?: string;
4
+ }