@leyyo/common 1.0.8 → 1.0.9

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 (231) hide show
  1. package/dist/assertion/common-assertion.d.ts +151 -22
  2. package/dist/assertion/common-assertion.js +573 -90
  3. package/dist/assertion/common-assertion.js.map +1 -1
  4. package/dist/assertion/index.d.ts +1 -1
  5. package/dist/assertion/index.js +1 -1
  6. package/dist/assertion/index.types.d.ts +661 -0
  7. package/dist/{descriptor/index-types.js → assertion/index.types.js} +1 -1
  8. package/dist/assertion/index.types.js.map +1 -0
  9. package/dist/assets/.gitkeep +0 -0
  10. package/dist/config/common-config.d.ts +16 -0
  11. package/dist/config/common-config.js +81 -0
  12. package/dist/config/common-config.js.map +1 -0
  13. package/dist/config/index.d.ts +1 -0
  14. package/dist/config/index.js +18 -0
  15. package/dist/config/index.js.map +1 -0
  16. package/dist/config/index.types.d.ts +13 -0
  17. package/dist/{assertion/index-types.js → config/index.types.js} +1 -1
  18. package/dist/config/index.types.js.map +1 -0
  19. package/dist/deploy/common-deploy.d.ts +29 -0
  20. package/dist/deploy/common-deploy.js +106 -0
  21. package/dist/deploy/common-deploy.js.map +1 -0
  22. package/dist/deploy/index.d.ts +1 -0
  23. package/dist/deploy/index.js +18 -0
  24. package/dist/deploy/index.js.map +1 -0
  25. package/dist/deploy/index.types.d.ts +25 -0
  26. package/dist/{developer/index-types.js → deploy/index.types.js} +1 -1
  27. package/dist/deploy/index.types.js.map +1 -0
  28. package/dist/descriptor/common-descriptor.d.ts +17 -14
  29. package/dist/descriptor/common-descriptor.js +45 -20
  30. package/dist/descriptor/common-descriptor.js.map +1 -1
  31. package/dist/descriptor/index.d.ts +1 -1
  32. package/dist/descriptor/index.js +1 -1
  33. package/dist/descriptor/index.types.d.ts +23 -0
  34. package/dist/{error/index-types.js → descriptor/index.types.js} +1 -1
  35. package/dist/descriptor/index.types.js.map +1 -0
  36. package/dist/developer/common-developer.d.ts +13 -10
  37. package/dist/developer/common-developer.js +81 -102
  38. package/dist/developer/common-developer.js.map +1 -1
  39. package/dist/developer/index.d.ts +2 -1
  40. package/dist/developer/index.errors.d.ts +13 -0
  41. package/dist/developer/index.errors.js +24 -0
  42. package/dist/developer/index.errors.js.map +1 -0
  43. package/dist/developer/index.js +2 -1
  44. package/dist/developer/index.js.map +1 -1
  45. package/dist/developer/{index-types.d.ts → index.types.d.ts} +20 -12
  46. package/dist/developer/index.types.js +3 -0
  47. package/dist/developer/index.types.js.map +1 -0
  48. package/dist/error/common-error.d.ts +4 -3
  49. package/dist/error/common-error.js +17 -12
  50. package/dist/error/common-error.js.map +1 -1
  51. package/dist/error/index.d.ts +1 -1
  52. package/dist/error/index.js +1 -1
  53. package/dist/error/index.types.js +3 -0
  54. package/dist/error/index.types.js.map +1 -0
  55. package/dist/exception/exception.d.ts +3 -7
  56. package/dist/exception/exception.js +17 -34
  57. package/dist/exception/exception.js.map +1 -1
  58. package/dist/exception/index.d.ts +1 -1
  59. package/dist/exception/index.js +1 -1
  60. package/dist/exception/index.types.js +3 -0
  61. package/dist/exception/index.types.js.map +1 -0
  62. package/dist/exception/multiple-exception.d.ts +1 -1
  63. package/dist/fqn/common-fqn.d.ts +8 -8
  64. package/dist/fqn/common-fqn.js +23 -16
  65. package/dist/fqn/common-fqn.js.map +1 -1
  66. package/dist/fqn/index.d.ts +1 -1
  67. package/dist/fqn/index.js +1 -1
  68. package/dist/fqn/{index-types.d.ts → index.types.d.ts} +2 -2
  69. package/dist/fqn/index.types.js +3 -0
  70. package/dist/fqn/index.types.js.map +1 -0
  71. package/dist/hook/common-hook.d.ts +6 -13
  72. package/dist/hook/common-hook.js +18 -40
  73. package/dist/hook/common-hook.js.map +1 -1
  74. package/dist/hook/index.d.ts +1 -1
  75. package/dist/hook/index.js +1 -1
  76. package/dist/hook/{index-types.d.ts → index.types.d.ts} +6 -5
  77. package/dist/hook/index.types.js +3 -0
  78. package/dist/hook/index.types.js.map +1 -0
  79. package/dist/index.d.ts +12 -2
  80. package/dist/index.js +16 -5
  81. package/dist/index.js.map +1 -1
  82. package/dist/internal.d.ts +1 -3
  83. package/dist/internal.js +2 -4
  84. package/dist/internal.js.map +1 -1
  85. package/dist/is/common-is.d.ts +18 -4
  86. package/dist/is/common-is.js +53 -12
  87. package/dist/is/common-is.js.map +1 -1
  88. package/dist/is/index.d.ts +1 -1
  89. package/dist/is/index.js +1 -1
  90. package/dist/is/{index-types.d.ts → index.types.d.ts} +56 -5
  91. package/dist/is/index.types.js +3 -0
  92. package/dist/is/index.types.js.map +1 -0
  93. package/dist/leyyo/index.d.ts +1 -1
  94. package/dist/leyyo/index.js +1 -1
  95. package/dist/leyyo/{index-types.d.ts → index.types.d.ts} +13 -3
  96. package/dist/leyyo/index.types.js +3 -0
  97. package/dist/leyyo/index.types.js.map +1 -0
  98. package/dist/leyyo/leyyo-common-hook.js +7 -7
  99. package/dist/leyyo/leyyo-common-hook.js.map +1 -1
  100. package/dist/leyyo/leyyo.d.ts +14 -4
  101. package/dist/leyyo/leyyo.js +34 -19
  102. package/dist/leyyo/leyyo.js.map +1 -1
  103. package/dist/log/common-log.d.ts +6 -5
  104. package/dist/log/common-log.js +90 -22
  105. package/dist/log/common-log.js.map +1 -1
  106. package/dist/log/index.d.ts +1 -1
  107. package/dist/log/index.js +1 -1
  108. package/dist/log/{index-types.d.ts → index.types.d.ts} +18 -23
  109. package/dist/log/index.types.js +3 -0
  110. package/dist/log/index.types.js.map +1 -0
  111. package/dist/log/logger-instance.d.ts +11 -16
  112. package/dist/log/logger-instance.js +86 -50
  113. package/dist/log/logger-instance.js.map +1 -1
  114. package/dist/log/severity.d.ts +1 -1
  115. package/dist/log/severity.js +1 -1
  116. package/dist/log/severity.js.map +1 -1
  117. package/dist/mixin/common-mixin.d.ts +23 -0
  118. package/dist/mixin/common-mixin.js +165 -0
  119. package/dist/mixin/common-mixin.js.map +1 -0
  120. package/dist/mixin/index.d.ts +1 -0
  121. package/dist/mixin/index.js +18 -0
  122. package/dist/mixin/index.js.map +1 -0
  123. package/dist/mixin/index.types.d.ts +19 -0
  124. package/dist/mixin/index.types.js +3 -0
  125. package/dist/mixin/index.types.js.map +1 -0
  126. package/dist/name/common-name.d.ts +16 -0
  127. package/dist/name/common-name.js +82 -0
  128. package/dist/name/common-name.js.map +1 -0
  129. package/dist/name/index.d.ts +1 -0
  130. package/dist/name/index.js +18 -0
  131. package/dist/name/index.js.map +1 -0
  132. package/dist/name/index.types.d.ts +21 -0
  133. package/dist/name/index.types.js +3 -0
  134. package/dist/name/index.types.js.map +1 -0
  135. package/dist/repo/common-repo.d.ts +14 -11
  136. package/dist/repo/common-repo.js +64 -78
  137. package/dist/repo/common-repo.js.map +1 -1
  138. package/dist/repo/index.d.ts +1 -2
  139. package/dist/repo/index.js +1 -2
  140. package/dist/repo/index.js.map +1 -1
  141. package/dist/repo/{index-types.d.ts → index.types.d.ts} +27 -9
  142. package/dist/repo/index.types.js +3 -0
  143. package/dist/repo/index.types.js.map +1 -0
  144. package/dist/server.js +1 -1
  145. package/dist/server.js.map +1 -1
  146. package/dist/shared/index.d.ts +1 -1
  147. package/dist/shared/index.js +1 -1
  148. package/dist/shared/{index-types.d.ts → index.types.d.ts} +21 -9
  149. package/dist/shared/{index-types.js → index.types.js} +1 -1
  150. package/dist/shared/index.types.js.map +1 -0
  151. package/dist/system/common-system.d.ts +4 -3
  152. package/dist/system/common-system.js +10 -11
  153. package/dist/system/common-system.js.map +1 -1
  154. package/dist/system/index.d.ts +1 -3
  155. package/dist/system/index.js +1 -3
  156. package/dist/system/index.js.map +1 -1
  157. package/dist/system/index.types.js +3 -0
  158. package/dist/system/index.types.js.map +1 -0
  159. package/dist/test/common-test.d.ts +14 -0
  160. package/dist/test/common-test.js +48 -0
  161. package/dist/test/common-test.js.map +1 -0
  162. package/dist/test/index.d.ts +2 -0
  163. package/dist/test/index.js +19 -0
  164. package/dist/test/index.js.map +1 -0
  165. package/dist/test/index.types.d.ts +9 -0
  166. package/dist/test/index.types.js +3 -0
  167. package/dist/test/index.types.js.map +1 -0
  168. package/dist/test/tested.d.ts +1 -0
  169. package/dist/test/tested.js +9 -0
  170. package/dist/test/tested.js.map +1 -0
  171. package/dist/to/common-to.d.ts +55 -27
  172. package/dist/to/common-to.js +554 -381
  173. package/dist/to/common-to.js.map +1 -1
  174. package/dist/to/index.d.ts +1 -1
  175. package/dist/to/index.js +1 -1
  176. package/dist/to/index.types.d.ts +72 -0
  177. package/dist/to/index.types.js +3 -0
  178. package/dist/to/index.types.js.map +1 -0
  179. package/dist/to/list.d.ts +10 -0
  180. package/dist/to/list.js +18 -0
  181. package/dist/to/list.js.map +1 -1
  182. package/dist/wrapper/common-wrapper.d.ts +9 -9
  183. package/dist/wrapper/common-wrapper.js +11 -10
  184. package/dist/wrapper/common-wrapper.js.map +1 -1
  185. package/dist/wrapper/index.d.ts +1 -1
  186. package/dist/wrapper/index.js +1 -1
  187. package/dist/wrapper/{index-types.d.ts → index.types.d.ts} +6 -6
  188. package/dist/wrapper/index.types.js +3 -0
  189. package/dist/wrapper/index.types.js.map +1 -0
  190. package/dist/wrapper/wrap.d.ts +3 -3
  191. package/package.json +5 -2
  192. package/dist/assertion/index-types.d.ts +0 -465
  193. package/dist/assertion/index-types.js.map +0 -1
  194. package/dist/descriptor/index-types.d.ts +0 -21
  195. package/dist/descriptor/index-types.js.map +0 -1
  196. package/dist/developer/index-types.js.map +0 -1
  197. package/dist/error/index-types.js.map +0 -1
  198. package/dist/exception/index-types.js +0 -3
  199. package/dist/exception/index-types.js.map +0 -1
  200. package/dist/fqn/index-types.js +0 -3
  201. package/dist/fqn/index-types.js.map +0 -1
  202. package/dist/hook/index-types.js +0 -3
  203. package/dist/hook/index-types.js.map +0 -1
  204. package/dist/is/index-types.js +0 -3
  205. package/dist/is/index-types.js.map +0 -1
  206. package/dist/leyyo/index-types.js +0 -3
  207. package/dist/leyyo/index-types.js.map +0 -1
  208. package/dist/log/index-types.js +0 -3
  209. package/dist/log/index-types.js.map +0 -1
  210. package/dist/repo/index-types.js +0 -3
  211. package/dist/repo/index-types.js.map +0 -1
  212. package/dist/repo/repo-type.d.ts +0 -8
  213. package/dist/repo/repo-type.js +0 -8
  214. package/dist/repo/repo-type.js.map +0 -1
  215. package/dist/shared/index-types.js.map +0 -1
  216. package/dist/system/http-method.d.ts +0 -8
  217. package/dist/system/http-method.js +0 -8
  218. package/dist/system/http-method.js.map +0 -1
  219. package/dist/system/http-place.d.ts +0 -8
  220. package/dist/system/http-place.js +0 -8
  221. package/dist/system/http-place.js.map +0 -1
  222. package/dist/system/index-types.js +0 -3
  223. package/dist/system/index-types.js.map +0 -1
  224. package/dist/to/index-types.d.ts +0 -40
  225. package/dist/to/index-types.js +0 -3
  226. package/dist/to/index-types.js.map +0 -1
  227. package/dist/wrapper/index-types.js +0 -3
  228. package/dist/wrapper/index-types.js.map +0 -1
  229. /package/dist/error/{index-types.d.ts → index.types.d.ts} +0 -0
  230. /package/dist/exception/{index-types.d.ts → index.types.d.ts} +0 -0
  231. /package/dist/system/{index-types.d.ts → index.types.d.ts} +0 -0
@@ -2,12 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommonAssertion = void 0;
4
4
  const internal_1 = require("../internal");
5
- const to_1 = require("../to");
6
5
  // noinspection JSUnusedGlobalSymbols
7
6
  /** @inheritDoc */
8
7
  class CommonAssertion {
9
8
  // endregion properties
10
- constructor() {
9
+ constructor(lyy) {
10
+ this.lyy = lyy;
11
+ // region properties
11
12
  this._EMPTY = [null, undefined];
12
13
  }
13
14
  // region internal
@@ -17,158 +18,640 @@ class CommonAssertion {
17
18
  }
18
19
  else if (typeof opt === 'function') {
19
20
  try {
20
- return this._run(opt());
21
+ const values = opt();
22
+ if (Array.isArray(values)) {
23
+ let [pck, testCase, opt2] = values;
24
+ if (!opt2) {
25
+ opt2 = {};
26
+ }
27
+ opt2['message'] = this.lyy.test.code(pck, testCase);
28
+ return opt2;
29
+ }
30
+ else if (typeof values === 'string') {
31
+ return { issue: values };
32
+ }
33
+ else {
34
+ return (values && values.contructor === Object) ? values : {};
35
+ }
21
36
  }
22
37
  catch (e) {
23
- const key = `cv[${Date.now()}]`;
38
+ const now = Date.now();
24
39
  return {
25
- [key]: [e.message, e.name]
40
+ message: e.message,
41
+ [`e-${now}-name`]: e.name,
26
42
  };
27
43
  }
28
44
  }
29
45
  else {
30
- return opt;
46
+ return ((opt === null || opt === void 0 ? void 0 : opt.contructor) === Object) ? opt : {};
31
47
  }
32
48
  }
33
- // endregion internal
34
- // region types
35
- /** @inheritDoc */
36
- array(value, opt) {
49
+ _optional(value, fn) {
50
+ if (this._EMPTY.includes(value)) {
51
+ return;
52
+ }
53
+ fn();
54
+ }
55
+ _array(value, opt, issue, fn) {
37
56
  if (!Array.isArray(value)) {
38
- this.dev.invalid(this._run(opt), { issue: 'invalid.array', value, type: typeof value });
57
+ throw this.lyy.dev.invalidError(this._run(opt), { issue, reason: 'type', type: typeof value });
58
+ }
59
+ const arr = value;
60
+ if (arr.length < 1) {
61
+ throw this.lyy.dev.invalidError(this._run(opt), { issue, reason: 'size', size: 0 });
62
+ }
63
+ const wrongIndexes = arr.filter(item => !fn(item)).map((_v, index) => index);
64
+ if (wrongIndexes.length > 0) {
65
+ throw this.lyy.dev.invalidError(this._run(opt), { issue, reason: 'items', wrongIndexes });
39
66
  }
40
67
  }
41
- /** @inheritDoc */
42
- boolean(value, opt) {
43
- if (typeof value !== 'boolean') {
44
- this.dev.invalid(this._run(opt), { issue: 'invalid.boolean', value, type: typeof value });
68
+ _is(value, opt, issue, fn, extra) {
69
+ if (!fn(value)) {
70
+ throw this.lyy.dev.invalidError(this._run(opt), Object.assign({ issue, value, type: typeof value }, extra));
45
71
  }
46
72
  }
73
+ _replaceMethod(method) {
74
+ if (method.endsWith('?')) {
75
+ method = method.slice(0, -1) + 'Optional';
76
+ }
77
+ else if (method.endsWith('[]')) {
78
+ method = method.slice(0, -2) + 'Array';
79
+ }
80
+ return method;
81
+ }
82
+ _execLambda(value, method, opt, isDual, throwable, another) {
83
+ if (typeof method !== 'string') {
84
+ if (throwable) {
85
+ throw this.lyy.dev.invalidError(this._run(opt), { issue: 'invalid.method.name', value: method });
86
+ }
87
+ return 'invalid.method.name';
88
+ }
89
+ method = this._replaceMethod(method);
90
+ const fn = this[method];
91
+ if (typeof fn !== 'function') {
92
+ if (throwable) {
93
+ throw this.lyy.dev.invalidError(this._run(opt), { issue: 'unknown.assertion.method', value: method });
94
+ }
95
+ return 'unknown.assertion.method';
96
+ }
97
+ try {
98
+ if (isDual) {
99
+ fn(value, another, opt);
100
+ }
101
+ else {
102
+ fn(value, opt);
103
+ }
104
+ }
105
+ catch (e) {
106
+ if (throwable) {
107
+ throw e;
108
+ }
109
+ return e.message;
110
+ }
111
+ return undefined;
112
+ }
113
+ _isTupleReason(value, setting) {
114
+ if (!Array.isArray(setting)) {
115
+ return 'invalid.tuple.setting';
116
+ }
117
+ if (!Array.isArray(value)) {
118
+ return 'tuple.should.be.array';
119
+ }
120
+ const arr = value;
121
+ if (arr.length < 1) {
122
+ return 'tuple.empty.array';
123
+ }
124
+ if (arr.length !== setting.length) {
125
+ return 'tuple.size.conflict';
126
+ }
127
+ let index = -1;
128
+ for (const set of setting) {
129
+ index++;
130
+ let method;
131
+ let another;
132
+ let isDual;
133
+ if (Array.isArray(set)) {
134
+ if (set[0] === 'or') {
135
+ const orCase = set;
136
+ if (!this._isOrCase(arr[index], orCase[1])) {
137
+ return 'invalid-or-case';
138
+ }
139
+ break;
140
+ }
141
+ const dualCase = set;
142
+ method = dualCase[0];
143
+ another = dualCase[1];
144
+ isDual = true;
145
+ if (another === undefined) {
146
+ return 'invalid.tuple.setting';
147
+ }
148
+ }
149
+ else if (typeof set === 'string') {
150
+ method = set;
151
+ }
152
+ const issue = this._execLambda(arr[index], method, {}, isDual, false, another);
153
+ if (issue) {
154
+ return issue;
155
+ }
156
+ }
157
+ return undefined;
158
+ }
159
+ _isTuple(value, setting) {
160
+ return !this._isTupleReason(value, setting);
161
+ }
162
+ _isOrCase(value, types) {
163
+ for (const type of types) {
164
+ let method;
165
+ let another;
166
+ let isDual;
167
+ if (typeof type === 'string') {
168
+ method = type;
169
+ }
170
+ else if (Array.isArray(type) && type.length === 2) {
171
+ method = type[0];
172
+ another = type[1];
173
+ isDual = true;
174
+ }
175
+ const issue = this._execLambda(value, method, {}, isDual, false, another);
176
+ if (!issue) {
177
+ return true;
178
+ }
179
+ }
180
+ return false;
181
+ }
182
+ // endregion internal
183
+ // region general
47
184
  /** @inheritDoc */
48
- clazz(value, opt) {
49
- switch (typeof value) {
50
- case "function":
51
- return;
52
- case "object":
53
- if (!value) {
54
- return;
185
+ notEmpty(value, opt) {
186
+ if (this._EMPTY.includes(value)) {
187
+ throw this.lyy.dev.invalidError(this._run(opt), { issue: 'empty', value, type: typeof value });
188
+ }
189
+ return value;
190
+ }
191
+ // endregion general
192
+ // region or
193
+ orCase(value, types, opt) {
194
+ let firstError;
195
+ for (const type of types) {
196
+ let method;
197
+ let another;
198
+ let isDual;
199
+ let errorOccurred;
200
+ if (Array.isArray(type)) {
201
+ const dualCase = type;
202
+ method = dualCase[0];
203
+ another = dualCase[1];
204
+ isDual = true;
205
+ if (another === undefined) {
206
+ if (!firstError) {
207
+ firstError = this.lyy.dev.invalidError(this._run(opt), { issue: 'invalid.tuple.setting', value: method });
208
+ }
209
+ errorOccurred = true;
55
210
  }
56
- break;
57
- case "string":
58
- if (value.trim() !== '') {
211
+ }
212
+ else if (typeof type === 'string') {
213
+ method = type;
214
+ }
215
+ if (!errorOccurred) {
216
+ const issue = this._execLambda(value, method, opt, isDual, false, another);
217
+ if (!issue) {
59
218
  return;
60
219
  }
61
- break;
220
+ if (!firstError) {
221
+ firstError = this.lyy.dev.invalidError(this._run(opt), { issue, value: method });
222
+ }
223
+ }
224
+ }
225
+ if (firstError) {
226
+ throw firstError;
62
227
  }
63
- this.dev.invalid(this._run(opt), { issue: 'invalid.class', value, type: typeof value });
64
228
  }
65
229
  /** @inheritDoc */
66
- date(value, opt) {
67
- if (!(value instanceof Date)) {
68
- this.dev.invalid(this._run(opt), { issue: 'invalid.date', value, type: typeof value });
69
- }
230
+ orCaseOptional(value, types, opt) {
231
+ this._optional(value, () => this.orCase(value, types, opt));
70
232
  }
71
233
  /** @inheritDoc */
72
- func(value, opt) {
73
- if (typeof value !== 'function') {
74
- this.dev.invalid(this._run(opt), { issue: 'invalid.function', value, type: typeof value });
75
- }
234
+ orCaseArray(value, types, opt) {
235
+ this._array(value, opt, 'invalid.orCase.array', (v) => this._isOrCase(v, types));
76
236
  }
237
+ // endregion or
238
+ // region realValue
77
239
  /** @inheritDoc */
78
- sym(value, opt) {
79
- if (typeof value !== 'symbol') {
80
- this.dev.invalid(this._run(opt), { issue: 'invalid.symbol', value, type: typeof value });
81
- }
240
+ realValue(value, opt) {
241
+ this._is(value, opt, 'invalid.realValue', v => this.lyy.is.realValue(v), {});
82
242
  }
83
243
  /** @inheritDoc */
84
- integer(value, opt) {
85
- if (!Number.isInteger(value)) {
86
- this.dev.invalid(this._run(opt), { issue: 'invalid.integer', value, type: typeof value });
244
+ realValueOptional(value, opt) {
245
+ this._optional(value, () => this.realValue(value, opt));
246
+ }
247
+ /** @inheritDoc */
248
+ realValueArray(value, opt) {
249
+ this._array(value, opt, 'invalid.realValue.array', (v) => this.lyy.is.realValue(v));
250
+ }
251
+ // endregion realValue
252
+ // region object
253
+ /** @inheritDoc */
254
+ object(value, opt) {
255
+ this._is(value, opt, 'invalid.object', v => this.lyy.is.object(v), {});
256
+ }
257
+ /** @inheritDoc */
258
+ objectOptional(value, opt) {
259
+ this._optional(value, () => this.object(value, opt));
260
+ }
261
+ objectArray(value, opt) {
262
+ this._array(value, opt, 'invalid.object.array', (v) => this.lyy.is.object(v));
263
+ }
264
+ // endregion object
265
+ // region bareObject
266
+ /** @inheritDoc */
267
+ bareObject(value, opt) {
268
+ this._is(value, opt, 'invalid.bareObject', v => this.lyy.is.bareObject(v), {});
269
+ }
270
+ /** @inheritDoc */
271
+ bareObjectOptional(value, opt) {
272
+ this._optional(value, () => this.bareObject(value, opt));
273
+ }
274
+ bareObjectArray(value, opt) {
275
+ this._array(value, opt, 'invalid.bareObject.array', (v) => this.lyy.is.bareObject(v));
276
+ }
277
+ // endregion bareObject
278
+ // region anotherObject
279
+ /** @inheritDoc */
280
+ anotherObject(value, opt) {
281
+ this._is(value, opt, 'invalid.anotherObject', v => this.lyy.is.anotherObject(v), {});
282
+ }
283
+ /** @inheritDoc */
284
+ anotherObjectOptional(value, opt) {
285
+ this._optional(value, () => this.anotherObject(value, opt));
286
+ }
287
+ /** @inheritDoc */
288
+ anotherObjectArray(value, opt) {
289
+ this._array(value, opt, 'invalid.anotherObject.array', (v) => this.lyy.is.anotherObject(v));
290
+ }
291
+ // endregion anotherObject
292
+ // region array
293
+ /** @inheritDoc */
294
+ array(value, opt) {
295
+ this._is(value, opt, 'invalid.array', v => Array.isArray(v) && v.length > 0, {});
296
+ }
297
+ /** @inheritDoc */
298
+ arrayOptional(value, opt) {
299
+ this._optional(value, () => this.array(value, opt));
300
+ }
301
+ /** @inheritDoc */
302
+ arrayArray(value, opt) {
303
+ this._array(value, opt, 'invalid.array.array', (v) => Array.isArray(v));
304
+ }
305
+ // endregion array
306
+ // region instanceOf
307
+ /** @inheritDoc */
308
+ instanceOf(value, clazz, opt) {
309
+ this._is(value, opt, 'invalid.instanceOf', v => this.lyy.is.instanceOf(v, clazz), { clazz });
310
+ }
311
+ /** @inheritDoc */
312
+ instanceOfOptional(value, clazz, opt) {
313
+ this._optional(value, () => this.instanceOf(value, clazz, opt));
314
+ }
315
+ /** @inheritDoc */
316
+ instanceOfArray(value, clazz, opt) {
317
+ this._array(value, opt, 'invalid.instanceOf.array', (v) => this.lyy.is.instanceOf(v, clazz));
318
+ }
319
+ // endregion instanceOf
320
+ // region tuple
321
+ /** @inheritDoc */
322
+ tuple(value, setting, opt) {
323
+ if (!Array.isArray(setting)) {
324
+ throw this.lyy.dev.invalidError(this._run(opt), {
325
+ issue: 'invalid.tuple.setting',
326
+ value: setting,
327
+ type: typeof setting
328
+ });
329
+ }
330
+ if (!Array.isArray(value)) {
331
+ throw this.lyy.dev.invalidError(this._run(opt), {
332
+ issue: 'tuple.should.be.array',
333
+ value: setting,
334
+ type: typeof setting
335
+ });
336
+ }
337
+ const arr = value;
338
+ if (arr.length !== setting.length) {
339
+ throw this.lyy.dev.invalidError(this._run(opt), {
340
+ issue: 'tuple.size.conflict',
341
+ value: arr.length,
342
+ setting: setting.length
343
+ });
87
344
  }
345
+ setting.forEach((set, index) => {
346
+ let method;
347
+ let another;
348
+ let isDual;
349
+ if (Array.isArray(set)) {
350
+ if (set[0] === 'or') {
351
+ const orCase = set;
352
+ this.orCase(arr[index], orCase[1], opt);
353
+ return;
354
+ }
355
+ const dualCase = set;
356
+ method = dualCase[0];
357
+ another = dualCase[1];
358
+ isDual = true;
359
+ if (another === undefined) {
360
+ throw this.lyy.dev.invalidError(this._run(opt), {
361
+ issue: 'invalid.tuple.setting',
362
+ index,
363
+ value: setting,
364
+ type: typeof setting
365
+ });
366
+ }
367
+ }
368
+ else if (typeof set === 'string') {
369
+ method = set;
370
+ }
371
+ this._execLambda(arr[index], method, opt, isDual, true, another);
372
+ });
373
+ }
374
+ /** @inheritDoc */
375
+ tupleOptional(value, setting, opt) {
376
+ this._optional(value, () => this.tuple(value, setting, opt));
377
+ }
378
+ /** @inheritDoc */
379
+ tupleArray(value, setting, opt) {
380
+ this._array(value, opt, 'invalid.tuple.array', (v) => this._isTuple(v, setting));
381
+ }
382
+ // endregion tuple
383
+ // region primitive
384
+ /** @inheritDoc */
385
+ primitive(value, opt) {
386
+ this._is(value, opt, 'invalid.primitive', v => this.lyy.is.primitive(v), {});
387
+ }
388
+ /** @inheritDoc */
389
+ primitiveOptional(value, opt) {
390
+ this._optional(value, () => this.primitive(value, opt));
391
+ }
392
+ /** @inheritDoc */
393
+ primitiveArray(value, opt) {
394
+ this._array(value, opt, 'invalid.primitive.array', (v) => this.lyy.is.primitive(v));
88
395
  }
396
+ // endregion primitive
397
+ // region key
89
398
  /** @inheritDoc */
90
399
  key(value, opt) {
91
- if (!['string', 'number'].includes(typeof value)) {
92
- this.dev.invalid(this._run(opt), { issue: 'invalid.key', value, type: typeof value });
93
- }
400
+ this._is(value, opt, 'invalid.key', v => this.lyy.is.key(v), {});
94
401
  }
95
402
  /** @inheritDoc */
96
- notEmpty(value, opt) {
97
- if (this._EMPTY.includes(value)) {
98
- this.dev.invalid(this._run(opt), { issue: 'empty', value, type: typeof value });
99
- }
403
+ keyOptional(value, opt) {
404
+ this._optional(value, () => this.key(value, opt));
405
+ }
406
+ /** @inheritDoc */
407
+ keyArray(value, opt) {
408
+ this._array(value, opt, 'invalid.key.array', (v) => this.lyy.is.key(v));
409
+ }
410
+ // endregion key
411
+ // region arrayLike
412
+ /** @inheritDoc */
413
+ arrayLike(value, opt) {
414
+ this._is(value, opt, 'invalid.arrayLike', v => this.lyy.is.arrayLike(v), {});
415
+ }
416
+ /** @inheritDoc */
417
+ arrayLikeOptional(value, opt) {
418
+ this._optional(value, () => this.arrayLike(value, opt));
419
+ }
420
+ /** @inheritDoc */
421
+ arrayLikeArray(value, opt) {
422
+ this._array(value, opt, 'invalid.arrayLike.array', (v) => this.lyy.is.arrayLike(v));
423
+ }
424
+ // endregion arrayLike
425
+ // region function
426
+ /** @inheritDoc */
427
+ func(value, opt) {
428
+ this._is(value, opt, 'invalid.function', v => this.lyy.is.func(v), {});
429
+ }
430
+ /** @inheritDoc */
431
+ funcOptional(value, opt) {
432
+ this._optional(value, () => this.func(value, opt));
433
+ }
434
+ /** @inheritDoc */
435
+ funcArray(value, opt) {
436
+ this._array(value, opt, 'invalid.function.array', (v) => this.lyy.is.func(v));
437
+ }
438
+ // endregion function
439
+ // region symbol
440
+ /** @inheritDoc */
441
+ sym(value, opt) {
442
+ this._is(value, opt, 'invalid.symbol', v => this.lyy.is.sym(v), {});
443
+ }
444
+ /** @inheritDoc */
445
+ symOptional(value, opt) {
446
+ this._optional(value, () => this.sym(value, opt));
100
447
  }
101
448
  /** @inheritDoc */
449
+ symArray(value, opt) {
450
+ this._array(value, opt, 'invalid.symbol.array', (v) => this.lyy.is.sym(v));
451
+ }
452
+ // endregion symbol
453
+ // region number
454
+ /** @inheritDoc */
102
455
  number(value, opt) {
103
- if (typeof value !== 'number') {
104
- this.dev.invalid(this._run(opt), { issue: 'invalid.number', value, type: typeof value });
105
- }
456
+ this._is(value, opt, 'invalid.number', v => this.lyy.is.number(v), {});
106
457
  }
107
458
  /** @inheritDoc */
108
- object(value, opt) {
109
- if (!value || typeof value !== 'object' && !Array.isArray(value)) {
110
- this.dev.invalid(this._run(opt), { issue: 'invalid.object', value, type: typeof value });
111
- }
459
+ numberOptional(value, opt) {
460
+ this._optional(value, () => this.number(value, opt));
112
461
  }
113
462
  /** @inheritDoc */
114
- bareObject(value, opt) {
115
- if (!value || typeof value !== 'object' && value.constructor !== Object) {
116
- this.dev.invalid(this._run(opt), { issue: 'invalid.bare.object', value, type: typeof value });
117
- }
463
+ numberArray(value, opt) {
464
+ this._array(value, opt, 'invalid.number.array', (v) => this.lyy.is.number(v));
118
465
  }
466
+ // endregion number
467
+ // region positiveNumber
119
468
  /** @inheritDoc */
120
- positiveInteger(value, opt) {
121
- if (!Number.isInteger(value) || (value <= 0)) {
122
- this.dev.invalid(this._run(opt), { issue: 'invalid.positive.integer', value, type: typeof value });
123
- }
469
+ positiveNumber(value, opt) {
470
+ this._is(value, opt, 'invalid.positiveNumber', v => this.lyy.is.positiveNumber(v), {});
471
+ }
472
+ /** @inheritDoc */
473
+ positiveNumberOptional(value, opt) {
474
+ this._optional(value, () => this.positiveNumber(value, opt));
475
+ }
476
+ /** @inheritDoc */
477
+ positiveNumberArray(value, opt) {
478
+ this._array(value, opt, 'invalid.positiveNumber.array', (v) => this.lyy.is.positiveNumber(v));
124
479
  }
480
+ // endregion positiveNumber
481
+ // region nonNegativeNumber
482
+ /** @inheritDoc */
483
+ nonNegativeNumber(value, opt) {
484
+ this._is(value, opt, 'invalid.nonNegativeNumber', v => this.lyy.is.nonNegativeNumber(v), {});
485
+ }
486
+ /** @inheritDoc */
487
+ nonNegativeNumberOptional(value, opt) {
488
+ this._optional(value, () => this.nonNegativeNumber(value, opt));
489
+ }
490
+ /** @inheritDoc */
491
+ nonNegativeNumberArray(value, opt) {
492
+ this._array(value, opt, 'invalid.nonNegativeNumber.array', (v) => this.lyy.is.nonNegativeNumber(v));
493
+ }
494
+ // endregion nonNegativeNumber
495
+ // region integer
496
+ /** @inheritDoc */
497
+ integer(value, opt) {
498
+ this._is(value, opt, 'invalid.integer', v => this.lyy.is.integer(v), {});
499
+ }
500
+ /** @inheritDoc */
501
+ integerOptional(value, opt) {
502
+ this._optional(value, () => this.integer(value, opt));
503
+ }
504
+ /** @inheritDoc */
505
+ integerArray(value, opt) {
506
+ this._array(value, opt, 'invalid.integer.array', (v) => this.lyy.is.integer(v));
507
+ }
508
+ // endregion integer
509
+ // region safeInteger
125
510
  /** @inheritDoc */
126
511
  safeInteger(value, opt) {
127
- if (!Number.isSafeInteger(value)) {
128
- this.dev.invalid(this._run(opt), { issue: 'invalid.safe.integer', value, type: typeof value });
129
- }
512
+ this._is(value, opt, 'invalid.safeInteger', v => this.lyy.is.safeInteger(v), {});
130
513
  }
131
514
  /** @inheritDoc */
132
- positiveNumber(value, opt) {
133
- if (typeof value !== 'number' || (value <= 0)) {
134
- this.dev.invalid(this._run(opt), { issue: 'invalid.positive', value, type: typeof value });
135
- }
515
+ safeIntegerOptional(value, opt) {
516
+ this._optional(value, () => this.safeInteger(value, opt));
136
517
  }
137
518
  /** @inheritDoc */
138
- primitive(value, opt) {
139
- if (!to_1.PrimitiveItems.includes(typeof value)) {
140
- this.dev.invalid(this._run(opt), { issue: 'invalid.primitive', value, type: typeof value });
141
- }
519
+ safeIntegerArray(value, opt) {
520
+ this._array(value, opt, 'invalid.safeInteger.array', (v) => this.lyy.is.safeInteger(v));
521
+ }
522
+ // endregion safeInteger
523
+ // region positiveInteger
524
+ /** @inheritDoc */
525
+ positiveInteger(value, opt) {
526
+ this._is(value, opt, 'invalid.positiveInteger', v => this.lyy.is.positiveInteger(v), {});
527
+ }
528
+ /** @inheritDoc */
529
+ positiveIntegerOptional(value, opt) {
530
+ this._optional(value, () => this.positiveInteger(value, opt));
531
+ }
532
+ /** @inheritDoc */
533
+ positiveIntegerArray(value, opt) {
534
+ this._array(value, opt, 'invalid.positiveInteger.array', (v) => this.lyy.is.positiveInteger(v));
535
+ }
536
+ // endregion positiveInteger
537
+ // region nonNegativeInteger
538
+ nonNegativeInteger(value, opt) {
539
+ this._is(value, opt, 'invalid.nonNegativeInteger', v => this.lyy.is.nonNegativeInteger(v), {});
540
+ }
541
+ nonNegativeIntegerArray(value, opt) {
542
+ this._optional(value, () => this.nonNegativeInteger(value, opt));
543
+ }
544
+ nonNegativeIntegerOptional(value, opt) {
545
+ this._array(value, opt, 'invalid.nonNegativeInteger.array', (v) => this.lyy.is.nonNegativeInteger(v));
142
546
  }
547
+ // endregion nonNegativeInteger
548
+ // region string
143
549
  /** @inheritDoc */
144
550
  string(value, opt) {
145
- if (typeof value !== 'string') {
146
- this.dev.invalid(this._run(opt), { issue: 'invalid.string', value, type: typeof value });
147
- }
551
+ this._is(value, opt, 'invalid.string', v => this.lyy.is.string(v), {});
552
+ }
553
+ /** @inheritDoc */
554
+ stringOptional(value, opt) {
555
+ this._optional(value, () => this.string(value, opt));
148
556
  }
149
557
  /** @inheritDoc */
558
+ stringArray(value, opt) {
559
+ this._array(value, opt, 'invalid.string.array', (v) => this.lyy.is.string(v));
560
+ }
561
+ // endregion string
562
+ // region text
563
+ /** @inheritDoc */
150
564
  text(value, opt) {
151
- if (typeof value !== 'string' || value.trim() === '') {
152
- this.dev.invalid(this._run(opt), { issue: 'invalid.text', value, type: typeof value });
153
- }
565
+ this._is(value, opt, 'invalid.text', v => this.lyy.is.text(v), {});
154
566
  }
155
567
  /** @inheritDoc */
156
- realValue(value, opt) {
157
- if (!to_1.RealValueItems.includes(typeof value)) {
158
- this.dev.invalid(this._run(opt), { issue: 'invalid.real.value', value, type: typeof value });
159
- }
568
+ textOptional(value, opt) {
569
+ this._optional(value, () => this.text(value, opt));
570
+ }
571
+ /** @inheritDoc */
572
+ textArray(value, opt) {
573
+ this._array(value, opt, 'invalid.text.array', (v) => this.lyy.is.text(v));
574
+ }
575
+ // endregion text
576
+ // region clazz
577
+ /** @inheritDoc */
578
+ clazz(value, opt) {
579
+ this._is(value, opt, 'invalid.class', v => this.lyy.is.clazz(v), {});
580
+ }
581
+ /** @inheritDoc */
582
+ clazzOptional(value, opt) {
583
+ this._optional(value, () => this.clazz(value, opt));
584
+ }
585
+ /** @inheritDoc */
586
+ clazzArray(value, opt) {
587
+ this._array(value, opt, 'invalid.clazz.array', (v) => this.lyy.is.clazz(v));
588
+ }
589
+ // endregion clazz
590
+ // region possibleFunc
591
+ /** @inheritDoc */
592
+ possibleFunc(value, opt) {
593
+ this._is(value, opt, 'invalid.possibleFunc', v => this.lyy.is.possibleFunc(v), {});
594
+ }
595
+ /** @inheritDoc */
596
+ possibleFuncOptional(value, opt) {
597
+ this._optional(value, () => this.possibleFunc(value, opt));
598
+ }
599
+ /** @inheritDoc */
600
+ possibleFuncArray(value, opt) {
601
+ this._array(value, opt, 'invalid.possibleFunc.array', (v) => this.lyy.is.possibleFunc(v));
602
+ }
603
+ // endregion possibleFunc
604
+ // region boolean
605
+ /** @inheritDoc */
606
+ boolean(value, opt) {
607
+ this._is(value, opt, 'invalid.boolean', v => this.lyy.is.boolean(v), {});
608
+ }
609
+ /** @inheritDoc */
610
+ booleanOptional(value, opt) {
611
+ this._optional(value, () => this.boolean(value, opt));
612
+ }
613
+ /** @inheritDoc */
614
+ booleanArray(value, opt) {
615
+ this._array(value, opt, 'invalid.boolean.array', (v) => this.lyy.is.boolean(v));
616
+ }
617
+ // endregion boolean
618
+ // region enum
619
+ /** @inheritDoc */
620
+ enum(value, map, opt) {
621
+ this._is(value, opt, 'invalid.enum', v => this.lyy.is.enumeration(v, map), {});
622
+ }
623
+ /** @inheritDoc */
624
+ enumOptional(value, map, opt) {
625
+ this._optional(value, () => this.enum(value, map, opt));
626
+ }
627
+ /** @inheritDoc */
628
+ enumArray(value, map, opt) {
629
+ this._array(value, opt, 'invalid.enum.array', (v) => this.lyy.is.enumeration(v, map));
630
+ }
631
+ // endregion enum
632
+ // region literal
633
+ /** @inheritDoc */
634
+ literal(value, items, opt) {
635
+ this._is(value, opt, 'invalid.literal', v => this.lyy.is.literal(v, items), {});
636
+ }
637
+ /** @inheritDoc */
638
+ literalOptional(value, items, opt) {
639
+ this._optional(value, () => this.literal(value, items, opt));
640
+ }
641
+ /** @inheritDoc */
642
+ literalArray(value, items, opt) {
643
+ this._array(value, opt, 'invalid.literal.array', (v) => this.lyy.is.literal(v, items));
160
644
  }
161
- // endregion types
645
+ // endregion literal
162
646
  // region secure
163
647
  /** @inheritDoc */
164
648
  get $back() {
165
649
  return this;
166
650
  }
167
651
  /** @inheritDoc */
168
- $init(leyyo) {
169
- this.dev = leyyo.dev;
170
- leyyo.$secure.$lazyRun(() => {
171
- leyyo.fqn.register(null, CommonAssertion, 'class', internal_1.FQN_PCK);
652
+ $init() {
653
+ this.lyy.$secure.$lazyRun(() => {
654
+ this.lyy.fqn.register(null, CommonAssertion, 'class', internal_1.FQN);
172
655
  });
173
656
  }
174
657
  /** @inheritDoc */