@palmares/schemas 0.0.1

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 (219) hide show
  1. package/.turbo/turbo-build$colon$watch.log +424 -0
  2. package/.turbo/turbo-build.log +13 -0
  3. package/.turbo/turbo-build:watch.log +26 -0
  4. package/CHANGELOG.md +11 -0
  5. package/LICENSE +21 -0
  6. package/dist/cjs/src/adapter/fields/array.js +157 -0
  7. package/dist/cjs/src/adapter/fields/boolean.js +167 -0
  8. package/dist/cjs/src/adapter/fields/datetime.js +167 -0
  9. package/dist/cjs/src/adapter/fields/index.js +311 -0
  10. package/dist/cjs/src/adapter/fields/number.js +167 -0
  11. package/dist/cjs/src/adapter/fields/object.js +167 -0
  12. package/dist/cjs/src/adapter/fields/string.js +167 -0
  13. package/dist/cjs/src/adapter/fields/union.js +167 -0
  14. package/dist/cjs/src/adapter/index.js +198 -0
  15. package/dist/cjs/src/adapter/types.js +4 -0
  16. package/dist/cjs/src/compile.js +262 -0
  17. package/dist/cjs/src/conf.js +27 -0
  18. package/dist/cjs/src/constants.js +42 -0
  19. package/dist/cjs/src/domain.js +12 -0
  20. package/dist/cjs/src/exceptions.js +168 -0
  21. package/dist/cjs/src/index.js +365 -0
  22. package/dist/cjs/src/model.js +628 -0
  23. package/dist/cjs/src/parsers/convert-from-number.js +20 -0
  24. package/dist/cjs/src/parsers/convert-from-string.js +24 -0
  25. package/dist/cjs/src/parsers/index.js +25 -0
  26. package/dist/cjs/src/schema/array.js +890 -0
  27. package/dist/cjs/src/schema/boolean.js +826 -0
  28. package/dist/cjs/src/schema/datetime.js +778 -0
  29. package/dist/cjs/src/schema/index.js +17 -0
  30. package/dist/cjs/src/schema/number.js +960 -0
  31. package/dist/cjs/src/schema/object.js +999 -0
  32. package/dist/cjs/src/schema/schema.js +1788 -0
  33. package/dist/cjs/src/schema/string.js +948 -0
  34. package/dist/cjs/src/schema/types.js +4 -0
  35. package/dist/cjs/src/schema/union.js +952 -0
  36. package/dist/cjs/src/types.js +4 -0
  37. package/dist/cjs/src/utils.js +627 -0
  38. package/dist/cjs/src/validators/array.js +457 -0
  39. package/dist/cjs/src/validators/boolean.js +199 -0
  40. package/dist/cjs/src/validators/datetime.js +287 -0
  41. package/dist/cjs/src/validators/number.js +403 -0
  42. package/dist/cjs/src/validators/object.js +290 -0
  43. package/dist/cjs/src/validators/schema.js +318 -0
  44. package/dist/cjs/src/validators/string.js +439 -0
  45. package/dist/cjs/src/validators/types.js +4 -0
  46. package/dist/cjs/src/validators/union.js +232 -0
  47. package/dist/cjs/src/validators/utils.js +426 -0
  48. package/dist/cjs/tsconfig.types.tsbuildinfo +1 -0
  49. package/dist/cjs/types/adapter/fields/array.d.ts +20 -0
  50. package/dist/cjs/types/adapter/fields/array.d.ts.map +1 -0
  51. package/dist/cjs/types/adapter/fields/boolean.d.ts +25 -0
  52. package/dist/cjs/types/adapter/fields/boolean.d.ts.map +1 -0
  53. package/dist/cjs/types/adapter/fields/datetime.d.ts +25 -0
  54. package/dist/cjs/types/adapter/fields/datetime.d.ts.map +1 -0
  55. package/dist/cjs/types/adapter/fields/index.d.ts +31 -0
  56. package/dist/cjs/types/adapter/fields/index.d.ts.map +1 -0
  57. package/dist/cjs/types/adapter/fields/number.d.ts +25 -0
  58. package/dist/cjs/types/adapter/fields/number.d.ts.map +1 -0
  59. package/dist/cjs/types/adapter/fields/object.d.ts +25 -0
  60. package/dist/cjs/types/adapter/fields/object.d.ts.map +1 -0
  61. package/dist/cjs/types/adapter/fields/string.d.ts +25 -0
  62. package/dist/cjs/types/adapter/fields/string.d.ts.map +1 -0
  63. package/dist/cjs/types/adapter/fields/union.d.ts +25 -0
  64. package/dist/cjs/types/adapter/fields/union.d.ts.map +1 -0
  65. package/dist/cjs/types/adapter/index.d.ts +25 -0
  66. package/dist/cjs/types/adapter/index.d.ts.map +1 -0
  67. package/dist/cjs/types/adapter/types.d.ts +144 -0
  68. package/dist/cjs/types/adapter/types.d.ts.map +1 -0
  69. package/dist/cjs/types/compile.d.ts +3 -0
  70. package/dist/cjs/types/compile.d.ts.map +1 -0
  71. package/dist/cjs/types/conf.d.ts +16 -0
  72. package/dist/cjs/types/conf.d.ts.map +1 -0
  73. package/dist/cjs/types/constants.d.ts +6 -0
  74. package/dist/cjs/types/constants.d.ts.map +1 -0
  75. package/dist/cjs/types/domain.d.ts +21 -0
  76. package/dist/cjs/types/domain.d.ts.map +1 -0
  77. package/dist/cjs/types/exceptions.d.ts +13 -0
  78. package/dist/cjs/types/exceptions.d.ts.map +1 -0
  79. package/dist/cjs/types/index.d.ts +240 -0
  80. package/dist/cjs/types/index.d.ts.map +1 -0
  81. package/dist/cjs/types/model.d.ts +136 -0
  82. package/dist/cjs/types/model.d.ts.map +1 -0
  83. package/dist/cjs/types/parsers/convert-from-number.d.ts +15 -0
  84. package/dist/cjs/types/parsers/convert-from-number.d.ts.map +1 -0
  85. package/dist/cjs/types/parsers/convert-from-string.d.ts +9 -0
  86. package/dist/cjs/types/parsers/convert-from-string.d.ts.map +1 -0
  87. package/dist/cjs/types/parsers/index.d.ts +3 -0
  88. package/dist/cjs/types/parsers/index.d.ts.map +1 -0
  89. package/dist/cjs/types/schema/array.d.ts +429 -0
  90. package/dist/cjs/types/schema/array.d.ts.map +1 -0
  91. package/dist/cjs/types/schema/boolean.d.ts +501 -0
  92. package/dist/cjs/types/schema/boolean.d.ts.map +1 -0
  93. package/dist/cjs/types/schema/datetime.d.ts +474 -0
  94. package/dist/cjs/types/schema/datetime.d.ts.map +1 -0
  95. package/dist/cjs/types/schema/index.d.ts +4 -0
  96. package/dist/cjs/types/schema/index.d.ts.map +1 -0
  97. package/dist/cjs/types/schema/number.d.ts +667 -0
  98. package/dist/cjs/types/schema/number.d.ts.map +1 -0
  99. package/dist/cjs/types/schema/object.d.ts +450 -0
  100. package/dist/cjs/types/schema/object.d.ts.map +1 -0
  101. package/dist/cjs/types/schema/schema.d.ts +646 -0
  102. package/dist/cjs/types/schema/schema.d.ts.map +1 -0
  103. package/dist/cjs/types/schema/string.d.ts +606 -0
  104. package/dist/cjs/types/schema/string.d.ts.map +1 -0
  105. package/dist/cjs/types/schema/types.d.ts +70 -0
  106. package/dist/cjs/types/schema/types.d.ts.map +1 -0
  107. package/dist/cjs/types/schema/union.d.ts +388 -0
  108. package/dist/cjs/types/schema/union.d.ts.map +1 -0
  109. package/dist/cjs/types/types.d.ts +11 -0
  110. package/dist/cjs/types/types.d.ts.map +1 -0
  111. package/dist/cjs/types/utils.d.ts +79 -0
  112. package/dist/cjs/types/utils.d.ts.map +1 -0
  113. package/dist/cjs/types/validators/array.d.ts +8 -0
  114. package/dist/cjs/types/validators/array.d.ts.map +1 -0
  115. package/dist/cjs/types/validators/boolean.d.ts +4 -0
  116. package/dist/cjs/types/validators/boolean.d.ts.map +1 -0
  117. package/dist/cjs/types/validators/datetime.d.ts +7 -0
  118. package/dist/cjs/types/validators/datetime.d.ts.map +1 -0
  119. package/dist/cjs/types/validators/number.d.ts +10 -0
  120. package/dist/cjs/types/validators/number.d.ts.map +1 -0
  121. package/dist/cjs/types/validators/object.d.ts +6 -0
  122. package/dist/cjs/types/validators/object.d.ts.map +1 -0
  123. package/dist/cjs/types/validators/schema.d.ts +10 -0
  124. package/dist/cjs/types/validators/schema.d.ts.map +1 -0
  125. package/dist/cjs/types/validators/string.d.ts +12 -0
  126. package/dist/cjs/types/validators/string.d.ts.map +1 -0
  127. package/dist/cjs/types/validators/types.d.ts +2 -0
  128. package/dist/cjs/types/validators/types.d.ts.map +1 -0
  129. package/dist/cjs/types/validators/union.d.ts +4 -0
  130. package/dist/cjs/types/validators/union.d.ts.map +1 -0
  131. package/dist/cjs/types/validators/utils.d.ts +83 -0
  132. package/dist/cjs/types/validators/utils.d.ts.map +1 -0
  133. package/dist/esm/src/adapter/fields/array.js +13 -0
  134. package/dist/esm/src/adapter/fields/boolean.js +20 -0
  135. package/dist/esm/src/adapter/fields/datetime.js +20 -0
  136. package/dist/esm/src/adapter/fields/index.js +37 -0
  137. package/dist/esm/src/adapter/fields/number.js +20 -0
  138. package/dist/esm/src/adapter/fields/object.js +20 -0
  139. package/dist/esm/src/adapter/fields/string.js +20 -0
  140. package/dist/esm/src/adapter/fields/union.js +20 -0
  141. package/dist/esm/src/adapter/index.js +18 -0
  142. package/dist/esm/src/adapter/types.js +1 -0
  143. package/dist/esm/src/compile.js +10 -0
  144. package/dist/esm/src/conf.js +19 -0
  145. package/dist/esm/src/constants.js +5 -0
  146. package/dist/esm/src/domain.js +2 -0
  147. package/dist/esm/src/exceptions.js +15 -0
  148. package/dist/esm/src/index.js +160 -0
  149. package/dist/esm/src/model.js +255 -0
  150. package/dist/esm/src/parsers/convert-from-number.js +8 -0
  151. package/dist/esm/src/parsers/convert-from-string.js +14 -0
  152. package/dist/esm/src/parsers/index.js +2 -0
  153. package/dist/esm/src/schema/array.js +403 -0
  154. package/dist/esm/src/schema/boolean.js +465 -0
  155. package/dist/esm/src/schema/datetime.js +423 -0
  156. package/dist/esm/src/schema/index.js +3 -0
  157. package/dist/esm/src/schema/number.js +592 -0
  158. package/dist/esm/src/schema/object.js +464 -0
  159. package/dist/esm/src/schema/schema.js +728 -0
  160. package/dist/esm/src/schema/string.js +579 -0
  161. package/dist/esm/src/schema/types.js +1 -0
  162. package/dist/esm/src/schema/union.js +388 -0
  163. package/dist/esm/src/types.js +1 -0
  164. package/dist/esm/src/utils.js +175 -0
  165. package/dist/esm/src/validators/array.js +135 -0
  166. package/dist/esm/src/validators/boolean.js +35 -0
  167. package/dist/esm/src/validators/datetime.js +85 -0
  168. package/dist/esm/src/validators/number.js +162 -0
  169. package/dist/esm/src/validators/object.js +38 -0
  170. package/dist/esm/src/validators/schema.js +114 -0
  171. package/dist/esm/src/validators/string.js +174 -0
  172. package/dist/esm/src/validators/types.js +1 -0
  173. package/dist/esm/src/validators/union.js +38 -0
  174. package/dist/esm/src/validators/utils.js +120 -0
  175. package/package.json +48 -0
  176. package/src/adapter/fields/array.ts +31 -0
  177. package/src/adapter/fields/boolean.ts +48 -0
  178. package/src/adapter/fields/datetime.ts +49 -0
  179. package/src/adapter/fields/index.ts +72 -0
  180. package/src/adapter/fields/number.ts +49 -0
  181. package/src/adapter/fields/object.ts +49 -0
  182. package/src/adapter/fields/string.ts +49 -0
  183. package/src/adapter/fields/union.ts +49 -0
  184. package/src/adapter/index.ts +34 -0
  185. package/src/adapter/types.ts +261 -0
  186. package/src/compile.ts +14 -0
  187. package/src/conf.ts +27 -0
  188. package/src/constants.ts +9 -0
  189. package/src/domain.ts +3 -0
  190. package/src/exceptions.ts +17 -0
  191. package/src/index.ts +338 -0
  192. package/src/model.ts +501 -0
  193. package/src/parsers/convert-from-number.ts +13 -0
  194. package/src/parsers/convert-from-string.ts +19 -0
  195. package/src/parsers/index.ts +2 -0
  196. package/src/schema/array.ts +633 -0
  197. package/src/schema/boolean.ts +700 -0
  198. package/src/schema/datetime.ts +613 -0
  199. package/src/schema/index.ts +5 -0
  200. package/src/schema/number.ts +885 -0
  201. package/src/schema/object.ts +699 -0
  202. package/src/schema/schema.ts +1093 -0
  203. package/src/schema/string.ts +807 -0
  204. package/src/schema/types.ts +126 -0
  205. package/src/schema/union.ts +596 -0
  206. package/src/types.ts +13 -0
  207. package/src/utils.ts +322 -0
  208. package/src/validators/array.ts +164 -0
  209. package/src/validators/boolean.ts +46 -0
  210. package/src/validators/datetime.ts +113 -0
  211. package/src/validators/number.ts +188 -0
  212. package/src/validators/object.ts +55 -0
  213. package/src/validators/schema.ts +134 -0
  214. package/src/validators/string.ts +215 -0
  215. package/src/validators/types.ts +1 -0
  216. package/src/validators/union.ts +52 -0
  217. package/src/validators/utils.ts +200 -0
  218. package/tsconfig.json +9 -0
  219. package/tsconfig.types.json +10 -0
@@ -0,0 +1,439 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ email: function() {
13
+ return email;
14
+ },
15
+ endsWith: function() {
16
+ return endsWith;
17
+ },
18
+ includes: function() {
19
+ return includes;
20
+ },
21
+ maxLength: function() {
22
+ return maxLength;
23
+ },
24
+ minLength: function() {
25
+ return minLength;
26
+ },
27
+ regex: function() {
28
+ return regex;
29
+ },
30
+ startsWith: function() {
31
+ return startsWith;
32
+ },
33
+ stringValidation: function() {
34
+ return stringValidation;
35
+ },
36
+ uuid: function() {
37
+ return uuid;
38
+ }
39
+ });
40
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
41
+ try {
42
+ var info = gen[key](arg);
43
+ var value = info.value;
44
+ } catch (error) {
45
+ reject(error);
46
+ return;
47
+ }
48
+ if (info.done) {
49
+ resolve(value);
50
+ } else {
51
+ Promise.resolve(value).then(_next, _throw);
52
+ }
53
+ }
54
+ function _async_to_generator(fn) {
55
+ return function() {
56
+ var self = this, args = arguments;
57
+ return new Promise(function(resolve, reject) {
58
+ var gen = fn.apply(self, args);
59
+ function _next(value) {
60
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
61
+ }
62
+ function _throw(err) {
63
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
64
+ }
65
+ _next(undefined);
66
+ });
67
+ };
68
+ }
69
+ function _type_of(obj) {
70
+ "@swc/helpers - typeof";
71
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
72
+ }
73
+ function _ts_generator(thisArg, body) {
74
+ var f, y, t, g, _ = {
75
+ label: 0,
76
+ sent: function() {
77
+ if (t[0] & 1) throw t[1];
78
+ return t[1];
79
+ },
80
+ trys: [],
81
+ ops: []
82
+ };
83
+ return g = {
84
+ next: verb(0),
85
+ "throw": verb(1),
86
+ "return": verb(2)
87
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
88
+ return this;
89
+ }), g;
90
+ function verb(n) {
91
+ return function(v) {
92
+ return step([
93
+ n,
94
+ v
95
+ ]);
96
+ };
97
+ }
98
+ function step(op) {
99
+ if (f) throw new TypeError("Generator is already executing.");
100
+ while(_)try {
101
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
102
+ if (y = 0, t) op = [
103
+ op[0] & 2,
104
+ t.value
105
+ ];
106
+ switch(op[0]){
107
+ case 0:
108
+ case 1:
109
+ t = op;
110
+ break;
111
+ case 4:
112
+ _.label++;
113
+ return {
114
+ value: op[1],
115
+ done: false
116
+ };
117
+ case 5:
118
+ _.label++;
119
+ y = op[1];
120
+ op = [
121
+ 0
122
+ ];
123
+ continue;
124
+ case 7:
125
+ op = _.ops.pop();
126
+ _.trys.pop();
127
+ continue;
128
+ default:
129
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
130
+ _ = 0;
131
+ continue;
132
+ }
133
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
134
+ _.label = op[1];
135
+ break;
136
+ }
137
+ if (op[0] === 6 && _.label < t[1]) {
138
+ _.label = t[1];
139
+ t = op;
140
+ break;
141
+ }
142
+ if (t && _.label < t[2]) {
143
+ _.label = t[2];
144
+ _.ops.push(op);
145
+ break;
146
+ }
147
+ if (t[2]) _.ops.pop();
148
+ _.trys.pop();
149
+ continue;
150
+ }
151
+ op = body.call(thisArg, _);
152
+ } catch (e) {
153
+ op = [
154
+ 6,
155
+ e
156
+ ];
157
+ y = 0;
158
+ } finally{
159
+ f = t = 0;
160
+ }
161
+ if (op[0] & 5) throw op[1];
162
+ return {
163
+ value: op[0] ? op[1] : void 0,
164
+ done: true
165
+ };
166
+ }
167
+ }
168
+ function stringValidation() {
169
+ return {
170
+ type: 'medium',
171
+ callback: function() {
172
+ var _ref = _async_to_generator(function(value, path, _options) {
173
+ return _ts_generator(this, function(_state) {
174
+ return [
175
+ 2,
176
+ {
177
+ parsed: value,
178
+ errors: typeof value === 'string' ? [] : [
179
+ {
180
+ isValid: typeof value === 'string',
181
+ code: 'string',
182
+ path: path || [],
183
+ message: 'The value must be a string. Received: ' + (typeof value === "undefined" ? "undefined" : _type_of(value))
184
+ }
185
+ ]
186
+ }
187
+ ];
188
+ });
189
+ });
190
+ return function(value, path, _options) {
191
+ return _ref.apply(this, arguments);
192
+ };
193
+ }()
194
+ };
195
+ }
196
+ function maxLength(args) {
197
+ return {
198
+ type: 'low',
199
+ callback: function() {
200
+ var _ref = _async_to_generator(function(value, path, _options) {
201
+ var isValid;
202
+ return _ts_generator(this, function(_state) {
203
+ isValid = args.inclusive ? value.length <= args.value : value.length < args.value;
204
+ return [
205
+ 2,
206
+ {
207
+ parsed: value,
208
+ errors: isValid ? [] : [
209
+ {
210
+ isValid: false,
211
+ code: 'maxLength',
212
+ path: path || [],
213
+ message: args.message
214
+ }
215
+ ]
216
+ }
217
+ ];
218
+ });
219
+ });
220
+ return function(value, path, _options) {
221
+ return _ref.apply(this, arguments);
222
+ };
223
+ }()
224
+ };
225
+ }
226
+ function minLength(args) {
227
+ return {
228
+ type: 'low',
229
+ callback: function() {
230
+ var _ref = _async_to_generator(function(value, path, _options) {
231
+ var isValid;
232
+ return _ts_generator(this, function(_state) {
233
+ isValid = args.inclusive ? value.length >= args.value : value.length > args.value;
234
+ return [
235
+ 2,
236
+ {
237
+ parsed: value,
238
+ errors: isValid ? [] : [
239
+ {
240
+ isValid: false,
241
+ code: 'minLength',
242
+ path: path || [],
243
+ message: args.message
244
+ }
245
+ ]
246
+ }
247
+ ];
248
+ });
249
+ });
250
+ return function(value, path, _options) {
251
+ return _ref.apply(this, arguments);
252
+ };
253
+ }()
254
+ };
255
+ }
256
+ function endsWith(args) {
257
+ return {
258
+ type: 'low',
259
+ callback: function() {
260
+ var _ref = _async_to_generator(function(value, path, _options) {
261
+ var isValid;
262
+ return _ts_generator(this, function(_state) {
263
+ isValid = value.endsWith(args.value);
264
+ return [
265
+ 2,
266
+ {
267
+ parsed: value,
268
+ errors: isValid ? [] : [
269
+ {
270
+ isValid: false,
271
+ code: 'endsWith',
272
+ path: path || [],
273
+ message: args.message
274
+ }
275
+ ]
276
+ }
277
+ ];
278
+ });
279
+ });
280
+ return function(value, path, _options) {
281
+ return _ref.apply(this, arguments);
282
+ };
283
+ }()
284
+ };
285
+ }
286
+ function startsWith(args) {
287
+ return {
288
+ type: 'low',
289
+ callback: function() {
290
+ var _ref = _async_to_generator(function(value, path, _options) {
291
+ var isValid;
292
+ return _ts_generator(this, function(_state) {
293
+ isValid = value.startsWith(args.value);
294
+ return [
295
+ 2,
296
+ {
297
+ parsed: value,
298
+ errors: isValid ? [] : [
299
+ {
300
+ isValid: false,
301
+ code: 'startsWith',
302
+ path: path || [],
303
+ message: args.message
304
+ }
305
+ ]
306
+ }
307
+ ];
308
+ });
309
+ });
310
+ return function(value, path, _options) {
311
+ return _ref.apply(this, arguments);
312
+ };
313
+ }()
314
+ };
315
+ }
316
+ function includes(args) {
317
+ return {
318
+ type: 'low',
319
+ callback: function() {
320
+ var _ref = _async_to_generator(function(value, path, _options) {
321
+ var isValid;
322
+ return _ts_generator(this, function(_state) {
323
+ isValid = value.includes(args.value);
324
+ return [
325
+ 2,
326
+ {
327
+ parsed: value,
328
+ errors: isValid ? [] : [
329
+ {
330
+ isValid: false,
331
+ code: 'includes',
332
+ path: path || [],
333
+ message: args.message
334
+ }
335
+ ]
336
+ }
337
+ ];
338
+ });
339
+ });
340
+ return function(value, path, _options) {
341
+ return _ref.apply(this, arguments);
342
+ };
343
+ }()
344
+ };
345
+ }
346
+ function regex(args) {
347
+ return {
348
+ type: 'low',
349
+ callback: function() {
350
+ var _ref = _async_to_generator(function(value, path, _options) {
351
+ var isValid;
352
+ return _ts_generator(this, function(_state) {
353
+ isValid = args.value.test(value);
354
+ return [
355
+ 2,
356
+ {
357
+ parsed: value,
358
+ errors: isValid ? [] : [
359
+ {
360
+ isValid: false,
361
+ code: 'regex',
362
+ path: path || [],
363
+ message: args.message
364
+ }
365
+ ]
366
+ }
367
+ ];
368
+ });
369
+ });
370
+ return function(value, path, _options) {
371
+ return _ref.apply(this, arguments);
372
+ };
373
+ }()
374
+ };
375
+ }
376
+ function uuid(args) {
377
+ // const uuidRegex =
378
+ // /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
379
+ var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
380
+ return {
381
+ type: 'low',
382
+ callback: function() {
383
+ var _ref = _async_to_generator(function(value, path, _options) {
384
+ var isValid;
385
+ return _ts_generator(this, function(_state) {
386
+ isValid = uuidRegex.test(value);
387
+ return [
388
+ 2,
389
+ {
390
+ parsed: value,
391
+ errors: isValid ? [] : [
392
+ {
393
+ isValid: false,
394
+ code: 'uuid',
395
+ path: path || [],
396
+ message: args.message
397
+ }
398
+ ]
399
+ }
400
+ ];
401
+ });
402
+ });
403
+ return function(value, path, _options) {
404
+ return _ref.apply(this, arguments);
405
+ };
406
+ }()
407
+ };
408
+ }
409
+ function email(args) {
410
+ var emailRegex = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
411
+ return {
412
+ type: 'low',
413
+ callback: function() {
414
+ var _ref = _async_to_generator(function(value, path, _options) {
415
+ var isValid;
416
+ return _ts_generator(this, function(_state) {
417
+ isValid = emailRegex.test(value);
418
+ return [
419
+ 2,
420
+ {
421
+ parsed: value,
422
+ errors: isValid ? [] : [
423
+ {
424
+ isValid: false,
425
+ code: 'email',
426
+ path: path || [],
427
+ message: args.message
428
+ }
429
+ ]
430
+ }
431
+ ];
432
+ });
433
+ });
434
+ return function(value, path, _options) {
435
+ return _ref.apply(this, arguments);
436
+ };
437
+ }()
438
+ };
439
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "unionValidation", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return unionValidation;
9
+ }
10
+ });
11
+ function _array_like_to_array(arr, len) {
12
+ if (len == null || len > arr.length) len = arr.length;
13
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
14
+ return arr2;
15
+ }
16
+ function _array_without_holes(arr) {
17
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
18
+ }
19
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
20
+ try {
21
+ var info = gen[key](arg);
22
+ var value = info.value;
23
+ } catch (error) {
24
+ reject(error);
25
+ return;
26
+ }
27
+ if (info.done) {
28
+ resolve(value);
29
+ } else {
30
+ Promise.resolve(value).then(_next, _throw);
31
+ }
32
+ }
33
+ function _async_to_generator(fn) {
34
+ return function() {
35
+ var self = this, args = arguments;
36
+ return new Promise(function(resolve, reject) {
37
+ var gen = fn.apply(self, args);
38
+ function _next(value) {
39
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
40
+ }
41
+ function _throw(err) {
42
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
43
+ }
44
+ _next(undefined);
45
+ });
46
+ };
47
+ }
48
+ function _iterable_to_array(iter) {
49
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
50
+ }
51
+ function _non_iterable_spread() {
52
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
53
+ }
54
+ function _to_consumable_array(arr) {
55
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
56
+ }
57
+ function _unsupported_iterable_to_array(o, minLen) {
58
+ if (!o) return;
59
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
60
+ var n = Object.prototype.toString.call(o).slice(8, -1);
61
+ if (n === "Object" && o.constructor) n = o.constructor.name;
62
+ if (n === "Map" || n === "Set") return Array.from(n);
63
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
64
+ }
65
+ function _ts_generator(thisArg, body) {
66
+ var f, y, t, g, _ = {
67
+ label: 0,
68
+ sent: function() {
69
+ if (t[0] & 1) throw t[1];
70
+ return t[1];
71
+ },
72
+ trys: [],
73
+ ops: []
74
+ };
75
+ return g = {
76
+ next: verb(0),
77
+ "throw": verb(1),
78
+ "return": verb(2)
79
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
80
+ return this;
81
+ }), g;
82
+ function verb(n) {
83
+ return function(v) {
84
+ return step([
85
+ n,
86
+ v
87
+ ]);
88
+ };
89
+ }
90
+ function step(op) {
91
+ if (f) throw new TypeError("Generator is already executing.");
92
+ while(_)try {
93
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
94
+ if (y = 0, t) op = [
95
+ op[0] & 2,
96
+ t.value
97
+ ];
98
+ switch(op[0]){
99
+ case 0:
100
+ case 1:
101
+ t = op;
102
+ break;
103
+ case 4:
104
+ _.label++;
105
+ return {
106
+ value: op[1],
107
+ done: false
108
+ };
109
+ case 5:
110
+ _.label++;
111
+ y = op[1];
112
+ op = [
113
+ 0
114
+ ];
115
+ continue;
116
+ case 7:
117
+ op = _.ops.pop();
118
+ _.trys.pop();
119
+ continue;
120
+ default:
121
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
122
+ _ = 0;
123
+ continue;
124
+ }
125
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
126
+ _.label = op[1];
127
+ break;
128
+ }
129
+ if (op[0] === 6 && _.label < t[1]) {
130
+ _.label = t[1];
131
+ t = op;
132
+ break;
133
+ }
134
+ if (t && _.label < t[2]) {
135
+ _.label = t[2];
136
+ _.ops.push(op);
137
+ break;
138
+ }
139
+ if (t[2]) _.ops.pop();
140
+ _.trys.pop();
141
+ continue;
142
+ }
143
+ op = body.call(thisArg, _);
144
+ } catch (e) {
145
+ op = [
146
+ 6,
147
+ e
148
+ ];
149
+ y = 0;
150
+ } finally{
151
+ f = t = 0;
152
+ }
153
+ if (op[0] & 5) throw op[1];
154
+ return {
155
+ value: op[0] ? op[1] : void 0,
156
+ done: true
157
+ };
158
+ }
159
+ }
160
+ function unionValidation(schemas) {
161
+ return {
162
+ type: 'high',
163
+ callback: function() {
164
+ var _ref = _async_to_generator(function(value, path, options) {
165
+ var _options_toInternalToBubbleUp, parsedValues, startingToInternalBubbleUpLength, i, _parsedValues_errors, _options_toInternalToBubbleUp1, schemaWithProtected, parsedData, hasNoErrorsSoItsAValidSchemaAndShouldResetOldErrors, _options_toInternalToBubbleUp2, _options_toInternalToBubbleUp3, numberOfElementsToRemove;
166
+ return _ts_generator(this, function(_state) {
167
+ switch(_state.label){
168
+ case 0:
169
+ parsedValues = {
170
+ parsed: value,
171
+ errors: []
172
+ };
173
+ startingToInternalBubbleUpLength = ((_options_toInternalToBubbleUp = options.toInternalToBubbleUp) === null || _options_toInternalToBubbleUp === void 0 ? void 0 : _options_toInternalToBubbleUp.length) || 0;
174
+ i = 0;
175
+ _state.label = 1;
176
+ case 1:
177
+ if (!(i < schemas.length)) return [
178
+ 3,
179
+ 4
180
+ ];
181
+ schemaWithProtected = schemas[i];
182
+ return [
183
+ 4,
184
+ schemaWithProtected.__parse(value, path, options)
185
+ ];
186
+ case 2:
187
+ parsedData = _state.sent();
188
+ parsedValues.parsed = parsedData.parsed;
189
+ if (Array.isArray(parsedData.errors)) if (Array.isArray(parsedValues.errors)) (_parsedValues_errors = parsedValues.errors).push.apply(_parsedValues_errors, _to_consumable_array(parsedData.errors));
190
+ else parsedValues.errors = parsedData.errors;
191
+ hasNoErrorsSoItsAValidSchemaAndShouldResetOldErrors = // eslint-disable-next-line ts/no-unnecessary-condition
192
+ parsedData.errors === undefined || (parsedData.errors || []).length === 0;
193
+ if (hasNoErrorsSoItsAValidSchemaAndShouldResetOldErrors) {
194
+ return [
195
+ 2,
196
+ {
197
+ parsed: parsedValues.parsed,
198
+ errors: []
199
+ }
200
+ ];
201
+ } else if (startingToInternalBubbleUpLength < (((_options_toInternalToBubbleUp1 = options.toInternalToBubbleUp) === null || _options_toInternalToBubbleUp1 === void 0 ? void 0 : _options_toInternalToBubbleUp1.length) || 0)) {
202
+ ;
203
+ // If there is a new toInternalToBubbleUp we should remove the ones that we added since this is not a valid schema,
204
+ // we shouldn't be calling the `toInternal` on that schemas.
205
+ numberOfElementsToRemove = (((_options_toInternalToBubbleUp2 = options.toInternalToBubbleUp) === null || _options_toInternalToBubbleUp2 === void 0 ? void 0 : _options_toInternalToBubbleUp2.length) || 0) - startingToInternalBubbleUpLength;
206
+ (_options_toInternalToBubbleUp3 = options.toInternalToBubbleUp) === null || _options_toInternalToBubbleUp3 === void 0 ? void 0 : _options_toInternalToBubbleUp3.splice(startingToInternalBubbleUpLength, numberOfElementsToRemove);
207
+ }
208
+ _state.label = 3;
209
+ case 3:
210
+ i++;
211
+ return [
212
+ 3,
213
+ 1
214
+ ];
215
+ case 4:
216
+ return [
217
+ 2,
218
+ {
219
+ parsed: parsedValues.parsed,
220
+ // eslint-disable-next-line ts/no-unnecessary-condition
221
+ errors: parsedValues.errors ? parsedValues.errors : []
222
+ }
223
+ ];
224
+ }
225
+ });
226
+ });
227
+ return function(value, path, options) {
228
+ return _ref.apply(this, arguments);
229
+ };
230
+ }()
231
+ };
232
+ }