@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.
- package/.turbo/turbo-build$colon$watch.log +424 -0
- package/.turbo/turbo-build.log +13 -0
- package/.turbo/turbo-build:watch.log +26 -0
- package/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/dist/cjs/src/adapter/fields/array.js +157 -0
- package/dist/cjs/src/adapter/fields/boolean.js +167 -0
- package/dist/cjs/src/adapter/fields/datetime.js +167 -0
- package/dist/cjs/src/adapter/fields/index.js +311 -0
- package/dist/cjs/src/adapter/fields/number.js +167 -0
- package/dist/cjs/src/adapter/fields/object.js +167 -0
- package/dist/cjs/src/adapter/fields/string.js +167 -0
- package/dist/cjs/src/adapter/fields/union.js +167 -0
- package/dist/cjs/src/adapter/index.js +198 -0
- package/dist/cjs/src/adapter/types.js +4 -0
- package/dist/cjs/src/compile.js +262 -0
- package/dist/cjs/src/conf.js +27 -0
- package/dist/cjs/src/constants.js +42 -0
- package/dist/cjs/src/domain.js +12 -0
- package/dist/cjs/src/exceptions.js +168 -0
- package/dist/cjs/src/index.js +365 -0
- package/dist/cjs/src/model.js +628 -0
- package/dist/cjs/src/parsers/convert-from-number.js +20 -0
- package/dist/cjs/src/parsers/convert-from-string.js +24 -0
- package/dist/cjs/src/parsers/index.js +25 -0
- package/dist/cjs/src/schema/array.js +890 -0
- package/dist/cjs/src/schema/boolean.js +826 -0
- package/dist/cjs/src/schema/datetime.js +778 -0
- package/dist/cjs/src/schema/index.js +17 -0
- package/dist/cjs/src/schema/number.js +960 -0
- package/dist/cjs/src/schema/object.js +999 -0
- package/dist/cjs/src/schema/schema.js +1788 -0
- package/dist/cjs/src/schema/string.js +948 -0
- package/dist/cjs/src/schema/types.js +4 -0
- package/dist/cjs/src/schema/union.js +952 -0
- package/dist/cjs/src/types.js +4 -0
- package/dist/cjs/src/utils.js +627 -0
- package/dist/cjs/src/validators/array.js +457 -0
- package/dist/cjs/src/validators/boolean.js +199 -0
- package/dist/cjs/src/validators/datetime.js +287 -0
- package/dist/cjs/src/validators/number.js +403 -0
- package/dist/cjs/src/validators/object.js +290 -0
- package/dist/cjs/src/validators/schema.js +318 -0
- package/dist/cjs/src/validators/string.js +439 -0
- package/dist/cjs/src/validators/types.js +4 -0
- package/dist/cjs/src/validators/union.js +232 -0
- package/dist/cjs/src/validators/utils.js +426 -0
- package/dist/cjs/tsconfig.types.tsbuildinfo +1 -0
- package/dist/cjs/types/adapter/fields/array.d.ts +20 -0
- package/dist/cjs/types/adapter/fields/array.d.ts.map +1 -0
- package/dist/cjs/types/adapter/fields/boolean.d.ts +25 -0
- package/dist/cjs/types/adapter/fields/boolean.d.ts.map +1 -0
- package/dist/cjs/types/adapter/fields/datetime.d.ts +25 -0
- package/dist/cjs/types/adapter/fields/datetime.d.ts.map +1 -0
- package/dist/cjs/types/adapter/fields/index.d.ts +31 -0
- package/dist/cjs/types/adapter/fields/index.d.ts.map +1 -0
- package/dist/cjs/types/adapter/fields/number.d.ts +25 -0
- package/dist/cjs/types/adapter/fields/number.d.ts.map +1 -0
- package/dist/cjs/types/adapter/fields/object.d.ts +25 -0
- package/dist/cjs/types/adapter/fields/object.d.ts.map +1 -0
- package/dist/cjs/types/adapter/fields/string.d.ts +25 -0
- package/dist/cjs/types/adapter/fields/string.d.ts.map +1 -0
- package/dist/cjs/types/adapter/fields/union.d.ts +25 -0
- package/dist/cjs/types/adapter/fields/union.d.ts.map +1 -0
- package/dist/cjs/types/adapter/index.d.ts +25 -0
- package/dist/cjs/types/adapter/index.d.ts.map +1 -0
- package/dist/cjs/types/adapter/types.d.ts +144 -0
- package/dist/cjs/types/adapter/types.d.ts.map +1 -0
- package/dist/cjs/types/compile.d.ts +3 -0
- package/dist/cjs/types/compile.d.ts.map +1 -0
- package/dist/cjs/types/conf.d.ts +16 -0
- package/dist/cjs/types/conf.d.ts.map +1 -0
- package/dist/cjs/types/constants.d.ts +6 -0
- package/dist/cjs/types/constants.d.ts.map +1 -0
- package/dist/cjs/types/domain.d.ts +21 -0
- package/dist/cjs/types/domain.d.ts.map +1 -0
- package/dist/cjs/types/exceptions.d.ts +13 -0
- package/dist/cjs/types/exceptions.d.ts.map +1 -0
- package/dist/cjs/types/index.d.ts +240 -0
- package/dist/cjs/types/index.d.ts.map +1 -0
- package/dist/cjs/types/model.d.ts +136 -0
- package/dist/cjs/types/model.d.ts.map +1 -0
- package/dist/cjs/types/parsers/convert-from-number.d.ts +15 -0
- package/dist/cjs/types/parsers/convert-from-number.d.ts.map +1 -0
- package/dist/cjs/types/parsers/convert-from-string.d.ts +9 -0
- package/dist/cjs/types/parsers/convert-from-string.d.ts.map +1 -0
- package/dist/cjs/types/parsers/index.d.ts +3 -0
- package/dist/cjs/types/parsers/index.d.ts.map +1 -0
- package/dist/cjs/types/schema/array.d.ts +429 -0
- package/dist/cjs/types/schema/array.d.ts.map +1 -0
- package/dist/cjs/types/schema/boolean.d.ts +501 -0
- package/dist/cjs/types/schema/boolean.d.ts.map +1 -0
- package/dist/cjs/types/schema/datetime.d.ts +474 -0
- package/dist/cjs/types/schema/datetime.d.ts.map +1 -0
- package/dist/cjs/types/schema/index.d.ts +4 -0
- package/dist/cjs/types/schema/index.d.ts.map +1 -0
- package/dist/cjs/types/schema/number.d.ts +667 -0
- package/dist/cjs/types/schema/number.d.ts.map +1 -0
- package/dist/cjs/types/schema/object.d.ts +450 -0
- package/dist/cjs/types/schema/object.d.ts.map +1 -0
- package/dist/cjs/types/schema/schema.d.ts +646 -0
- package/dist/cjs/types/schema/schema.d.ts.map +1 -0
- package/dist/cjs/types/schema/string.d.ts +606 -0
- package/dist/cjs/types/schema/string.d.ts.map +1 -0
- package/dist/cjs/types/schema/types.d.ts +70 -0
- package/dist/cjs/types/schema/types.d.ts.map +1 -0
- package/dist/cjs/types/schema/union.d.ts +388 -0
- package/dist/cjs/types/schema/union.d.ts.map +1 -0
- package/dist/cjs/types/types.d.ts +11 -0
- package/dist/cjs/types/types.d.ts.map +1 -0
- package/dist/cjs/types/utils.d.ts +79 -0
- package/dist/cjs/types/utils.d.ts.map +1 -0
- package/dist/cjs/types/validators/array.d.ts +8 -0
- package/dist/cjs/types/validators/array.d.ts.map +1 -0
- package/dist/cjs/types/validators/boolean.d.ts +4 -0
- package/dist/cjs/types/validators/boolean.d.ts.map +1 -0
- package/dist/cjs/types/validators/datetime.d.ts +7 -0
- package/dist/cjs/types/validators/datetime.d.ts.map +1 -0
- package/dist/cjs/types/validators/number.d.ts +10 -0
- package/dist/cjs/types/validators/number.d.ts.map +1 -0
- package/dist/cjs/types/validators/object.d.ts +6 -0
- package/dist/cjs/types/validators/object.d.ts.map +1 -0
- package/dist/cjs/types/validators/schema.d.ts +10 -0
- package/dist/cjs/types/validators/schema.d.ts.map +1 -0
- package/dist/cjs/types/validators/string.d.ts +12 -0
- package/dist/cjs/types/validators/string.d.ts.map +1 -0
- package/dist/cjs/types/validators/types.d.ts +2 -0
- package/dist/cjs/types/validators/types.d.ts.map +1 -0
- package/dist/cjs/types/validators/union.d.ts +4 -0
- package/dist/cjs/types/validators/union.d.ts.map +1 -0
- package/dist/cjs/types/validators/utils.d.ts +83 -0
- package/dist/cjs/types/validators/utils.d.ts.map +1 -0
- package/dist/esm/src/adapter/fields/array.js +13 -0
- package/dist/esm/src/adapter/fields/boolean.js +20 -0
- package/dist/esm/src/adapter/fields/datetime.js +20 -0
- package/dist/esm/src/adapter/fields/index.js +37 -0
- package/dist/esm/src/adapter/fields/number.js +20 -0
- package/dist/esm/src/adapter/fields/object.js +20 -0
- package/dist/esm/src/adapter/fields/string.js +20 -0
- package/dist/esm/src/adapter/fields/union.js +20 -0
- package/dist/esm/src/adapter/index.js +18 -0
- package/dist/esm/src/adapter/types.js +1 -0
- package/dist/esm/src/compile.js +10 -0
- package/dist/esm/src/conf.js +19 -0
- package/dist/esm/src/constants.js +5 -0
- package/dist/esm/src/domain.js +2 -0
- package/dist/esm/src/exceptions.js +15 -0
- package/dist/esm/src/index.js +160 -0
- package/dist/esm/src/model.js +255 -0
- package/dist/esm/src/parsers/convert-from-number.js +8 -0
- package/dist/esm/src/parsers/convert-from-string.js +14 -0
- package/dist/esm/src/parsers/index.js +2 -0
- package/dist/esm/src/schema/array.js +403 -0
- package/dist/esm/src/schema/boolean.js +465 -0
- package/dist/esm/src/schema/datetime.js +423 -0
- package/dist/esm/src/schema/index.js +3 -0
- package/dist/esm/src/schema/number.js +592 -0
- package/dist/esm/src/schema/object.js +464 -0
- package/dist/esm/src/schema/schema.js +728 -0
- package/dist/esm/src/schema/string.js +579 -0
- package/dist/esm/src/schema/types.js +1 -0
- package/dist/esm/src/schema/union.js +388 -0
- package/dist/esm/src/types.js +1 -0
- package/dist/esm/src/utils.js +175 -0
- package/dist/esm/src/validators/array.js +135 -0
- package/dist/esm/src/validators/boolean.js +35 -0
- package/dist/esm/src/validators/datetime.js +85 -0
- package/dist/esm/src/validators/number.js +162 -0
- package/dist/esm/src/validators/object.js +38 -0
- package/dist/esm/src/validators/schema.js +114 -0
- package/dist/esm/src/validators/string.js +174 -0
- package/dist/esm/src/validators/types.js +1 -0
- package/dist/esm/src/validators/union.js +38 -0
- package/dist/esm/src/validators/utils.js +120 -0
- package/package.json +48 -0
- package/src/adapter/fields/array.ts +31 -0
- package/src/adapter/fields/boolean.ts +48 -0
- package/src/adapter/fields/datetime.ts +49 -0
- package/src/adapter/fields/index.ts +72 -0
- package/src/adapter/fields/number.ts +49 -0
- package/src/adapter/fields/object.ts +49 -0
- package/src/adapter/fields/string.ts +49 -0
- package/src/adapter/fields/union.ts +49 -0
- package/src/adapter/index.ts +34 -0
- package/src/adapter/types.ts +261 -0
- package/src/compile.ts +14 -0
- package/src/conf.ts +27 -0
- package/src/constants.ts +9 -0
- package/src/domain.ts +3 -0
- package/src/exceptions.ts +17 -0
- package/src/index.ts +338 -0
- package/src/model.ts +501 -0
- package/src/parsers/convert-from-number.ts +13 -0
- package/src/parsers/convert-from-string.ts +19 -0
- package/src/parsers/index.ts +2 -0
- package/src/schema/array.ts +633 -0
- package/src/schema/boolean.ts +700 -0
- package/src/schema/datetime.ts +613 -0
- package/src/schema/index.ts +5 -0
- package/src/schema/number.ts +885 -0
- package/src/schema/object.ts +699 -0
- package/src/schema/schema.ts +1093 -0
- package/src/schema/string.ts +807 -0
- package/src/schema/types.ts +126 -0
- package/src/schema/union.ts +596 -0
- package/src/types.ts +13 -0
- package/src/utils.ts +322 -0
- package/src/validators/array.ts +164 -0
- package/src/validators/boolean.ts +46 -0
- package/src/validators/datetime.ts +113 -0
- package/src/validators/number.ts +188 -0
- package/src/validators/object.ts +55 -0
- package/src/validators/schema.ts +134 -0
- package/src/validators/string.ts +215 -0
- package/src/validators/types.ts +1 -0
- package/src/validators/union.ts +52 -0
- package/src/validators/utils.ts +200 -0
- package/tsconfig.json +9 -0
- package/tsconfig.types.json +10 -0
@@ -0,0 +1,290 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "objectValidation", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return objectValidation;
|
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_with_holes(arr) {
|
17
|
+
if (Array.isArray(arr)) return arr;
|
18
|
+
}
|
19
|
+
function _array_without_holes(arr) {
|
20
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
21
|
+
}
|
22
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
23
|
+
try {
|
24
|
+
var info = gen[key](arg);
|
25
|
+
var value = info.value;
|
26
|
+
} catch (error) {
|
27
|
+
reject(error);
|
28
|
+
return;
|
29
|
+
}
|
30
|
+
if (info.done) {
|
31
|
+
resolve(value);
|
32
|
+
} else {
|
33
|
+
Promise.resolve(value).then(_next, _throw);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
function _async_to_generator(fn) {
|
37
|
+
return function() {
|
38
|
+
var self = this, args = arguments;
|
39
|
+
return new Promise(function(resolve, reject) {
|
40
|
+
var gen = fn.apply(self, args);
|
41
|
+
function _next(value) {
|
42
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
43
|
+
}
|
44
|
+
function _throw(err) {
|
45
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
46
|
+
}
|
47
|
+
_next(undefined);
|
48
|
+
});
|
49
|
+
};
|
50
|
+
}
|
51
|
+
function _iterable_to_array(iter) {
|
52
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
53
|
+
}
|
54
|
+
function _iterable_to_array_limit(arr, i) {
|
55
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
56
|
+
if (_i == null) return;
|
57
|
+
var _arr = [];
|
58
|
+
var _n = true;
|
59
|
+
var _d = false;
|
60
|
+
var _s, _e;
|
61
|
+
try {
|
62
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
63
|
+
_arr.push(_s.value);
|
64
|
+
if (i && _arr.length === i) break;
|
65
|
+
}
|
66
|
+
} catch (err) {
|
67
|
+
_d = true;
|
68
|
+
_e = err;
|
69
|
+
} finally{
|
70
|
+
try {
|
71
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
72
|
+
} finally{
|
73
|
+
if (_d) throw _e;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
return _arr;
|
77
|
+
}
|
78
|
+
function _non_iterable_rest() {
|
79
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
80
|
+
}
|
81
|
+
function _non_iterable_spread() {
|
82
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
83
|
+
}
|
84
|
+
function _sliced_to_array(arr, i) {
|
85
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
86
|
+
}
|
87
|
+
function _to_consumable_array(arr) {
|
88
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
89
|
+
}
|
90
|
+
function _type_of(obj) {
|
91
|
+
"@swc/helpers - typeof";
|
92
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
93
|
+
}
|
94
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
95
|
+
if (!o) return;
|
96
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
97
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
98
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
99
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
100
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
101
|
+
}
|
102
|
+
function _ts_generator(thisArg, body) {
|
103
|
+
var f, y, t, g, _ = {
|
104
|
+
label: 0,
|
105
|
+
sent: function() {
|
106
|
+
if (t[0] & 1) throw t[1];
|
107
|
+
return t[1];
|
108
|
+
},
|
109
|
+
trys: [],
|
110
|
+
ops: []
|
111
|
+
};
|
112
|
+
return g = {
|
113
|
+
next: verb(0),
|
114
|
+
"throw": verb(1),
|
115
|
+
"return": verb(2)
|
116
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
117
|
+
return this;
|
118
|
+
}), g;
|
119
|
+
function verb(n) {
|
120
|
+
return function(v) {
|
121
|
+
return step([
|
122
|
+
n,
|
123
|
+
v
|
124
|
+
]);
|
125
|
+
};
|
126
|
+
}
|
127
|
+
function step(op) {
|
128
|
+
if (f) throw new TypeError("Generator is already executing.");
|
129
|
+
while(_)try {
|
130
|
+
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;
|
131
|
+
if (y = 0, t) op = [
|
132
|
+
op[0] & 2,
|
133
|
+
t.value
|
134
|
+
];
|
135
|
+
switch(op[0]){
|
136
|
+
case 0:
|
137
|
+
case 1:
|
138
|
+
t = op;
|
139
|
+
break;
|
140
|
+
case 4:
|
141
|
+
_.label++;
|
142
|
+
return {
|
143
|
+
value: op[1],
|
144
|
+
done: false
|
145
|
+
};
|
146
|
+
case 5:
|
147
|
+
_.label++;
|
148
|
+
y = op[1];
|
149
|
+
op = [
|
150
|
+
0
|
151
|
+
];
|
152
|
+
continue;
|
153
|
+
case 7:
|
154
|
+
op = _.ops.pop();
|
155
|
+
_.trys.pop();
|
156
|
+
continue;
|
157
|
+
default:
|
158
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
159
|
+
_ = 0;
|
160
|
+
continue;
|
161
|
+
}
|
162
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
163
|
+
_.label = op[1];
|
164
|
+
break;
|
165
|
+
}
|
166
|
+
if (op[0] === 6 && _.label < t[1]) {
|
167
|
+
_.label = t[1];
|
168
|
+
t = op;
|
169
|
+
break;
|
170
|
+
}
|
171
|
+
if (t && _.label < t[2]) {
|
172
|
+
_.label = t[2];
|
173
|
+
_.ops.push(op);
|
174
|
+
break;
|
175
|
+
}
|
176
|
+
if (t[2]) _.ops.pop();
|
177
|
+
_.trys.pop();
|
178
|
+
continue;
|
179
|
+
}
|
180
|
+
op = body.call(thisArg, _);
|
181
|
+
} catch (e) {
|
182
|
+
op = [
|
183
|
+
6,
|
184
|
+
e
|
185
|
+
];
|
186
|
+
y = 0;
|
187
|
+
} finally{
|
188
|
+
f = t = 0;
|
189
|
+
}
|
190
|
+
if (op[0] & 5) throw op[1];
|
191
|
+
return {
|
192
|
+
value: op[0] ? op[1] : void 0,
|
193
|
+
done: true
|
194
|
+
};
|
195
|
+
}
|
196
|
+
}
|
197
|
+
function objectValidation(keysToFallback) {
|
198
|
+
return {
|
199
|
+
type: 'low',
|
200
|
+
callback: function() {
|
201
|
+
var _ref = _async_to_generator(function(value, path, options) {
|
202
|
+
var isNotAnObject, errors, toValidateEntries;
|
203
|
+
return _ts_generator(this, function(_state) {
|
204
|
+
switch(_state.label){
|
205
|
+
case 0:
|
206
|
+
isNotAnObject = (typeof value === "undefined" ? "undefined" : _type_of(value)) !== 'object' && Array.isArray(value) === false && value !== null;
|
207
|
+
if (isNotAnObject) return [
|
208
|
+
2,
|
209
|
+
{
|
210
|
+
parsed: value,
|
211
|
+
preventChildValidation: true,
|
212
|
+
errors: [
|
213
|
+
{
|
214
|
+
isValid: false,
|
215
|
+
code: 'object',
|
216
|
+
// eslint-disable-next-line ts/no-unnecessary-condition
|
217
|
+
path: path || [],
|
218
|
+
message: 'The value must be an object. Received: ' + (typeof value === "undefined" ? "undefined" : _type_of(value))
|
219
|
+
}
|
220
|
+
]
|
221
|
+
}
|
222
|
+
];
|
223
|
+
errors = {};
|
224
|
+
toValidateEntries = Object.entries(keysToFallback);
|
225
|
+
return [
|
226
|
+
4,
|
227
|
+
Promise.all(toValidateEntries.map(function() {
|
228
|
+
var _ref = _async_to_generator(function(param) {
|
229
|
+
var _param, key, schema, schemaWithProtected, _ref, parsed, parseErrors;
|
230
|
+
return _ts_generator(this, function(_state) {
|
231
|
+
switch(_state.label){
|
232
|
+
case 0:
|
233
|
+
_param = _sliced_to_array(param, 2), key = _param[0], schema = _param[1];
|
234
|
+
schemaWithProtected = schema;
|
235
|
+
return [
|
236
|
+
4,
|
237
|
+
schemaWithProtected.__parse(value[key], _to_consumable_array(path).concat([
|
238
|
+
key
|
239
|
+
]), options)
|
240
|
+
];
|
241
|
+
case 1:
|
242
|
+
_ref = _state.sent(), parsed = _ref.parsed, parseErrors = _ref.errors;
|
243
|
+
if (Array.isArray(parseErrors) && parseErrors.length > 0) errors[key] = parseErrors;
|
244
|
+
else value[key] = parsed;
|
245
|
+
// We append the toInternalToBubbleUp to the parent toInternalToBubbleUp
|
246
|
+
if (schemaWithProtected.__toInternal && options.toInternalToBubbleUp) options.toInternalToBubbleUp.push(/*#__PURE__*/ _async_to_generator(function() {
|
247
|
+
return _ts_generator(this, function(_state) {
|
248
|
+
switch(_state.label){
|
249
|
+
case 0:
|
250
|
+
return [
|
251
|
+
4,
|
252
|
+
schema.__toInternal(parsed)
|
253
|
+
];
|
254
|
+
case 1:
|
255
|
+
return [
|
256
|
+
2,
|
257
|
+
value[key] = _state.sent()
|
258
|
+
];
|
259
|
+
}
|
260
|
+
});
|
261
|
+
}));
|
262
|
+
return [
|
263
|
+
2
|
264
|
+
];
|
265
|
+
}
|
266
|
+
});
|
267
|
+
});
|
268
|
+
return function(_) {
|
269
|
+
return _ref.apply(this, arguments);
|
270
|
+
};
|
271
|
+
}()))
|
272
|
+
];
|
273
|
+
case 1:
|
274
|
+
_state.sent();
|
275
|
+
return [
|
276
|
+
2,
|
277
|
+
{
|
278
|
+
parsed: value,
|
279
|
+
errors: Object.values(errors).flat()
|
280
|
+
}
|
281
|
+
];
|
282
|
+
}
|
283
|
+
});
|
284
|
+
});
|
285
|
+
return function(value, path, options) {
|
286
|
+
return _ref.apply(this, arguments);
|
287
|
+
};
|
288
|
+
}()
|
289
|
+
};
|
290
|
+
}
|
@@ -0,0 +1,318 @@
|
|
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
|
+
checkType: function() {
|
13
|
+
return checkType;
|
14
|
+
},
|
15
|
+
is: function() {
|
16
|
+
return is;
|
17
|
+
},
|
18
|
+
nullable: function() {
|
19
|
+
return nullable;
|
20
|
+
},
|
21
|
+
optional: function() {
|
22
|
+
return optional;
|
23
|
+
}
|
24
|
+
});
|
25
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
26
|
+
try {
|
27
|
+
var info = gen[key](arg);
|
28
|
+
var value = info.value;
|
29
|
+
} catch (error) {
|
30
|
+
reject(error);
|
31
|
+
return;
|
32
|
+
}
|
33
|
+
if (info.done) {
|
34
|
+
resolve(value);
|
35
|
+
} else {
|
36
|
+
Promise.resolve(value).then(_next, _throw);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
function _async_to_generator(fn) {
|
40
|
+
return function() {
|
41
|
+
var self = this, args = arguments;
|
42
|
+
return new Promise(function(resolve, reject) {
|
43
|
+
var gen = fn.apply(self, args);
|
44
|
+
function _next(value) {
|
45
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
46
|
+
}
|
47
|
+
function _throw(err) {
|
48
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
49
|
+
}
|
50
|
+
_next(undefined);
|
51
|
+
});
|
52
|
+
};
|
53
|
+
}
|
54
|
+
function _ts_generator(thisArg, body) {
|
55
|
+
var f, y, t, g, _ = {
|
56
|
+
label: 0,
|
57
|
+
sent: function() {
|
58
|
+
if (t[0] & 1) throw t[1];
|
59
|
+
return t[1];
|
60
|
+
},
|
61
|
+
trys: [],
|
62
|
+
ops: []
|
63
|
+
};
|
64
|
+
return g = {
|
65
|
+
next: verb(0),
|
66
|
+
"throw": verb(1),
|
67
|
+
"return": verb(2)
|
68
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
69
|
+
return this;
|
70
|
+
}), g;
|
71
|
+
function verb(n) {
|
72
|
+
return function(v) {
|
73
|
+
return step([
|
74
|
+
n,
|
75
|
+
v
|
76
|
+
]);
|
77
|
+
};
|
78
|
+
}
|
79
|
+
function step(op) {
|
80
|
+
if (f) throw new TypeError("Generator is already executing.");
|
81
|
+
while(_)try {
|
82
|
+
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;
|
83
|
+
if (y = 0, t) op = [
|
84
|
+
op[0] & 2,
|
85
|
+
t.value
|
86
|
+
];
|
87
|
+
switch(op[0]){
|
88
|
+
case 0:
|
89
|
+
case 1:
|
90
|
+
t = op;
|
91
|
+
break;
|
92
|
+
case 4:
|
93
|
+
_.label++;
|
94
|
+
return {
|
95
|
+
value: op[1],
|
96
|
+
done: false
|
97
|
+
};
|
98
|
+
case 5:
|
99
|
+
_.label++;
|
100
|
+
y = op[1];
|
101
|
+
op = [
|
102
|
+
0
|
103
|
+
];
|
104
|
+
continue;
|
105
|
+
case 7:
|
106
|
+
op = _.ops.pop();
|
107
|
+
_.trys.pop();
|
108
|
+
continue;
|
109
|
+
default:
|
110
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
111
|
+
_ = 0;
|
112
|
+
continue;
|
113
|
+
}
|
114
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
115
|
+
_.label = op[1];
|
116
|
+
break;
|
117
|
+
}
|
118
|
+
if (op[0] === 6 && _.label < t[1]) {
|
119
|
+
_.label = t[1];
|
120
|
+
t = op;
|
121
|
+
break;
|
122
|
+
}
|
123
|
+
if (t && _.label < t[2]) {
|
124
|
+
_.label = t[2];
|
125
|
+
_.ops.push(op);
|
126
|
+
break;
|
127
|
+
}
|
128
|
+
if (t[2]) _.ops.pop();
|
129
|
+
_.trys.pop();
|
130
|
+
continue;
|
131
|
+
}
|
132
|
+
op = body.call(thisArg, _);
|
133
|
+
} catch (e) {
|
134
|
+
op = [
|
135
|
+
6,
|
136
|
+
e
|
137
|
+
];
|
138
|
+
y = 0;
|
139
|
+
} finally{
|
140
|
+
f = t = 0;
|
141
|
+
}
|
142
|
+
if (op[0] & 5) throw op[1];
|
143
|
+
return {
|
144
|
+
value: op[0] ? op[1] : void 0,
|
145
|
+
done: true
|
146
|
+
};
|
147
|
+
}
|
148
|
+
}
|
149
|
+
function optional(args) {
|
150
|
+
return {
|
151
|
+
type: 'high',
|
152
|
+
// eslint-disable-next-line ts/require-await
|
153
|
+
callback: function() {
|
154
|
+
var _ref = _async_to_generator(function(value, path) {
|
155
|
+
return _ts_generator(this, function(_state) {
|
156
|
+
if (value === undefined) {
|
157
|
+
if (args.allow === true) return [
|
158
|
+
2,
|
159
|
+
{
|
160
|
+
parsed: value,
|
161
|
+
errors: [],
|
162
|
+
preventChildValidation: true
|
163
|
+
}
|
164
|
+
];
|
165
|
+
return [
|
166
|
+
2,
|
167
|
+
{
|
168
|
+
parsed: value,
|
169
|
+
errors: [
|
170
|
+
{
|
171
|
+
isValid: false,
|
172
|
+
message: args.message,
|
173
|
+
code: 'required',
|
174
|
+
// eslint-disable-next-line ts/no-unnecessary-condition
|
175
|
+
path: path || []
|
176
|
+
}
|
177
|
+
],
|
178
|
+
preventChildValidation: true
|
179
|
+
}
|
180
|
+
];
|
181
|
+
}
|
182
|
+
return [
|
183
|
+
2,
|
184
|
+
{
|
185
|
+
parsed: value,
|
186
|
+
errors: [],
|
187
|
+
preventChildValidation: false
|
188
|
+
}
|
189
|
+
];
|
190
|
+
});
|
191
|
+
});
|
192
|
+
return function(value, path) {
|
193
|
+
return _ref.apply(this, arguments);
|
194
|
+
};
|
195
|
+
}()
|
196
|
+
};
|
197
|
+
}
|
198
|
+
function nullable(args) {
|
199
|
+
return {
|
200
|
+
type: 'high',
|
201
|
+
// eslint-disable-next-line ts/require-await
|
202
|
+
callback: function() {
|
203
|
+
var _ref = _async_to_generator(function(value, path) {
|
204
|
+
return _ts_generator(this, function(_state) {
|
205
|
+
if (value === null) {
|
206
|
+
if (args.allow === true) return [
|
207
|
+
2,
|
208
|
+
{
|
209
|
+
parsed: value,
|
210
|
+
errors: [],
|
211
|
+
preventChildValidation: true
|
212
|
+
}
|
213
|
+
];
|
214
|
+
return [
|
215
|
+
2,
|
216
|
+
{
|
217
|
+
parsed: value,
|
218
|
+
errors: [
|
219
|
+
{
|
220
|
+
isValid: false,
|
221
|
+
message: args.message,
|
222
|
+
code: 'cannot_be_null',
|
223
|
+
// eslint-disable-next-line ts/no-unnecessary-condition
|
224
|
+
path: path || []
|
225
|
+
}
|
226
|
+
],
|
227
|
+
preventChildValidation: true
|
228
|
+
}
|
229
|
+
];
|
230
|
+
}
|
231
|
+
return [
|
232
|
+
2,
|
233
|
+
{
|
234
|
+
parsed: value,
|
235
|
+
errors: [],
|
236
|
+
preventChildValidation: false
|
237
|
+
}
|
238
|
+
];
|
239
|
+
});
|
240
|
+
});
|
241
|
+
return function(value, path) {
|
242
|
+
return _ref.apply(this, arguments);
|
243
|
+
};
|
244
|
+
}()
|
245
|
+
};
|
246
|
+
}
|
247
|
+
function checkType(args) {
|
248
|
+
return {
|
249
|
+
type: 'medium',
|
250
|
+
// eslint-disable-next-line ts/require-await
|
251
|
+
callback: function() {
|
252
|
+
var _ref = _async_to_generator(function(value, path) {
|
253
|
+
return _ts_generator(this, function(_state) {
|
254
|
+
if (args.check(value)) return [
|
255
|
+
2,
|
256
|
+
{
|
257
|
+
parsed: value,
|
258
|
+
errors: [],
|
259
|
+
preventChildValidation: false
|
260
|
+
}
|
261
|
+
];
|
262
|
+
return [
|
263
|
+
2,
|
264
|
+
{
|
265
|
+
parsed: value,
|
266
|
+
errors: [
|
267
|
+
{
|
268
|
+
isValid: false,
|
269
|
+
message: args.message,
|
270
|
+
code: 'invalid_type',
|
271
|
+
// eslint-disable-next-line ts/no-unnecessary-condition
|
272
|
+
path: path || []
|
273
|
+
}
|
274
|
+
],
|
275
|
+
preventChildValidation: true
|
276
|
+
}
|
277
|
+
];
|
278
|
+
});
|
279
|
+
});
|
280
|
+
return function(value, path) {
|
281
|
+
return _ref.apply(this, arguments);
|
282
|
+
};
|
283
|
+
}()
|
284
|
+
};
|
285
|
+
}
|
286
|
+
function is(args) {
|
287
|
+
return {
|
288
|
+
type: 'medium',
|
289
|
+
// eslint-disable-next-line ts/require-await
|
290
|
+
callback: function() {
|
291
|
+
var _ref = _async_to_generator(function(value, path, _options) {
|
292
|
+
var isValid;
|
293
|
+
return _ts_generator(this, function(_state) {
|
294
|
+
isValid = Array.isArray(args.value) ? args.value.includes(value) : value === args.value;
|
295
|
+
return [
|
296
|
+
2,
|
297
|
+
{
|
298
|
+
parsed: value,
|
299
|
+
errors: isValid ? [] : [
|
300
|
+
{
|
301
|
+
isValid: false,
|
302
|
+
code: 'is',
|
303
|
+
// eslint-disable-next-line ts/no-unnecessary-condition
|
304
|
+
path: path || [],
|
305
|
+
message: 'Value is not a boolean'
|
306
|
+
}
|
307
|
+
],
|
308
|
+
preventChildValidation: true
|
309
|
+
}
|
310
|
+
];
|
311
|
+
});
|
312
|
+
});
|
313
|
+
return function(value, path, _options) {
|
314
|
+
return _ref.apply(this, arguments);
|
315
|
+
};
|
316
|
+
}()
|
317
|
+
};
|
318
|
+
}
|