@duplojs/utils 1.6.2 → 1.6.3

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 (121) hide show
  1. package/dist/array/types/createTuple.d.ts +1 -1
  2. package/dist/clean/constraint/base.cjs +7 -0
  3. package/dist/clean/constraint/base.d.ts +26 -6
  4. package/dist/clean/constraint/base.mjs +7 -0
  5. package/dist/clean/constraint/cast.cjs +18 -0
  6. package/dist/clean/constraint/cast.d.ts +29 -0
  7. package/dist/clean/constraint/cast.mjs +16 -0
  8. package/dist/clean/constraint/defaultConstraint/number.cjs +2 -10
  9. package/dist/clean/constraint/defaultConstraint/number.d.ts +12 -37
  10. package/dist/clean/constraint/defaultConstraint/number.mjs +3 -10
  11. package/dist/clean/constraint/defaultConstraint/string.d.ts +9 -5
  12. package/dist/clean/constraint/index.d.ts +1 -0
  13. package/dist/clean/constraint/set.cjs +7 -1
  14. package/dist/clean/constraint/set.d.ts +25 -5
  15. package/dist/clean/constraint/set.mjs +7 -1
  16. package/dist/clean/entity/index.cjs +14 -4
  17. package/dist/clean/entity/index.d.ts +11 -1
  18. package/dist/clean/entity/index.mjs +15 -6
  19. package/dist/clean/index.cjs +5 -1
  20. package/dist/clean/index.d.ts +1 -0
  21. package/dist/clean/index.mjs +4 -2
  22. package/dist/clean/newType.cjs +6 -1
  23. package/dist/clean/newType.d.ts +20 -5
  24. package/dist/clean/newType.mjs +6 -1
  25. package/dist/clean/primitive/operations/equal.cjs +3 -0
  26. package/dist/clean/primitive/operations/equal.d.ts +2 -2
  27. package/dist/clean/primitive/operations/equal.mjs +3 -0
  28. package/dist/clean/toMapDataParser.cjs +52 -0
  29. package/dist/clean/toMapDataParser.d.ts +53 -0
  30. package/dist/clean/toMapDataParser.mjs +50 -0
  31. package/dist/common/index.d.ts +1 -0
  32. package/dist/common/printer.cjs +73 -0
  33. package/dist/common/printer.d.ts +139 -0
  34. package/dist/common/printer.mjs +73 -0
  35. package/dist/common/types/and.d.ts +1 -2
  36. package/dist/common/types/or.d.ts +1 -2
  37. package/dist/dataParser/base.cjs +12 -35
  38. package/dist/dataParser/base.d.ts +6 -9
  39. package/dist/dataParser/base.mjs +8 -30
  40. package/dist/dataParser/error.cjs +39 -21
  41. package/dist/dataParser/error.d.ts +19 -19
  42. package/dist/dataParser/error.mjs +37 -18
  43. package/dist/dataParser/extended/index.cjs +3 -4
  44. package/dist/dataParser/extended/index.mjs +1 -1
  45. package/dist/dataParser/identifier.d.ts +6 -6
  46. package/dist/dataParser/index.cjs +3 -6
  47. package/dist/dataParser/index.mjs +2 -2
  48. package/dist/dataParser/parsers/array/checkers/max.cjs +3 -6
  49. package/dist/dataParser/parsers/array/checkers/max.mjs +4 -7
  50. package/dist/dataParser/parsers/array/checkers/min.cjs +3 -6
  51. package/dist/dataParser/parsers/array/checkers/min.mjs +4 -7
  52. package/dist/dataParser/parsers/array/index.cjs +8 -8
  53. package/dist/dataParser/parsers/array/index.mjs +4 -4
  54. package/dist/dataParser/parsers/bigint/checkers/max.cjs +2 -2
  55. package/dist/dataParser/parsers/bigint/checkers/max.mjs +3 -3
  56. package/dist/dataParser/parsers/bigint/checkers/min.cjs +2 -2
  57. package/dist/dataParser/parsers/bigint/checkers/min.mjs +3 -3
  58. package/dist/dataParser/parsers/bigint/index.cjs +2 -2
  59. package/dist/dataParser/parsers/bigint/index.mjs +3 -3
  60. package/dist/dataParser/parsers/boolean.cjs +3 -3
  61. package/dist/dataParser/parsers/boolean.mjs +4 -4
  62. package/dist/dataParser/parsers/date.cjs +4 -4
  63. package/dist/dataParser/parsers/date.mjs +5 -5
  64. package/dist/dataParser/parsers/empty.cjs +2 -2
  65. package/dist/dataParser/parsers/empty.mjs +3 -3
  66. package/dist/dataParser/parsers/literal.cjs +2 -2
  67. package/dist/dataParser/parsers/literal.mjs +3 -3
  68. package/dist/dataParser/parsers/nil.cjs +2 -2
  69. package/dist/dataParser/parsers/nil.mjs +3 -3
  70. package/dist/dataParser/parsers/number/checkers/int.cjs +2 -2
  71. package/dist/dataParser/parsers/number/checkers/int.mjs +3 -3
  72. package/dist/dataParser/parsers/number/checkers/max.cjs +3 -1
  73. package/dist/dataParser/parsers/number/checkers/max.mjs +4 -2
  74. package/dist/dataParser/parsers/number/checkers/min.cjs +3 -1
  75. package/dist/dataParser/parsers/number/checkers/min.mjs +4 -2
  76. package/dist/dataParser/parsers/number/index.cjs +2 -2
  77. package/dist/dataParser/parsers/number/index.mjs +3 -3
  78. package/dist/dataParser/parsers/object/index.cjs +8 -8
  79. package/dist/dataParser/parsers/object/index.mjs +4 -4
  80. package/dist/dataParser/parsers/pipe.cjs +25 -10
  81. package/dist/dataParser/parsers/pipe.mjs +22 -7
  82. package/dist/dataParser/parsers/record/index.cjs +18 -16
  83. package/dist/dataParser/parsers/record/index.mjs +8 -6
  84. package/dist/dataParser/parsers/recover.cjs +7 -6
  85. package/dist/dataParser/parsers/recover.mjs +2 -1
  86. package/dist/dataParser/parsers/refine.cjs +3 -1
  87. package/dist/dataParser/parsers/refine.mjs +4 -2
  88. package/dist/dataParser/parsers/string/checkers/email.cjs +2 -2
  89. package/dist/dataParser/parsers/string/checkers/email.mjs +3 -3
  90. package/dist/dataParser/parsers/string/checkers/max.cjs +3 -1
  91. package/dist/dataParser/parsers/string/checkers/max.mjs +4 -2
  92. package/dist/dataParser/parsers/string/checkers/min.cjs +3 -1
  93. package/dist/dataParser/parsers/string/checkers/min.mjs +4 -2
  94. package/dist/dataParser/parsers/string/checkers/regex.cjs +2 -2
  95. package/dist/dataParser/parsers/string/checkers/regex.mjs +3 -3
  96. package/dist/dataParser/parsers/string/checkers/url.cjs +4 -4
  97. package/dist/dataParser/parsers/string/checkers/url.mjs +5 -5
  98. package/dist/dataParser/parsers/string/index.cjs +2 -2
  99. package/dist/dataParser/parsers/string/index.mjs +3 -3
  100. package/dist/dataParser/parsers/templateLiteral/index.cjs +2 -2
  101. package/dist/dataParser/parsers/templateLiteral/index.mjs +3 -3
  102. package/dist/dataParser/parsers/time/checkers/max.cjs +3 -1
  103. package/dist/dataParser/parsers/time/checkers/max.mjs +4 -2
  104. package/dist/dataParser/parsers/time/checkers/min.cjs +3 -1
  105. package/dist/dataParser/parsers/time/checkers/min.mjs +4 -2
  106. package/dist/dataParser/parsers/time/index.cjs +4 -4
  107. package/dist/dataParser/parsers/time/index.mjs +5 -5
  108. package/dist/dataParser/parsers/transform.cjs +6 -6
  109. package/dist/dataParser/parsers/transform.d.ts +2 -2
  110. package/dist/dataParser/parsers/transform.mjs +4 -4
  111. package/dist/dataParser/parsers/tuple.cjs +14 -14
  112. package/dist/dataParser/parsers/tuple.mjs +4 -4
  113. package/dist/dataParser/parsers/union.cjs +26 -8
  114. package/dist/dataParser/parsers/union.mjs +26 -8
  115. package/dist/index.cjs +5 -0
  116. package/dist/index.mjs +1 -0
  117. package/dist/metadata.json +27 -0
  118. package/dist/number/types/isGreater.d.ts +26 -3
  119. package/dist/string/length.d.ts +2 -2
  120. package/dist/string/types/split.d.ts +6 -5
  121. package/package.json +1 -1
@@ -30,17 +30,17 @@ function object(shape, definition) {
30
30
  if (!data
31
31
  || typeof data !== "object"
32
32
  || data instanceof Array) {
33
- return error.SymbolDataParserErrorIssue;
33
+ return error.addIssue(error$1, "object", data, self.definition.errorMessage);
34
34
  }
35
35
  let output = {};
36
36
  const currentIndexPath = error$1.currentPath.length;
37
37
  for (const entry of self.definition.optimizedShape.value) {
38
38
  error.setErrorPath(error$1, entry.key, currentIndexPath);
39
39
  const result = entry.value.exec(data[entry.key], error$1);
40
- if (result === base.SymbolDataParserError) {
41
- output = base.SymbolDataParserError;
40
+ if (result === error.SymbolDataParserError) {
41
+ output = error.SymbolDataParserError;
42
42
  }
43
- else if (output !== base.SymbolDataParserError
43
+ else if (output !== error.SymbolDataParserError
44
44
  && result !== undefined) {
45
45
  output[entry.key] = result;
46
46
  }
@@ -52,17 +52,17 @@ function object(shape, definition) {
52
52
  if (!data
53
53
  || typeof data !== "object"
54
54
  || data instanceof Array) {
55
- return error.SymbolDataParserErrorIssue;
55
+ return error.addIssue(error$1, "object", data, self.definition.errorMessage);
56
56
  }
57
57
  let output = {};
58
58
  const currentIndexPath = error$1.currentPath.length;
59
59
  for (const entry of self.definition.optimizedShape.value) {
60
60
  error.setErrorPath(error$1, entry.key, currentIndexPath);
61
61
  const result = await entry.value.asyncExec(data[entry.key], error$1);
62
- if (result === base.SymbolDataParserError) {
63
- output = base.SymbolDataParserError;
62
+ if (result === error.SymbolDataParserError) {
63
+ output = error.SymbolDataParserError;
64
64
  }
65
- else if (output !== base.SymbolDataParserError
65
+ else if (output !== error.SymbolDataParserError
66
66
  && result !== undefined) {
67
67
  output[entry.key] = result;
68
68
  }
@@ -1,5 +1,5 @@
1
- import { dataParserInit, SymbolDataParserError, dataParserKind } from '../../base.mjs';
2
- import { SymbolDataParserErrorIssue, setErrorPath, popErrorPath } from '../../error.mjs';
1
+ import { dataParserInit, dataParserKind } from '../../base.mjs';
2
+ import { addIssue, setErrorPath, SymbolDataParserError, popErrorPath } from '../../error.mjs';
3
3
  import { createDataParserKind } from '../../kind.mjs';
4
4
  import { memo } from '../../../common/memo.mjs';
5
5
  import { some } from '../../../array/some.mjs';
@@ -28,7 +28,7 @@ function object(shape, definition) {
28
28
  if (!data
29
29
  || typeof data !== "object"
30
30
  || data instanceof Array) {
31
- return SymbolDataParserErrorIssue;
31
+ return addIssue(error, "object", data, self.definition.errorMessage);
32
32
  }
33
33
  let output = {};
34
34
  const currentIndexPath = error.currentPath.length;
@@ -50,7 +50,7 @@ function object(shape, definition) {
50
50
  if (!data
51
51
  || typeof data !== "object"
52
52
  || data instanceof Array) {
53
- return SymbolDataParserErrorIssue;
53
+ return addIssue(error, "object", data, self.definition.errorMessage);
54
54
  }
55
55
  let output = {};
56
56
  const currentIndexPath = error.currentPath.length;
@@ -2,6 +2,7 @@
2
2
 
3
3
  var base = require('../base.cjs');
4
4
  var kind = require('../kind.cjs');
5
+ var error = require('../error.cjs');
5
6
  var override = require('../../common/override.cjs');
6
7
 
7
8
  const pipeKind = kind.createDataParserKind("pipe");
@@ -15,19 +16,33 @@ function pipe(input, output, definition) {
15
16
  input,
16
17
  output,
17
18
  }, {
18
- sync: (data, error, self) => {
19
- const result = self.definition.input.exec(data, error);
20
- if (result === base.SymbolDataParserError) {
21
- return base.SymbolDataParserError;
19
+ sync: (data, error$1, self) => {
20
+ const currentIndexPath = error$1.currentPath.length;
21
+ error.setErrorPath(error$1, "(pipeIn)", currentIndexPath);
22
+ const resultIn = self.definition.input.exec(data, error$1);
23
+ if (resultIn === error.SymbolDataParserError) {
24
+ error.popErrorPath(error$1);
25
+ return error.SymbolDataParserError;
22
26
  }
23
- return self.definition.output.exec(result, error);
27
+ error.setErrorPath(error$1, "(pipeOut)", currentIndexPath);
28
+ const resultOut = self.definition.output.exec(resultIn, error$1);
29
+ error.popErrorPath(error$1);
30
+ return resultOut;
24
31
  },
25
- async: async (data, error, self) => {
26
- const result = await self.definition.input.asyncExec(data, error);
27
- if (result === base.SymbolDataParserError) {
28
- return base.SymbolDataParserError;
32
+ async: async (data, error$1, self) => {
33
+ const currentIndexPath = error$1.currentPath.length;
34
+ error.setErrorPath(error$1, "(pipeIn)", currentIndexPath);
35
+ const resultIn = await self.definition.input.asyncExec(data, error$1);
36
+ if (resultIn === error.SymbolDataParserError) {
37
+ error.popErrorPath(error$1);
38
+ return error.SymbolDataParserError;
29
39
  }
30
- return self.definition.output.asyncExec(result, error);
40
+ error.setErrorPath(error$1, "(pipeOut)", currentIndexPath);
41
+ return self.definition.output.asyncExec(resultIn, error$1)
42
+ .then((resultOut) => {
43
+ error.popErrorPath(error$1);
44
+ return resultOut;
45
+ });
31
46
  },
32
47
  isAsynchronous: (self) => self.definition.input.isAsynchronous() || self.definition.output.isAsynchronous(),
33
48
  }, pipe.overrideHandler);
@@ -1,5 +1,6 @@
1
- import { dataParserInit, SymbolDataParserError } from '../base.mjs';
1
+ import { dataParserInit } from '../base.mjs';
2
2
  import { createDataParserKind } from '../kind.mjs';
3
+ import { setErrorPath, SymbolDataParserError, popErrorPath } from '../error.mjs';
3
4
  import { createOverride } from '../../common/override.mjs';
4
5
 
5
6
  const pipeKind = createDataParserKind("pipe");
@@ -14,18 +15,32 @@ function pipe(input, output, definition) {
14
15
  output,
15
16
  }, {
16
17
  sync: (data, error, self) => {
17
- const result = self.definition.input.exec(data, error);
18
- if (result === SymbolDataParserError) {
18
+ const currentIndexPath = error.currentPath.length;
19
+ setErrorPath(error, "(pipeIn)", currentIndexPath);
20
+ const resultIn = self.definition.input.exec(data, error);
21
+ if (resultIn === SymbolDataParserError) {
22
+ popErrorPath(error);
19
23
  return SymbolDataParserError;
20
24
  }
21
- return self.definition.output.exec(result, error);
25
+ setErrorPath(error, "(pipeOut)", currentIndexPath);
26
+ const resultOut = self.definition.output.exec(resultIn, error);
27
+ popErrorPath(error);
28
+ return resultOut;
22
29
  },
23
30
  async: async (data, error, self) => {
24
- const result = await self.definition.input.asyncExec(data, error);
25
- if (result === SymbolDataParserError) {
31
+ const currentIndexPath = error.currentPath.length;
32
+ setErrorPath(error, "(pipeIn)", currentIndexPath);
33
+ const resultIn = await self.definition.input.asyncExec(data, error);
34
+ if (resultIn === SymbolDataParserError) {
35
+ popErrorPath(error);
26
36
  return SymbolDataParserError;
27
37
  }
28
- return self.definition.output.asyncExec(result, error);
38
+ setErrorPath(error, "(pipeOut)", currentIndexPath);
39
+ return self.definition.output.asyncExec(resultIn, error)
40
+ .then((resultOut) => {
41
+ popErrorPath(error);
42
+ return resultOut;
43
+ });
29
44
  },
30
45
  isAsynchronous: (self) => self.definition.input.isAsynchronous() || self.definition.output.isAsynchronous(),
31
46
  }, pipe.overrideHandler);
@@ -28,7 +28,7 @@ function record(key, value, definition) {
28
28
  if (!data
29
29
  || typeof data !== "object"
30
30
  || data instanceof Array) {
31
- return error.SymbolDataParserErrorIssue;
31
+ return error.addIssue(error$1, "record object", data, self.definition.errorMessage);
32
32
  }
33
33
  let output = {};
34
34
  const fromData = {
@@ -37,27 +37,28 @@ function record(key, value, definition) {
37
37
  };
38
38
  const currentIndexPath = error$1.currentPath.length;
39
39
  for (const key in fromData) {
40
- error.setErrorPath(error$1, key, currentIndexPath);
40
+ error.setErrorPath(error$1, `(recordKey: ${key})`, currentIndexPath);
41
41
  const resultKey = self
42
42
  .definition
43
43
  .key
44
44
  .exec(key, error$1);
45
- if (resultKey === base.SymbolDataParserError) {
46
- output = base.SymbolDataParserError;
45
+ if (resultKey === error.SymbolDataParserError) {
46
+ output = error.SymbolDataParserError;
47
47
  }
48
+ error.setErrorPath(error$1, key, currentIndexPath);
48
49
  const resultValue = self
49
50
  .definition
50
51
  .value
51
52
  .exec(fromData[key], error$1);
52
- if (resultValue === base.SymbolDataParserError) {
53
- output = base.SymbolDataParserError;
53
+ if (resultValue === error.SymbolDataParserError) {
54
+ output = error.SymbolDataParserError;
54
55
  }
55
- if (output !== base.SymbolDataParserError) {
56
+ if (output !== error.SymbolDataParserError) {
56
57
  output[resultKey] = resultValue;
57
58
  }
58
59
  }
59
60
  void (currentIndexPath !== error$1.currentPath.length && error.popErrorPath(error$1));
60
- if (output === base.SymbolDataParserError) {
61
+ if (output === error.SymbolDataParserError) {
61
62
  return output;
62
63
  }
63
64
  return output;
@@ -66,7 +67,7 @@ function record(key, value, definition) {
66
67
  if (!data
67
68
  || typeof data !== "object"
68
69
  || data instanceof Array) {
69
- return error.SymbolDataParserErrorIssue;
70
+ return error.addIssue(error$1, "record object", data, self.definition.errorMessage);
70
71
  }
71
72
  let output = {};
72
73
  const fromData = {
@@ -75,27 +76,28 @@ function record(key, value, definition) {
75
76
  };
76
77
  const currentIndexPath = error$1.currentPath.length;
77
78
  for (const key in fromData) {
78
- error.setErrorPath(error$1, key, currentIndexPath);
79
+ error.setErrorPath(error$1, `(recordKey: ${key})`, currentIndexPath);
79
80
  const resultKey = await self
80
81
  .definition
81
82
  .key
82
83
  .asyncExec(key, error$1);
83
- if (resultKey === base.SymbolDataParserError) {
84
- output = base.SymbolDataParserError;
84
+ if (resultKey === error.SymbolDataParserError) {
85
+ output = error.SymbolDataParserError;
85
86
  }
87
+ error.setErrorPath(error$1, key, currentIndexPath);
86
88
  const resultValue = await self
87
89
  .definition
88
90
  .value
89
91
  .asyncExec(fromData[key], error$1);
90
- if (resultValue === base.SymbolDataParserError) {
91
- output = base.SymbolDataParserError;
92
+ if (resultValue === error.SymbolDataParserError) {
93
+ output = error.SymbolDataParserError;
92
94
  }
93
- if (output !== base.SymbolDataParserError) {
95
+ if (output !== error.SymbolDataParserError) {
94
96
  output[resultKey] = resultValue;
95
97
  }
96
98
  }
97
99
  void (currentIndexPath !== error$1.currentPath.length && error.popErrorPath(error$1));
98
- if (output === base.SymbolDataParserError) {
100
+ if (output === error.SymbolDataParserError) {
99
101
  return output;
100
102
  }
101
103
  return output;
@@ -1,5 +1,5 @@
1
- import { dataParserInit, SymbolDataParserError } from '../../base.mjs';
2
- import { SymbolDataParserErrorIssue, setErrorPath, popErrorPath } from '../../error.mjs';
1
+ import { dataParserInit } from '../../base.mjs';
2
+ import { addIssue, setErrorPath, SymbolDataParserError, popErrorPath } from '../../error.mjs';
3
3
  import { createDataParserKind } from '../../kind.mjs';
4
4
  import { findRecordRequiredKey } from './findRecordRequiredKey.mjs';
5
5
  export { findRecordRequiredKeyOnTemplateLiteralPart } from './findRecordRequiredKey.mjs';
@@ -27,7 +27,7 @@ function record(key, value, definition) {
27
27
  if (!data
28
28
  || typeof data !== "object"
29
29
  || data instanceof Array) {
30
- return SymbolDataParserErrorIssue;
30
+ return addIssue(error, "record object", data, self.definition.errorMessage);
31
31
  }
32
32
  let output = {};
33
33
  const fromData = {
@@ -36,7 +36,7 @@ function record(key, value, definition) {
36
36
  };
37
37
  const currentIndexPath = error.currentPath.length;
38
38
  for (const key in fromData) {
39
- setErrorPath(error, key, currentIndexPath);
39
+ setErrorPath(error, `(recordKey: ${key})`, currentIndexPath);
40
40
  const resultKey = self
41
41
  .definition
42
42
  .key
@@ -44,6 +44,7 @@ function record(key, value, definition) {
44
44
  if (resultKey === SymbolDataParserError) {
45
45
  output = SymbolDataParserError;
46
46
  }
47
+ setErrorPath(error, key, currentIndexPath);
47
48
  const resultValue = self
48
49
  .definition
49
50
  .value
@@ -65,7 +66,7 @@ function record(key, value, definition) {
65
66
  if (!data
66
67
  || typeof data !== "object"
67
68
  || data instanceof Array) {
68
- return SymbolDataParserErrorIssue;
69
+ return addIssue(error, "record object", data, self.definition.errorMessage);
69
70
  }
70
71
  let output = {};
71
72
  const fromData = {
@@ -74,7 +75,7 @@ function record(key, value, definition) {
74
75
  };
75
76
  const currentIndexPath = error.currentPath.length;
76
77
  for (const key in fromData) {
77
- setErrorPath(error, key, currentIndexPath);
78
+ setErrorPath(error, `(recordKey: ${key})`, currentIndexPath);
78
79
  const resultKey = await self
79
80
  .definition
80
81
  .key
@@ -82,6 +83,7 @@ function record(key, value, definition) {
82
83
  if (resultKey === SymbolDataParserError) {
83
84
  output = SymbolDataParserError;
84
85
  }
86
+ setErrorPath(error, key, currentIndexPath);
85
87
  const resultValue = await self
86
88
  .definition
87
89
  .value
@@ -2,6 +2,7 @@
2
2
 
3
3
  var base = require('../base.cjs');
4
4
  var kind = require('../kind.cjs');
5
+ var error = require('../error.cjs');
5
6
  var override = require('../../common/override.cjs');
6
7
 
7
8
  const recoverKind = kind.createDataParserKind("recover");
@@ -15,15 +16,15 @@ function recover(inner, recoveredValue, definition) {
15
16
  inner,
16
17
  recoveredValue,
17
18
  }, {
18
- sync: (data, error, self) => {
19
- const result = self.definition.inner.exec(data, error);
20
- return result === base.SymbolDataParserError
19
+ sync: (data, error$1, self) => {
20
+ const result = self.definition.inner.exec(data, error$1);
21
+ return result === error.SymbolDataParserError
21
22
  ? self.definition.recoveredValue
22
23
  : result;
23
24
  },
24
- async: async (data, error, self) => {
25
- const result = await self.definition.inner.asyncExec(data, error);
26
- return result === base.SymbolDataParserError
25
+ async: async (data, error$1, self) => {
26
+ const result = await self.definition.inner.asyncExec(data, error$1);
27
+ return result === error.SymbolDataParserError
27
28
  ? self.definition.recoveredValue
28
29
  : result;
29
30
  },
@@ -1,5 +1,6 @@
1
- import { dataParserInit, SymbolDataParserError } from '../base.mjs';
1
+ import { dataParserInit } from '../base.mjs';
2
2
  import { createDataParserKind } from '../kind.mjs';
3
+ import { SymbolDataParserError } from '../error.mjs';
3
4
  import { createOverride } from '../../common/override.mjs';
4
5
 
5
6
  const recoverKind = createDataParserKind("recover");
@@ -11,7 +11,9 @@ function checkerRefine(theFunction, definition) {
11
11
  ...definition,
12
12
  theFunction,
13
13
  },
14
- }, (value, self) => self.definition.theFunction(value) ? value : error.SymbolDataParserErrorIssue);
14
+ }, (value, error$1, self) => self.definition.theFunction(value)
15
+ ? value
16
+ : error.addIssue(error$1, "value matching refine predicate", value, self.definition.errorMessage));
15
17
  }
16
18
 
17
19
  exports.checkerRefine = checkerRefine;
@@ -1,5 +1,5 @@
1
1
  import { dataParserCheckerInit } from '../base.mjs';
2
- import { SymbolDataParserErrorIssue } from '../error.mjs';
2
+ import { addIssue } from '../error.mjs';
3
3
  import { createDataParserKind } from '../kind.mjs';
4
4
 
5
5
  const dataParserCheckerRefineKind = createDataParserKind("refine");
@@ -9,7 +9,9 @@ function checkerRefine(theFunction, definition) {
9
9
  ...definition,
10
10
  theFunction,
11
11
  },
12
- }, (value, self) => self.definition.theFunction(value) ? value : SymbolDataParserErrorIssue);
12
+ }, (value, error, self) => self.definition.theFunction(value)
13
+ ? value
14
+ : addIssue(error, "value matching refine predicate", value, self.definition.errorMessage));
13
15
  }
14
16
 
15
17
  export { checkerRefine, dataParserCheckerRefineKind };
@@ -13,9 +13,9 @@ function checkerEmail(definition = {}) {
13
13
  ...definition,
14
14
  pattern: emailPattern,
15
15
  },
16
- }, (input, self) => {
16
+ }, (input, error$1, self) => {
17
17
  if (!self.definition.pattern.test(input)) {
18
- return error.SymbolDataParserErrorIssue;
18
+ return error.addIssue(error$1, "email", input, self.definition.errorMessage);
19
19
  }
20
20
  return self.definition.normalize ? input.toLowerCase() : input;
21
21
  });
@@ -1,5 +1,5 @@
1
1
  import { dataParserCheckerInit } from '../../../base.mjs';
2
- import { SymbolDataParserErrorIssue } from '../../../error.mjs';
2
+ import { addIssue } from '../../../error.mjs';
3
3
  import { string } from '../index.mjs';
4
4
  import { createDataParserKind } from '../../../kind.mjs';
5
5
 
@@ -11,9 +11,9 @@ function checkerEmail(definition = {}) {
11
11
  ...definition,
12
12
  pattern: emailPattern,
13
13
  },
14
- }, (input, self) => {
14
+ }, (input, error, self) => {
15
15
  if (!self.definition.pattern.test(input)) {
16
- return SymbolDataParserErrorIssue;
16
+ return addIssue(error, "email", input, self.definition.errorMessage);
17
17
  }
18
18
  return self.definition.normalize ? input.toLowerCase() : input;
19
19
  });
@@ -11,7 +11,9 @@ function checkerStringMax(max, definition = {}) {
11
11
  ...definition,
12
12
  max,
13
13
  },
14
- }, (value, self) => value.length <= self.definition.max ? value : error.SymbolDataParserErrorIssue);
14
+ }, (value, error$1, self) => value.length <= self.definition.max
15
+ ? value
16
+ : error.addIssue(error$1, `string.length <= ${self.definition.max}`, value, self.definition.errorMessage));
15
17
  }
16
18
 
17
19
  exports.checkerStringMax = checkerStringMax;
@@ -1,5 +1,5 @@
1
1
  import { dataParserCheckerInit } from '../../../base.mjs';
2
- import { SymbolDataParserErrorIssue } from '../../../error.mjs';
2
+ import { addIssue } from '../../../error.mjs';
3
3
  import { createDataParserKind } from '../../../kind.mjs';
4
4
 
5
5
  const checkerStringMaxKind = createDataParserKind("checker-string-max");
@@ -9,7 +9,9 @@ function checkerStringMax(max, definition = {}) {
9
9
  ...definition,
10
10
  max,
11
11
  },
12
- }, (value, self) => value.length <= self.definition.max ? value : SymbolDataParserErrorIssue);
12
+ }, (value, error, self) => value.length <= self.definition.max
13
+ ? value
14
+ : addIssue(error, `string.length <= ${self.definition.max}`, value, self.definition.errorMessage));
13
15
  }
14
16
 
15
17
  export { checkerStringMax, checkerStringMaxKind };
@@ -11,7 +11,9 @@ function checkerStringMin(min, definition = {}) {
11
11
  ...definition,
12
12
  min,
13
13
  },
14
- }, (value, self) => value.length >= self.definition.min ? value : error.SymbolDataParserErrorIssue);
14
+ }, (value, error$1, self) => value.length >= self.definition.min
15
+ ? value
16
+ : error.addIssue(error$1, `string.length >= ${self.definition.min}`, value, self.definition.errorMessage));
15
17
  }
16
18
 
17
19
  exports.checkerStringMin = checkerStringMin;
@@ -1,5 +1,5 @@
1
1
  import { dataParserCheckerInit } from '../../../base.mjs';
2
- import { SymbolDataParserErrorIssue } from '../../../error.mjs';
2
+ import { addIssue } from '../../../error.mjs';
3
3
  import { createDataParserKind } from '../../../kind.mjs';
4
4
 
5
5
  const checkerStringMinKind = createDataParserKind("checker-string-min");
@@ -9,7 +9,9 @@ function checkerStringMin(min, definition = {}) {
9
9
  ...definition,
10
10
  min,
11
11
  },
12
- }, (value, self) => value.length >= self.definition.min ? value : SymbolDataParserErrorIssue);
12
+ }, (value, error, self) => value.length >= self.definition.min
13
+ ? value
14
+ : addIssue(error, `string.length >= ${self.definition.min}`, value, self.definition.errorMessage));
13
15
  }
14
16
 
15
17
  export { checkerStringMin, checkerStringMinKind };
@@ -11,9 +11,9 @@ function checkerStringRegex(regex, definition = {}) {
11
11
  ...definition,
12
12
  regex,
13
13
  },
14
- }, (value, self) => self.definition.regex.test(value)
14
+ }, (value, error$1, self) => self.definition.regex.test(value)
15
15
  ? value
16
- : error.SymbolDataParserErrorIssue);
16
+ : error.addIssue(error$1, `string with pattern ${self.definition.regex.source.toString()}`, value, self.definition.errorMessage));
17
17
  }
18
18
 
19
19
  exports.checkerStringRegex = checkerStringRegex;
@@ -1,5 +1,5 @@
1
1
  import { dataParserCheckerInit } from '../../../base.mjs';
2
- import { SymbolDataParserErrorIssue } from '../../../error.mjs';
2
+ import { addIssue } from '../../../error.mjs';
3
3
  import { createDataParserKind } from '../../../kind.mjs';
4
4
 
5
5
  const checkerStringRegexKind = createDataParserKind("checker-string-regex");
@@ -9,9 +9,9 @@ function checkerStringRegex(regex, definition = {}) {
9
9
  ...definition,
10
10
  regex,
11
11
  },
12
- }, (value, self) => self.definition.regex.test(value)
12
+ }, (value, error, self) => self.definition.regex.test(value)
13
13
  ? value
14
- : SymbolDataParserErrorIssue);
14
+ : addIssue(error, `string with pattern ${self.definition.regex.source.toString()}`, value, self.definition.errorMessage));
15
15
  }
16
16
 
17
17
  export { checkerStringRegex, checkerStringRegexKind };
@@ -10,19 +10,19 @@ const regexRemoveDote = /:$/;
10
10
  function checkerUrl(definition = {}) {
11
11
  return base.dataParserCheckerInit(checkerUrlKind, {
12
12
  definition: definition,
13
- }, (input, self) => {
13
+ }, (input, error$1, self) => {
14
14
  try {
15
15
  const url = new URL(input);
16
16
  if (self.definition.hostname) {
17
17
  self.definition.hostname.lastIndex = 0;
18
18
  if (!self.definition.hostname.test(url.hostname)) {
19
- return error.SymbolDataParserErrorIssue;
19
+ return error.addIssue(error$1, `URL with hostname matching ${self.definition.hostname.source}`, input, self.definition.errorMessage);
20
20
  }
21
21
  }
22
22
  if (self.definition.protocol) {
23
23
  self.definition.protocol.lastIndex = 0;
24
24
  if (!self.definition.protocol.test(url.protocol.replace(regexRemoveDote, ""))) {
25
- return error.SymbolDataParserErrorIssue;
25
+ return error.addIssue(error$1, `URL with protocol matching ${self.definition.protocol.source}`, input, self.definition.errorMessage);
26
26
  }
27
27
  }
28
28
  if (self.definition.normalize) {
@@ -33,7 +33,7 @@ function checkerUrl(definition = {}) {
33
33
  }
34
34
  }
35
35
  catch {
36
- return error.SymbolDataParserErrorIssue;
36
+ return error.addIssue(error$1, "valid URL", input, self.definition.errorMessage);
37
37
  }
38
38
  });
39
39
  }
@@ -1,5 +1,5 @@
1
1
  import { dataParserCheckerInit } from '../../../base.mjs';
2
- import { SymbolDataParserErrorIssue } from '../../../error.mjs';
2
+ import { addIssue } from '../../../error.mjs';
3
3
  import { string } from '../index.mjs';
4
4
  import { createDataParserKind } from '../../../kind.mjs';
5
5
 
@@ -8,19 +8,19 @@ const regexRemoveDote = /:$/;
8
8
  function checkerUrl(definition = {}) {
9
9
  return dataParserCheckerInit(checkerUrlKind, {
10
10
  definition: definition,
11
- }, (input, self) => {
11
+ }, (input, error, self) => {
12
12
  try {
13
13
  const url = new URL(input);
14
14
  if (self.definition.hostname) {
15
15
  self.definition.hostname.lastIndex = 0;
16
16
  if (!self.definition.hostname.test(url.hostname)) {
17
- return SymbolDataParserErrorIssue;
17
+ return addIssue(error, `URL with hostname matching ${self.definition.hostname.source}`, input, self.definition.errorMessage);
18
18
  }
19
19
  }
20
20
  if (self.definition.protocol) {
21
21
  self.definition.protocol.lastIndex = 0;
22
22
  if (!self.definition.protocol.test(url.protocol.replace(regexRemoveDote, ""))) {
23
- return SymbolDataParserErrorIssue;
23
+ return addIssue(error, `URL with protocol matching ${self.definition.protocol.source}`, input, self.definition.errorMessage);
24
24
  }
25
25
  }
26
26
  if (self.definition.normalize) {
@@ -31,7 +31,7 @@ function checkerUrl(definition = {}) {
31
31
  }
32
32
  }
33
33
  catch {
34
- return SymbolDataParserErrorIssue;
34
+ return addIssue(error, "valid URL", input, self.definition.errorMessage);
35
35
  }
36
36
  });
37
37
  }
@@ -14,7 +14,7 @@ function string(definition) {
14
14
  errorMessage: definition?.errorMessage,
15
15
  checkers: definition?.checkers ?? [],
16
16
  coerce: definition?.coerce ?? false,
17
- }, (data, _error, self) => {
17
+ }, (data, error$1, self) => {
18
18
  if (self.definition.coerce) {
19
19
  try {
20
20
  // eslint-disable-next-line no-param-reassign
@@ -25,7 +25,7 @@ function string(definition) {
25
25
  if (typeof data === "string") {
26
26
  return data;
27
27
  }
28
- return error.SymbolDataParserErrorIssue;
28
+ return error.addIssue(error$1, "string", data, self.definition.errorMessage);
29
29
  }, string.overrideHandler);
30
30
  return self;
31
31
  }
@@ -1,5 +1,5 @@
1
1
  import { dataParserInit } from '../../base.mjs';
2
- import { SymbolDataParserErrorIssue } from '../../error.mjs';
2
+ import { addIssue } from '../../error.mjs';
3
3
  import { createDataParserKind } from '../../kind.mjs';
4
4
  import { createOverride } from '../../../common/override.mjs';
5
5
 
@@ -12,7 +12,7 @@ function string(definition) {
12
12
  errorMessage: definition?.errorMessage,
13
13
  checkers: definition?.checkers ?? [],
14
14
  coerce: definition?.coerce ?? false,
15
- }, (data, _error, self) => {
15
+ }, (data, error, self) => {
16
16
  if (self.definition.coerce) {
17
17
  try {
18
18
  // eslint-disable-next-line no-param-reassign
@@ -23,7 +23,7 @@ function string(definition) {
23
23
  if (typeof data === "string") {
24
24
  return data;
25
25
  }
26
- return SymbolDataParserErrorIssue;
26
+ return addIssue(error, "string", data, self.definition.errorMessage);
27
27
  }, string.overrideHandler);
28
28
  return self;
29
29
  }
@@ -18,11 +18,11 @@ function templateLiteral(template, definition) {
18
18
  checkers: definition?.checkers ?? [],
19
19
  template,
20
20
  pattern,
21
- }, (data, _error, self) => {
21
+ }, (data, error$1, self) => {
22
22
  if (typeof data === "string" && self.definition.pattern.test(data)) {
23
23
  return data;
24
24
  }
25
- return error.SymbolDataParserErrorIssue;
25
+ return error.addIssue(error$1, `string matching template literal pattern ${self.definition.pattern.source}`, data, self.definition.errorMessage);
26
26
  }, templateLiteral.overrideHandler);
27
27
  return self;
28
28
  }