@duplojs/utils 1.0.7 → 1.1.7

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 (294) hide show
  1. package/dist/array/coalescing.cjs +9 -0
  2. package/dist/array/coalescing.d.ts +3 -0
  3. package/dist/array/coalescing.mjs +7 -0
  4. package/dist/array/index.cjs +2 -0
  5. package/dist/array/index.d.ts +1 -0
  6. package/dist/array/index.mjs +1 -0
  7. package/dist/array/map.cjs +1 -1
  8. package/dist/array/map.d.ts +2 -2
  9. package/dist/array/map.mjs +1 -1
  10. package/dist/array/reduce.cjs +1 -1
  11. package/dist/array/reduce.mjs +1 -1
  12. package/dist/array/types/ArrayCoalescing.d.ts +1 -0
  13. package/dist/array/types/index.d.ts +1 -0
  14. package/dist/common/escapeRegExp.cjs +2 -2
  15. package/dist/common/escapeRegExp.d.ts +1 -1
  16. package/dist/common/escapeRegExp.mjs +2 -2
  17. package/dist/common/index.d.ts +2 -0
  18. package/dist/common/instanceOf.cjs +20 -0
  19. package/dist/common/instanceOf.d.ts +3 -0
  20. package/dist/common/instanceOf.mjs +18 -0
  21. package/dist/common/kind.cjs +38 -1
  22. package/dist/common/kind.d.ts +21 -3
  23. package/dist/common/kind.mjs +38 -2
  24. package/dist/common/memo.cjs +16 -0
  25. package/dist/common/memo.d.ts +5 -0
  26. package/dist/common/memo.mjs +14 -0
  27. package/dist/common/simpleClone.cjs +2 -2
  28. package/dist/common/simpleClone.mjs +2 -2
  29. package/dist/common/types/anyConstructor.d.ts +1 -0
  30. package/dist/common/types/anyPredicate.d.ts +1 -0
  31. package/dist/common/types/index.d.ts +2 -0
  32. package/dist/common/types/objectEntry.d.ts +1 -1
  33. package/dist/common/types/predicate.d.ts +1 -0
  34. package/dist/common/types/unionContain.d.ts +1 -1
  35. package/dist/dataParser/base.cjs +116 -0
  36. package/dist/dataParser/base.d.ts +44 -0
  37. package/dist/dataParser/base.mjs +109 -0
  38. package/dist/dataParser/baseExtended.cjs +55 -0
  39. package/dist/dataParser/baseExtended.d.ts +45 -0
  40. package/dist/dataParser/baseExtended.mjs +52 -0
  41. package/dist/dataParser/error.cjs +54 -0
  42. package/dist/dataParser/error.d.ts +31 -0
  43. package/dist/dataParser/error.mjs +41 -0
  44. package/dist/dataParser/extended/array.cjs +20 -0
  45. package/dist/dataParser/extended/array.d.ts +21 -0
  46. package/dist/dataParser/extended/array.mjs +18 -0
  47. package/dist/dataParser/extended/bigint.cjs +20 -0
  48. package/dist/dataParser/extended/bigint.d.ts +19 -0
  49. package/dist/dataParser/extended/bigint.mjs +18 -0
  50. package/dist/dataParser/extended/boolean.cjs +11 -0
  51. package/dist/dataParser/extended/boolean.d.ts +9 -0
  52. package/dist/dataParser/extended/boolean.mjs +9 -0
  53. package/dist/dataParser/extended/coerce/bigint.cjs +13 -0
  54. package/dist/dataParser/extended/coerce/bigint.d.ts +7 -0
  55. package/dist/dataParser/extended/coerce/bigint.mjs +11 -0
  56. package/dist/dataParser/extended/coerce/boolean.cjs +13 -0
  57. package/dist/dataParser/extended/coerce/boolean.d.ts +7 -0
  58. package/dist/dataParser/extended/coerce/boolean.mjs +11 -0
  59. package/dist/dataParser/extended/coerce/empty.cjs +13 -0
  60. package/dist/dataParser/extended/coerce/empty.d.ts +7 -0
  61. package/dist/dataParser/extended/coerce/empty.mjs +11 -0
  62. package/dist/dataParser/extended/coerce/index.cjs +17 -0
  63. package/dist/dataParser/extended/coerce/index.d.ts +6 -0
  64. package/dist/dataParser/extended/coerce/index.mjs +6 -0
  65. package/dist/dataParser/extended/coerce/nil.cjs +13 -0
  66. package/dist/dataParser/extended/coerce/nil.d.ts +7 -0
  67. package/dist/dataParser/extended/coerce/nil.mjs +11 -0
  68. package/dist/dataParser/extended/coerce/number.cjs +13 -0
  69. package/dist/dataParser/extended/coerce/number.d.ts +7 -0
  70. package/dist/dataParser/extended/coerce/number.mjs +11 -0
  71. package/dist/dataParser/extended/coerce/string.cjs +13 -0
  72. package/dist/dataParser/extended/coerce/string.d.ts +7 -0
  73. package/dist/dataParser/extended/coerce/string.mjs +11 -0
  74. package/dist/dataParser/extended/empty.cjs +11 -0
  75. package/dist/dataParser/extended/empty.d.ts +9 -0
  76. package/dist/dataParser/extended/empty.mjs +9 -0
  77. package/dist/dataParser/extended/index.cjs +48 -0
  78. package/dist/dataParser/extended/index.d.ts +22 -0
  79. package/dist/dataParser/extended/index.mjs +21 -0
  80. package/dist/dataParser/extended/lazy.cjs +11 -0
  81. package/dist/dataParser/extended/lazy.d.ts +11 -0
  82. package/dist/dataParser/extended/lazy.mjs +9 -0
  83. package/dist/dataParser/extended/literal.cjs +11 -0
  84. package/dist/dataParser/extended/literal.d.ts +11 -0
  85. package/dist/dataParser/extended/literal.mjs +9 -0
  86. package/dist/dataParser/extended/nil.cjs +11 -0
  87. package/dist/dataParser/extended/nil.d.ts +9 -0
  88. package/dist/dataParser/extended/nil.mjs +9 -0
  89. package/dist/dataParser/extended/nullable.cjs +11 -0
  90. package/dist/dataParser/extended/nullable.d.ts +11 -0
  91. package/dist/dataParser/extended/nullable.mjs +9 -0
  92. package/dist/dataParser/extended/number.cjs +27 -0
  93. package/dist/dataParser/extended/number.d.ts +24 -0
  94. package/dist/dataParser/extended/number.mjs +24 -0
  95. package/dist/dataParser/extended/object.cjs +11 -0
  96. package/dist/dataParser/extended/object.d.ts +11 -0
  97. package/dist/dataParser/extended/object.mjs +9 -0
  98. package/dist/dataParser/extended/optional.cjs +11 -0
  99. package/dist/dataParser/extended/optional.d.ts +11 -0
  100. package/dist/dataParser/extended/optional.mjs +9 -0
  101. package/dist/dataParser/extended/pipe.cjs +11 -0
  102. package/dist/dataParser/extended/pipe.d.ts +12 -0
  103. package/dist/dataParser/extended/pipe.mjs +9 -0
  104. package/dist/dataParser/extended/record.cjs +11 -0
  105. package/dist/dataParser/extended/record.d.ts +12 -0
  106. package/dist/dataParser/extended/record.mjs +9 -0
  107. package/dist/dataParser/extended/string.cjs +38 -0
  108. package/dist/dataParser/extended/string.d.ts +32 -0
  109. package/dist/dataParser/extended/string.mjs +34 -0
  110. package/dist/dataParser/extended/templateLiteral.cjs +10 -0
  111. package/dist/dataParser/extended/templateLiteral.d.ts +11 -0
  112. package/dist/dataParser/extended/templateLiteral.mjs +8 -0
  113. package/dist/dataParser/extended/transform.cjs +11 -0
  114. package/dist/dataParser/extended/transform.d.ts +14 -0
  115. package/dist/dataParser/extended/transform.mjs +9 -0
  116. package/dist/dataParser/extended/tuple.cjs +11 -0
  117. package/dist/dataParser/extended/tuple.d.ts +11 -0
  118. package/dist/dataParser/extended/tuple.mjs +9 -0
  119. package/dist/dataParser/extended/union.cjs +11 -0
  120. package/dist/dataParser/extended/union.d.ts +11 -0
  121. package/dist/dataParser/extended/union.mjs +9 -0
  122. package/dist/dataParser/extended/unknown.cjs +11 -0
  123. package/dist/dataParser/extended/unknown.d.ts +9 -0
  124. package/dist/dataParser/extended/unknown.mjs +9 -0
  125. package/dist/dataParser/index.cjs +128 -0
  126. package/dist/dataParser/index.d.ts +6 -0
  127. package/dist/dataParser/index.mjs +38 -0
  128. package/dist/dataParser/parsers/array/checkers/index.d.ts +2 -0
  129. package/dist/dataParser/parsers/array/checkers/max.cjs +23 -0
  130. package/dist/dataParser/parsers/array/checkers/max.d.ts +11 -0
  131. package/dist/dataParser/parsers/array/checkers/max.mjs +20 -0
  132. package/dist/dataParser/parsers/array/checkers/min.cjs +23 -0
  133. package/dist/dataParser/parsers/array/checkers/min.d.ts +11 -0
  134. package/dist/dataParser/parsers/array/checkers/min.mjs +20 -0
  135. package/dist/dataParser/parsers/array/index.cjs +64 -0
  136. package/dist/dataParser/parsers/array/index.d.ts +20 -0
  137. package/dist/dataParser/parsers/array/index.mjs +61 -0
  138. package/dist/dataParser/parsers/bigint/checkers/index.d.ts +2 -0
  139. package/dist/dataParser/parsers/bigint/checkers/max.cjs +23 -0
  140. package/dist/dataParser/parsers/bigint/checkers/max.d.ts +11 -0
  141. package/dist/dataParser/parsers/bigint/checkers/max.mjs +20 -0
  142. package/dist/dataParser/parsers/bigint/checkers/min.cjs +23 -0
  143. package/dist/dataParser/parsers/bigint/checkers/min.d.ts +11 -0
  144. package/dist/dataParser/parsers/bigint/checkers/min.mjs +20 -0
  145. package/dist/dataParser/parsers/bigint/index.cjs +31 -0
  146. package/dist/dataParser/parsers/bigint/index.d.ts +18 -0
  147. package/dist/dataParser/parsers/bigint/index.mjs +28 -0
  148. package/dist/dataParser/parsers/boolean.cjs +40 -0
  149. package/dist/dataParser/parsers/boolean.d.ts +12 -0
  150. package/dist/dataParser/parsers/boolean.mjs +37 -0
  151. package/dist/dataParser/parsers/coerce/bigint.cjs +13 -0
  152. package/dist/dataParser/parsers/coerce/bigint.d.ts +6 -0
  153. package/dist/dataParser/parsers/coerce/bigint.mjs +11 -0
  154. package/dist/dataParser/parsers/coerce/boolean.cjs +13 -0
  155. package/dist/dataParser/parsers/coerce/boolean.d.ts +6 -0
  156. package/dist/dataParser/parsers/coerce/boolean.mjs +11 -0
  157. package/dist/dataParser/parsers/coerce/empty.cjs +13 -0
  158. package/dist/dataParser/parsers/coerce/empty.d.ts +6 -0
  159. package/dist/dataParser/parsers/coerce/empty.mjs +11 -0
  160. package/dist/dataParser/parsers/coerce/index.cjs +17 -0
  161. package/dist/dataParser/parsers/coerce/index.d.ts +6 -0
  162. package/dist/dataParser/parsers/coerce/index.mjs +6 -0
  163. package/dist/dataParser/parsers/coerce/nil.cjs +13 -0
  164. package/dist/dataParser/parsers/coerce/nil.d.ts +6 -0
  165. package/dist/dataParser/parsers/coerce/nil.mjs +11 -0
  166. package/dist/dataParser/parsers/coerce/number.cjs +13 -0
  167. package/dist/dataParser/parsers/coerce/number.d.ts +6 -0
  168. package/dist/dataParser/parsers/coerce/number.mjs +11 -0
  169. package/dist/dataParser/parsers/coerce/string.cjs +13 -0
  170. package/dist/dataParser/parsers/coerce/string.d.ts +6 -0
  171. package/dist/dataParser/parsers/coerce/string.mjs +11 -0
  172. package/dist/dataParser/parsers/empty.cjs +27 -0
  173. package/dist/dataParser/parsers/empty.d.ts +12 -0
  174. package/dist/dataParser/parsers/empty.mjs +24 -0
  175. package/dist/dataParser/parsers/index.d.ts +20 -0
  176. package/dist/dataParser/parsers/lazy.cjs +21 -0
  177. package/dist/dataParser/parsers/lazy.d.ts +14 -0
  178. package/dist/dataParser/parsers/lazy.mjs +18 -0
  179. package/dist/dataParser/parsers/literal.cjs +25 -0
  180. package/dist/dataParser/parsers/literal.d.ts +15 -0
  181. package/dist/dataParser/parsers/literal.mjs +22 -0
  182. package/dist/dataParser/parsers/nil.cjs +27 -0
  183. package/dist/dataParser/parsers/nil.d.ts +12 -0
  184. package/dist/dataParser/parsers/nil.mjs +24 -0
  185. package/dist/dataParser/parsers/nullable.cjs +31 -0
  186. package/dist/dataParser/parsers/nullable.d.ts +14 -0
  187. package/dist/dataParser/parsers/nullable.mjs +28 -0
  188. package/dist/dataParser/parsers/number/checkers/index.d.ts +3 -0
  189. package/dist/dataParser/parsers/number/checkers/int.cjs +27 -0
  190. package/dist/dataParser/parsers/number/checkers/int.d.ts +15 -0
  191. package/dist/dataParser/parsers/number/checkers/int.mjs +23 -0
  192. package/dist/dataParser/parsers/number/checkers/max.cjs +18 -0
  193. package/dist/dataParser/parsers/number/checkers/max.d.ts +11 -0
  194. package/dist/dataParser/parsers/number/checkers/max.mjs +15 -0
  195. package/dist/dataParser/parsers/number/checkers/min.cjs +18 -0
  196. package/dist/dataParser/parsers/number/checkers/min.d.ts +11 -0
  197. package/dist/dataParser/parsers/number/checkers/min.mjs +15 -0
  198. package/dist/dataParser/parsers/number/index.cjs +31 -0
  199. package/dist/dataParser/parsers/number/index.d.ts +18 -0
  200. package/dist/dataParser/parsers/number/index.mjs +28 -0
  201. package/dist/dataParser/parsers/object.cjs +74 -0
  202. package/dist/dataParser/parsers/object.d.ts +26 -0
  203. package/dist/dataParser/parsers/object.mjs +71 -0
  204. package/dist/dataParser/parsers/optional.cjs +31 -0
  205. package/dist/dataParser/parsers/optional.d.ts +14 -0
  206. package/dist/dataParser/parsers/optional.mjs +28 -0
  207. package/dist/dataParser/parsers/pipe.cjs +34 -0
  208. package/dist/dataParser/parsers/pipe.d.ts +16 -0
  209. package/dist/dataParser/parsers/pipe.mjs +31 -0
  210. package/dist/dataParser/parsers/record.cjs +83 -0
  211. package/dist/dataParser/parsers/record.d.ts +30 -0
  212. package/dist/dataParser/parsers/record.mjs +80 -0
  213. package/dist/dataParser/parsers/string/checkers/email.cjs +31 -0
  214. package/dist/dataParser/parsers/string/checkers/email.d.ts +17 -0
  215. package/dist/dataParser/parsers/string/checkers/email.mjs +27 -0
  216. package/dist/dataParser/parsers/string/checkers/index.d.ts +5 -0
  217. package/dist/dataParser/parsers/string/checkers/max.cjs +18 -0
  218. package/dist/dataParser/parsers/string/checkers/max.d.ts +11 -0
  219. package/dist/dataParser/parsers/string/checkers/max.mjs +15 -0
  220. package/dist/dataParser/parsers/string/checkers/min.cjs +18 -0
  221. package/dist/dataParser/parsers/string/checkers/min.d.ts +11 -0
  222. package/dist/dataParser/parsers/string/checkers/min.mjs +15 -0
  223. package/dist/dataParser/parsers/string/checkers/regex.cjs +20 -0
  224. package/dist/dataParser/parsers/string/checkers/regex.d.ts +11 -0
  225. package/dist/dataParser/parsers/string/checkers/regex.mjs +17 -0
  226. package/dist/dataParser/parsers/string/checkers/url.cjs +48 -0
  227. package/dist/dataParser/parsers/string/checkers/url.d.ts +18 -0
  228. package/dist/dataParser/parsers/string/checkers/url.mjs +44 -0
  229. package/dist/dataParser/parsers/string/index.cjs +31 -0
  230. package/dist/dataParser/parsers/string/index.d.ts +18 -0
  231. package/dist/dataParser/parsers/string/index.mjs +28 -0
  232. package/dist/dataParser/parsers/templateLiteral.cjs +45 -0
  233. package/dist/dataParser/parsers/templateLiteral.d.ts +49 -0
  234. package/dist/dataParser/parsers/templateLiteral.mjs +42 -0
  235. package/dist/dataParser/parsers/transform.cjs +43 -0
  236. package/dist/dataParser/parsers/transform.d.ts +17 -0
  237. package/dist/dataParser/parsers/transform.mjs +40 -0
  238. package/dist/dataParser/parsers/tuple.cjs +83 -0
  239. package/dist/dataParser/parsers/tuple.d.ts +33 -0
  240. package/dist/dataParser/parsers/tuple.mjs +80 -0
  241. package/dist/dataParser/parsers/union.cjs +38 -0
  242. package/dist/dataParser/parsers/union.d.ts +15 -0
  243. package/dist/dataParser/parsers/union.mjs +35 -0
  244. package/dist/dataParser/parsers/unknown.cjs +17 -0
  245. package/dist/dataParser/parsers/unknown.d.ts +11 -0
  246. package/dist/dataParser/parsers/unknown.mjs +14 -0
  247. package/dist/dataParser/types/addCheckersToDefinition.d.ts +5 -0
  248. package/dist/dataParser/types/checkers.d.ts +3 -0
  249. package/dist/dataParser/types/dataParsers.d.ts +5 -0
  250. package/dist/dataParser/types/index.d.ts +4 -0
  251. package/dist/dataParser/types/mergeDefinition.d.ts +5 -0
  252. package/dist/either/bool/falsy.cjs +1 -1
  253. package/dist/either/bool/falsy.mjs +1 -1
  254. package/dist/either/bool/truthy.cjs +1 -1
  255. package/dist/either/bool/truthy.mjs +1 -1
  256. package/dist/either/future/error.cjs +1 -1
  257. package/dist/either/future/error.mjs +1 -1
  258. package/dist/either/future/success.cjs +1 -1
  259. package/dist/either/future/success.mjs +1 -1
  260. package/dist/either/left/create.cjs +1 -1
  261. package/dist/either/left/create.mjs +1 -1
  262. package/dist/either/left/error.cjs +1 -1
  263. package/dist/either/left/error.mjs +1 -1
  264. package/dist/either/left/fail.cjs +1 -1
  265. package/dist/either/left/fail.mjs +1 -1
  266. package/dist/either/nullable/empty.cjs +1 -1
  267. package/dist/either/nullable/empty.mjs +1 -1
  268. package/dist/either/nullable/filled.cjs +1 -1
  269. package/dist/either/nullable/filled.mjs +1 -1
  270. package/dist/either/nullish/empty.cjs +1 -1
  271. package/dist/either/nullish/empty.mjs +1 -1
  272. package/dist/either/nullish/filled.cjs +1 -1
  273. package/dist/either/nullish/filled.mjs +1 -1
  274. package/dist/either/optional/empty.cjs +1 -1
  275. package/dist/either/optional/empty.mjs +1 -1
  276. package/dist/either/optional/filled.cjs +1 -1
  277. package/dist/either/optional/filled.mjs +1 -1
  278. package/dist/either/right/asyncPipe.d.ts +2 -2
  279. package/dist/either/right/create.cjs +1 -1
  280. package/dist/either/right/create.mjs +1 -1
  281. package/dist/either/right/ok.cjs +1 -1
  282. package/dist/either/right/ok.mjs +1 -1
  283. package/dist/either/right/success.cjs +1 -1
  284. package/dist/either/right/success.mjs +1 -1
  285. package/dist/generator/reduce.cjs +1 -1
  286. package/dist/generator/reduce.mjs +1 -1
  287. package/dist/index.cjs +14 -0
  288. package/dist/index.d.ts +6 -0
  289. package/dist/index.mjs +12 -1
  290. package/dist/object/fromEntries.d.ts +1 -1
  291. package/dist/object/types/getPropsWithValueExtends.d.ts +1 -1
  292. package/dist/pattern/result.cjs +1 -1
  293. package/dist/pattern/result.mjs +1 -1
  294. package/package.json +57 -1
@@ -0,0 +1,28 @@
1
+ import { createKind } from '../../../common/kind.mjs';
2
+ import { dataParserInit } from '../../base.mjs';
3
+ import { SymbolDataParserErrorIssue } from '../../error.mjs';
4
+
5
+ const dataParserNumberKind = createKind("data-parser-number");
6
+ function number(definition) {
7
+ return dataParserInit(dataParserNumberKind, {
8
+ definition: {
9
+ errorMessage: definition?.errorMessage,
10
+ checkers: definition?.checkers ?? [],
11
+ coerce: definition?.coerce ?? false,
12
+ },
13
+ }, (data, _error, self) => {
14
+ if (self.definition.coerce) {
15
+ try {
16
+ // eslint-disable-next-line no-param-reassign
17
+ data = Number(data);
18
+ }
19
+ catch { }
20
+ }
21
+ if (typeof data === "number" && !Number.isNaN(data)) {
22
+ return data;
23
+ }
24
+ return SymbolDataParserErrorIssue;
25
+ });
26
+ }
27
+
28
+ export { dataParserNumberKind, number };
@@ -0,0 +1,74 @@
1
+ 'use strict';
2
+
3
+ var entries = require('../../object/entries.cjs');
4
+ var kind = require('../../common/kind.cjs');
5
+ var pipe = require('../../common/pipe.cjs');
6
+ var forward = require('../../common/forward.cjs');
7
+ var memo = require('../../common/memo.cjs');
8
+ var filter = require('../../array/filter.cjs');
9
+ var map = require('../../array/map.cjs');
10
+ var base = require('../base.cjs');
11
+ var error = require('../error.cjs');
12
+
13
+ const dataParserObjectKind = kind.createKind("data-parser-object");
14
+ function object(shape, definition) {
15
+ return base.dataParserInit(dataParserObjectKind, {
16
+ definition: {
17
+ shape,
18
+ errorMessage: definition?.errorMessage,
19
+ checkers: definition?.checkers ?? [],
20
+ optimizedShape: memo.memo(() => pipe.pipe(forward.forward(shape), entries.entries, filter.filter((entry) => base.dataParserKind.has(entry[1])), map.map(([key, value]) => ({
21
+ key,
22
+ value,
23
+ })))),
24
+ },
25
+ }, {
26
+ sync: (data, error$1, self) => {
27
+ if (!data
28
+ || typeof data !== "object"
29
+ || data instanceof Array) {
30
+ return error.SymbolDataParserErrorIssue;
31
+ }
32
+ let output = {};
33
+ const currentIndexPath = error$1.currentPath.length;
34
+ for (const entry of self.definition.optimizedShape.value) {
35
+ error.setErrorPath(error$1, entry.key, currentIndexPath);
36
+ const result = entry.value.exec(data[entry.key], error$1);
37
+ if (result === base.SymbolDataParserError) {
38
+ output = base.SymbolDataParserError;
39
+ }
40
+ else if (output !== base.SymbolDataParserError
41
+ && result !== undefined) {
42
+ output[entry.key] = result;
43
+ }
44
+ }
45
+ error.popErrorPath(error$1);
46
+ return output;
47
+ },
48
+ async: async (data, error$1, self) => {
49
+ if (!data
50
+ || typeof data !== "object"
51
+ || data instanceof Array) {
52
+ return error.SymbolDataParserErrorIssue;
53
+ }
54
+ let output = {};
55
+ const currentIndexPath = error$1.currentPath.length;
56
+ for (const entry of self.definition.optimizedShape.value) {
57
+ error.setErrorPath(error$1, entry.key, currentIndexPath);
58
+ const result = await entry.value.asyncExec(data[entry.key], error$1);
59
+ if (result === base.SymbolDataParserError) {
60
+ output = base.SymbolDataParserError;
61
+ }
62
+ else if (output !== base.SymbolDataParserError
63
+ && result !== undefined) {
64
+ output[entry.key] = result;
65
+ }
66
+ }
67
+ error.popErrorPath(error$1);
68
+ return output;
69
+ },
70
+ });
71
+ }
72
+
73
+ exports.dataParserObjectKind = dataParserObjectKind;
74
+ exports.object = object;
@@ -0,0 +1,26 @@
1
+ import { type Kind, type IsEqual, type NeverCoalescing, type Memoized } from "../../common";
2
+ import { dataParserKind, type Input, type Output, type DataParser, type DataParserDefinition } from "../base";
3
+ import { type MergeDefinition, type DataParsers } from "../types";
4
+ import * as DObject from "../../object";
5
+ export type DataParserObjectShape = Readonly<Record<string, DataParsers>>;
6
+ export type DataParserObjectShapeOutput<GenericShape extends DataParserObjectShape> = IsEqual<GenericShape, DataParserObjectShape> extends true ? DataParserObjectShape : {
7
+ -readonly [Prop in keyof GenericShape as GenericShape[Prop] extends Kind<typeof dataParserKind.definition> ? Prop : never]: Output<GenericShape[Prop]>;
8
+ } extends infer InferredResult extends object ? DObject.PartialKeys<InferredResult, DObject.GetPropsWithValueExtends<InferredResult, undefined>> : never;
9
+ export type DataParserObjectShapeInput<GenericShape extends DataParserObjectShape> = IsEqual<GenericShape, DataParserObjectShape> extends true ? DataParserObjectShape : {
10
+ -readonly [Prop in keyof GenericShape as GenericShape[Prop] extends Kind<typeof dataParserKind.definition> ? Prop : never]: Input<GenericShape[Prop]>;
11
+ } extends infer InferredResult extends object ? DObject.PartialKeys<InferredResult, DObject.GetPropsWithValueExtends<InferredResult, undefined>> : never;
12
+ export interface DataParserDefinitionObject extends DataParserDefinition<never> {
13
+ readonly shape: DataParserObjectShape;
14
+ readonly optimizedShape: Memoized<{
15
+ readonly key: string;
16
+ readonly value: DataParsers;
17
+ }[]>;
18
+ }
19
+ export declare const dataParserObjectKind: import("../../common").KindHandler<import("../../common").KindDefinition<"data-parser-object", unknown>>;
20
+ type _DataParserObject<GenericDefinition extends DataParserDefinitionObject> = (DataParser<GenericDefinition, DataParserObjectShapeOutput<GenericDefinition["shape"]>, DataParserObjectShapeInput<GenericDefinition["shape"]>> & Kind<typeof dataParserObjectKind.definition>);
21
+ export interface DataParserObject<GenericDefinition extends DataParserDefinitionObject = DataParserDefinitionObject> extends _DataParserObject<GenericDefinition> {
22
+ }
23
+ export declare function object<const GenericShape extends DataParserObjectShape, const GenericDefinition extends Partial<Omit<DataParserDefinitionObject, "shape">> = never>(shape: GenericShape, definition?: GenericDefinition): DataParserObject<MergeDefinition<DataParserDefinitionObject, NeverCoalescing<GenericDefinition, {}> & {
24
+ shape: GenericShape;
25
+ }>>;
26
+ export {};
@@ -0,0 +1,71 @@
1
+ import { entries } from '../../object/entries.mjs';
2
+ import { createKind } from '../../common/kind.mjs';
3
+ import { pipe } from '../../common/pipe.mjs';
4
+ import { forward } from '../../common/forward.mjs';
5
+ import { memo } from '../../common/memo.mjs';
6
+ import { filter } from '../../array/filter.mjs';
7
+ import { map } from '../../array/map.mjs';
8
+ import { dataParserInit, SymbolDataParserError, dataParserKind } from '../base.mjs';
9
+ import { SymbolDataParserErrorIssue, setErrorPath, popErrorPath } from '../error.mjs';
10
+
11
+ const dataParserObjectKind = createKind("data-parser-object");
12
+ function object(shape, definition) {
13
+ return dataParserInit(dataParserObjectKind, {
14
+ definition: {
15
+ shape,
16
+ errorMessage: definition?.errorMessage,
17
+ checkers: definition?.checkers ?? [],
18
+ optimizedShape: memo(() => pipe(forward(shape), entries, filter((entry) => dataParserKind.has(entry[1])), map(([key, value]) => ({
19
+ key,
20
+ value,
21
+ })))),
22
+ },
23
+ }, {
24
+ sync: (data, error, self) => {
25
+ if (!data
26
+ || typeof data !== "object"
27
+ || data instanceof Array) {
28
+ return SymbolDataParserErrorIssue;
29
+ }
30
+ let output = {};
31
+ const currentIndexPath = error.currentPath.length;
32
+ for (const entry of self.definition.optimizedShape.value) {
33
+ setErrorPath(error, entry.key, currentIndexPath);
34
+ const result = entry.value.exec(data[entry.key], error);
35
+ if (result === SymbolDataParserError) {
36
+ output = SymbolDataParserError;
37
+ }
38
+ else if (output !== SymbolDataParserError
39
+ && result !== undefined) {
40
+ output[entry.key] = result;
41
+ }
42
+ }
43
+ popErrorPath(error);
44
+ return output;
45
+ },
46
+ async: async (data, error, self) => {
47
+ if (!data
48
+ || typeof data !== "object"
49
+ || data instanceof Array) {
50
+ return SymbolDataParserErrorIssue;
51
+ }
52
+ let output = {};
53
+ const currentIndexPath = error.currentPath.length;
54
+ for (const entry of self.definition.optimizedShape.value) {
55
+ setErrorPath(error, entry.key, currentIndexPath);
56
+ const result = await entry.value.asyncExec(data[entry.key], error);
57
+ if (result === SymbolDataParserError) {
58
+ output = SymbolDataParserError;
59
+ }
60
+ else if (output !== SymbolDataParserError
61
+ && result !== undefined) {
62
+ output[entry.key] = result;
63
+ }
64
+ }
65
+ popErrorPath(error);
66
+ return output;
67
+ },
68
+ });
69
+ }
70
+
71
+ export { dataParserObjectKind, object };
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ var kind = require('../../common/kind.cjs');
4
+ var base = require('../base.cjs');
5
+
6
+ const dataParserOptionalKind = kind.createKind("data-parser-optional");
7
+ function optional(inner, definition) {
8
+ return base.dataParserInit(dataParserOptionalKind, {
9
+ definition: {
10
+ errorMessage: definition?.errorMessage,
11
+ checkers: definition?.checkers ?? [],
12
+ inner,
13
+ },
14
+ }, {
15
+ sync: (data, error, self) => {
16
+ if (data === undefined) {
17
+ return data;
18
+ }
19
+ return self.definition.inner.exec(data, error);
20
+ },
21
+ async: async (data, error, self) => {
22
+ if (data === undefined) {
23
+ return data;
24
+ }
25
+ return self.definition.inner.asyncExec(data, error);
26
+ },
27
+ });
28
+ }
29
+
30
+ exports.dataParserOptionalKind = dataParserOptionalKind;
31
+ exports.optional = optional;
@@ -0,0 +1,14 @@
1
+ import { type NeverCoalescing, type Kind } from "../../common";
2
+ import { type DataParserDefinition, type DataParser, type Output, type Input } from "../base";
3
+ import { type DataParsers, type MergeDefinition } from "../../dataParser/types";
4
+ export interface DataParserDefinitionOptional extends DataParserDefinition<never> {
5
+ readonly inner: DataParsers;
6
+ }
7
+ export declare const dataParserOptionalKind: import("../../common").KindHandler<import("../../common").KindDefinition<"data-parser-optional", unknown>>;
8
+ type _DataParserOptional<GenericDefinition extends DataParserDefinitionOptional> = (DataParser<GenericDefinition, Output<GenericDefinition["inner"]> | undefined, Input<GenericDefinition["inner"]> | undefined> & Kind<typeof dataParserOptionalKind.definition>);
9
+ export interface DataParserOptional<GenericDefinition extends DataParserDefinitionOptional = DataParserDefinitionOptional> extends _DataParserOptional<GenericDefinition> {
10
+ }
11
+ export declare function optional<GenericDataParser extends DataParsers, const GenericDefinition extends Partial<Omit<DataParserDefinitionOptional, "inner">> = never>(inner: GenericDataParser, definition?: GenericDefinition): DataParserOptional<MergeDefinition<DataParserDefinitionOptional, NeverCoalescing<GenericDefinition, {}> & {
12
+ inner: GenericDataParser;
13
+ }>>;
14
+ export {};
@@ -0,0 +1,28 @@
1
+ import { createKind } from '../../common/kind.mjs';
2
+ import { dataParserInit } from '../base.mjs';
3
+
4
+ const dataParserOptionalKind = createKind("data-parser-optional");
5
+ function optional(inner, definition) {
6
+ return dataParserInit(dataParserOptionalKind, {
7
+ definition: {
8
+ errorMessage: definition?.errorMessage,
9
+ checkers: definition?.checkers ?? [],
10
+ inner,
11
+ },
12
+ }, {
13
+ sync: (data, error, self) => {
14
+ if (data === undefined) {
15
+ return data;
16
+ }
17
+ return self.definition.inner.exec(data, error);
18
+ },
19
+ async: async (data, error, self) => {
20
+ if (data === undefined) {
21
+ return data;
22
+ }
23
+ return self.definition.inner.asyncExec(data, error);
24
+ },
25
+ });
26
+ }
27
+
28
+ export { dataParserOptionalKind, optional };
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ var kind = require('../../common/kind.cjs');
4
+ var base = require('../base.cjs');
5
+
6
+ const dataParserPipeKind = kind.createKind("data-parser-pipe");
7
+ function pipe(input, output, definition) {
8
+ return base.dataParserInit(dataParserPipeKind, {
9
+ definition: {
10
+ errorMessage: definition?.errorMessage,
11
+ checkers: definition?.checkers ?? [],
12
+ input,
13
+ output,
14
+ },
15
+ }, {
16
+ sync: (data, error, self) => {
17
+ const result = self.definition.input.exec(data, error);
18
+ if (result === base.SymbolDataParserError) {
19
+ return base.SymbolDataParserError;
20
+ }
21
+ return self.definition.output.exec(result, error);
22
+ },
23
+ async: async (data, error, self) => {
24
+ const result = await self.definition.input.asyncExec(data, error);
25
+ if (result === base.SymbolDataParserError) {
26
+ return base.SymbolDataParserError;
27
+ }
28
+ return self.definition.output.asyncExec(result, error);
29
+ },
30
+ });
31
+ }
32
+
33
+ exports.dataParserPipeKind = dataParserPipeKind;
34
+ exports.pipe = pipe;
@@ -0,0 +1,16 @@
1
+ import { type NeverCoalescing, type Kind } from "../../common";
2
+ import { type DataParserDefinition, type DataParser, type Output, type Input } from "../base";
3
+ import { type DataParsers, type MergeDefinition } from "../../dataParser/types";
4
+ export interface DataParserDefinitionPipe extends DataParserDefinition<never> {
5
+ readonly input: DataParsers;
6
+ readonly output: DataParsers;
7
+ }
8
+ export declare const dataParserPipeKind: import("../../common").KindHandler<import("../../common").KindDefinition<"data-parser-pipe", unknown>>;
9
+ type _DataParserPipe<GenericDefinition extends DataParserDefinitionPipe> = (DataParser<GenericDefinition, Output<GenericDefinition["output"]>, Input<GenericDefinition["input"]>> & Kind<typeof dataParserPipeKind.definition>);
10
+ export interface DataParserPipe<GenericDefinition extends DataParserDefinitionPipe = DataParserDefinitionPipe> extends _DataParserPipe<GenericDefinition> {
11
+ }
12
+ export declare function pipe<GenericInput extends DataParsers, GenericOutput extends DataParsers, const GenericDefinition extends Partial<Omit<DataParserDefinitionPipe, "input" | "output">> = never>(input: GenericInput, output: GenericOutput, definition?: GenericDefinition): DataParserPipe<MergeDefinition<DataParserDefinitionPipe, NeverCoalescing<GenericDefinition, {}> & {
13
+ input: GenericInput;
14
+ output: GenericOutput;
15
+ }>>;
16
+ export {};
@@ -0,0 +1,31 @@
1
+ import { createKind } from '../../common/kind.mjs';
2
+ import { dataParserInit, SymbolDataParserError } from '../base.mjs';
3
+
4
+ const dataParserPipeKind = createKind("data-parser-pipe");
5
+ function pipe(input, output, definition) {
6
+ return dataParserInit(dataParserPipeKind, {
7
+ definition: {
8
+ errorMessage: definition?.errorMessage,
9
+ checkers: definition?.checkers ?? [],
10
+ input,
11
+ output,
12
+ },
13
+ }, {
14
+ sync: (data, error, self) => {
15
+ const result = self.definition.input.exec(data, error);
16
+ if (result === SymbolDataParserError) {
17
+ return SymbolDataParserError;
18
+ }
19
+ return self.definition.output.exec(result, error);
20
+ },
21
+ async: async (data, error, self) => {
22
+ const result = await self.definition.input.asyncExec(data, error);
23
+ if (result === SymbolDataParserError) {
24
+ return SymbolDataParserError;
25
+ }
26
+ return self.definition.output.asyncExec(result, error);
27
+ },
28
+ });
29
+ }
30
+
31
+ export { dataParserPipeKind, pipe };
@@ -0,0 +1,83 @@
1
+ 'use strict';
2
+
3
+ var kind = require('../../common/kind.cjs');
4
+ var base = require('../base.cjs');
5
+ var error = require('../error.cjs');
6
+
7
+ const dataParserRecordKind = kind.createKind("data-parser-record");
8
+ function record(key, value, definition) {
9
+ return base.dataParserInit(dataParserRecordKind, {
10
+ definition: {
11
+ errorMessage: definition?.errorMessage,
12
+ checkers: definition?.checkers ?? [],
13
+ key,
14
+ value,
15
+ },
16
+ }, {
17
+ sync: (data, error$1, self) => {
18
+ if (!data
19
+ || typeof data !== "object"
20
+ || data instanceof Array) {
21
+ return error.SymbolDataParserErrorIssue;
22
+ }
23
+ let output = {};
24
+ const currentIndexPath = error$1.currentPath.length;
25
+ for (const key in data) {
26
+ error.setErrorPath(error$1, key, currentIndexPath);
27
+ const resultKey = self
28
+ .definition
29
+ .key
30
+ .exec(key, error$1);
31
+ if (resultKey === base.SymbolDataParserError) {
32
+ output = base.SymbolDataParserError;
33
+ }
34
+ const resultValue = self
35
+ .definition
36
+ .value
37
+ .exec(data[key], error$1);
38
+ if (resultValue === base.SymbolDataParserError) {
39
+ output = base.SymbolDataParserError;
40
+ }
41
+ if (output !== base.SymbolDataParserError) {
42
+ output[resultKey] = resultValue;
43
+ }
44
+ }
45
+ error.popErrorPath(error$1);
46
+ return output;
47
+ },
48
+ async: async (data, error$1, self) => {
49
+ if (!data
50
+ || typeof data !== "object"
51
+ || data instanceof Array) {
52
+ return error.SymbolDataParserErrorIssue;
53
+ }
54
+ let output = {};
55
+ const currentIndexPath = error$1.currentPath.length;
56
+ for (const key in data) {
57
+ error.setErrorPath(error$1, key, currentIndexPath);
58
+ const resultKey = await self
59
+ .definition
60
+ .key
61
+ .asyncExec(key, error$1);
62
+ if (resultKey === base.SymbolDataParserError) {
63
+ output = base.SymbolDataParserError;
64
+ }
65
+ const resultValue = await self
66
+ .definition
67
+ .value
68
+ .asyncExec(data[key], error$1);
69
+ if (resultValue === base.SymbolDataParserError) {
70
+ output = base.SymbolDataParserError;
71
+ }
72
+ if (output !== base.SymbolDataParserError) {
73
+ output[resultKey] = resultValue;
74
+ }
75
+ }
76
+ error.popErrorPath(error$1);
77
+ return output;
78
+ },
79
+ });
80
+ }
81
+
82
+ exports.dataParserRecordKind = dataParserRecordKind;
83
+ exports.record = record;
@@ -0,0 +1,30 @@
1
+ import { type NeverCoalescing, type Kind } from "../../common";
2
+ import { type DataParserDefinition, type DataParser, type Output, type Input } from "../base";
3
+ import { type DataParsers, type MergeDefinition } from "../../dataParser/types";
4
+ import { type DataParserString } from "./string";
5
+ import { type DataParserTemplateLiteral } from "./templateLiteral";
6
+ import { type DataParserDefinitionLiteral, type DataParserLiteral } from "./literal";
7
+ import { type DataParserDefinitionNumber, type DataParserNumber } from "./number";
8
+ import { type DataParserDefinitionUnion, type DataParserUnion } from "./union";
9
+ export type DataParserRecordKey = (DataParserString | DataParserTemplateLiteral | DataParserLiteral<DataParserDefinitionLiteral & {
10
+ value: string[];
11
+ }> | DataParserNumber<DataParserDefinitionNumber & {
12
+ coerce: true;
13
+ }> | DataParserUnion<DataParserDefinitionUnion & {
14
+ options: DataParserRecordKey[];
15
+ }>);
16
+ export interface DataParserDefinitionRecord extends DataParserDefinition<never> {
17
+ readonly key: DataParserRecordKey;
18
+ readonly value: DataParsers;
19
+ }
20
+ export declare const dataParserRecordKind: import("../../common").KindHandler<import("../../common").KindDefinition<"data-parser-record", unknown>>;
21
+ export type DataParserRecordShapeOutput<GenericDataParserKey extends DataParserRecordKey, GenericDataParserValue extends DataParsers> = Extract<Record<Output<GenericDataParserKey> extends infer InferredKey extends string | number ? `${InferredKey}` : never, Output<GenericDataParserValue> extends infer InferredValue ? InferredValue : never>, any>;
22
+ export type DataParserRecordShapeInput<GenericDataParserKey extends DataParserRecordKey, GenericDataParserValue extends DataParsers> = Extract<Record<Input<GenericDataParserKey> extends infer InferredKey extends string | number ? InferredKey : never, Input<GenericDataParserValue> extends infer InferredValue ? InferredValue : never>, any>;
23
+ type _DataParserRecord<GenericDefinition extends DataParserDefinitionRecord> = (DataParser<GenericDefinition, DataParserRecordShapeOutput<GenericDefinition["key"], GenericDefinition["value"]> extends infer InferredOutput ? InferredOutput : never, DataParserRecordShapeInput<GenericDefinition["key"], GenericDefinition["value"]>> & Kind<typeof dataParserRecordKind.definition>);
24
+ export interface DataParserRecord<GenericDefinition extends DataParserDefinitionRecord = DataParserDefinitionRecord> extends _DataParserRecord<GenericDefinition> {
25
+ }
26
+ export declare function record<GenericDataParserKey extends DataParserRecordKey, GenericDataParserValue extends DataParsers, const GenericDefinition extends Partial<DataParserDefinitionRecord> = never>(key: GenericDataParserKey, value: GenericDataParserValue, definition?: GenericDefinition): DataParserRecord<MergeDefinition<DataParserDefinitionRecord, NeverCoalescing<GenericDefinition, {}> & {
27
+ key: GenericDataParserKey;
28
+ value: GenericDataParserValue;
29
+ }>>;
30
+ export {};
@@ -0,0 +1,80 @@
1
+ import { createKind } from '../../common/kind.mjs';
2
+ import { dataParserInit, SymbolDataParserError } from '../base.mjs';
3
+ import { SymbolDataParserErrorIssue, setErrorPath, popErrorPath } from '../error.mjs';
4
+
5
+ const dataParserRecordKind = createKind("data-parser-record");
6
+ function record(key, value, definition) {
7
+ return dataParserInit(dataParserRecordKind, {
8
+ definition: {
9
+ errorMessage: definition?.errorMessage,
10
+ checkers: definition?.checkers ?? [],
11
+ key,
12
+ value,
13
+ },
14
+ }, {
15
+ sync: (data, error, self) => {
16
+ if (!data
17
+ || typeof data !== "object"
18
+ || data instanceof Array) {
19
+ return SymbolDataParserErrorIssue;
20
+ }
21
+ let output = {};
22
+ const currentIndexPath = error.currentPath.length;
23
+ for (const key in data) {
24
+ setErrorPath(error, key, currentIndexPath);
25
+ const resultKey = self
26
+ .definition
27
+ .key
28
+ .exec(key, error);
29
+ if (resultKey === SymbolDataParserError) {
30
+ output = SymbolDataParserError;
31
+ }
32
+ const resultValue = self
33
+ .definition
34
+ .value
35
+ .exec(data[key], error);
36
+ if (resultValue === SymbolDataParserError) {
37
+ output = SymbolDataParserError;
38
+ }
39
+ if (output !== SymbolDataParserError) {
40
+ output[resultKey] = resultValue;
41
+ }
42
+ }
43
+ popErrorPath(error);
44
+ return output;
45
+ },
46
+ async: async (data, error, self) => {
47
+ if (!data
48
+ || typeof data !== "object"
49
+ || data instanceof Array) {
50
+ return SymbolDataParserErrorIssue;
51
+ }
52
+ let output = {};
53
+ const currentIndexPath = error.currentPath.length;
54
+ for (const key in data) {
55
+ setErrorPath(error, key, currentIndexPath);
56
+ const resultKey = await self
57
+ .definition
58
+ .key
59
+ .asyncExec(key, error);
60
+ if (resultKey === SymbolDataParserError) {
61
+ output = SymbolDataParserError;
62
+ }
63
+ const resultValue = await self
64
+ .definition
65
+ .value
66
+ .asyncExec(data[key], error);
67
+ if (resultValue === SymbolDataParserError) {
68
+ output = SymbolDataParserError;
69
+ }
70
+ if (output !== SymbolDataParserError) {
71
+ output[resultKey] = resultValue;
72
+ }
73
+ }
74
+ popErrorPath(error);
75
+ return output;
76
+ },
77
+ });
78
+ }
79
+
80
+ export { dataParserRecordKind, record };
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ var kind = require('../../../../common/kind.cjs');
4
+ var base = require('../../../base.cjs');
5
+ var error = require('../../../error.cjs');
6
+ var index = require('../index.cjs');
7
+
8
+ const dataParserCheckerEmailKind = kind.createKind("data-parser-checker-email");
9
+ const emailPattern = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9-]*\.)+[A-Za-z]{2,}$/;
10
+ function checkerEmail(definition = {}) {
11
+ return base.dataParserCheckerInit(dataParserCheckerEmailKind, {
12
+ definition: {
13
+ ...definition,
14
+ pattern: emailPattern,
15
+ },
16
+ }, (input, self) => {
17
+ if (!self.definition.pattern.test(input)) {
18
+ return error.SymbolDataParserErrorIssue;
19
+ }
20
+ return self.definition.normalize ? input.toLowerCase() : input;
21
+ });
22
+ }
23
+ function email(definition) {
24
+ return index.string({
25
+ checkers: [checkerEmail(definition)],
26
+ });
27
+ }
28
+
29
+ exports.checkerEmail = checkerEmail;
30
+ exports.dataParserCheckerEmailKind = dataParserCheckerEmailKind;
31
+ exports.email = email;
@@ -0,0 +1,17 @@
1
+ import { type Kind } from "../../../../common";
2
+ import { type DataParserChecker, type DataParserCheckerDefinition } from "../../../../dataParser/base";
3
+ export interface DataParserCheckerDefinitionEmail extends DataParserCheckerDefinition {
4
+ normalize?: boolean;
5
+ pattern: RegExp;
6
+ }
7
+ export declare const dataParserCheckerEmailKind: import("../../../../common").KindHandler<import("../../../../common").KindDefinition<"data-parser-checker-email", unknown>>;
8
+ type _DataParserCheckerEmail = (Kind<typeof dataParserCheckerEmailKind.definition> & DataParserChecker<DataParserCheckerDefinitionEmail, string>);
9
+ export interface DataParserCheckerEmail extends _DataParserCheckerEmail {
10
+ }
11
+ export declare function checkerEmail(definition?: Partial<DataParserCheckerDefinitionEmail>): DataParserCheckerEmail;
12
+ export declare function email(definition?: Partial<DataParserCheckerDefinitionEmail>): import("..").DataParserString<{
13
+ readonly checkers: readonly [DataParserCheckerEmail];
14
+ readonly errorMessage?: string | undefined;
15
+ readonly coerce: boolean;
16
+ }>;
17
+ export {};
@@ -0,0 +1,27 @@
1
+ import { createKind } from '../../../../common/kind.mjs';
2
+ import { dataParserCheckerInit } from '../../../base.mjs';
3
+ import { SymbolDataParserErrorIssue } from '../../../error.mjs';
4
+ import { string } from '../index.mjs';
5
+
6
+ const dataParserCheckerEmailKind = createKind("data-parser-checker-email");
7
+ const emailPattern = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9-]*\.)+[A-Za-z]{2,}$/;
8
+ function checkerEmail(definition = {}) {
9
+ return dataParserCheckerInit(dataParserCheckerEmailKind, {
10
+ definition: {
11
+ ...definition,
12
+ pattern: emailPattern,
13
+ },
14
+ }, (input, self) => {
15
+ if (!self.definition.pattern.test(input)) {
16
+ return SymbolDataParserErrorIssue;
17
+ }
18
+ return self.definition.normalize ? input.toLowerCase() : input;
19
+ });
20
+ }
21
+ function email(definition) {
22
+ return string({
23
+ checkers: [checkerEmail(definition)],
24
+ });
25
+ }
26
+
27
+ export { checkerEmail, dataParserCheckerEmailKind, email };
@@ -0,0 +1,5 @@
1
+ export * from "./url";
2
+ export * from "./email";
3
+ export * from "./max";
4
+ export * from "./min";
5
+ export * from "./regex";