typia 3.6.10 → 3.7.0-dev.20230331

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