@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,287 @@
|
|
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
|
+
above: function() {
|
13
|
+
return above;
|
14
|
+
},
|
15
|
+
allowStringParser: function() {
|
16
|
+
return allowStringParser;
|
17
|
+
},
|
18
|
+
below: function() {
|
19
|
+
return below;
|
20
|
+
},
|
21
|
+
datetimeValidation: function() {
|
22
|
+
return datetimeValidation;
|
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 _instanceof(left, right) {
|
55
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
56
|
+
return !!right[Symbol.hasInstance](left);
|
57
|
+
} else {
|
58
|
+
return left instanceof right;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
function _ts_generator(thisArg, body) {
|
62
|
+
var f, y, t, g, _ = {
|
63
|
+
label: 0,
|
64
|
+
sent: function() {
|
65
|
+
if (t[0] & 1) throw t[1];
|
66
|
+
return t[1];
|
67
|
+
},
|
68
|
+
trys: [],
|
69
|
+
ops: []
|
70
|
+
};
|
71
|
+
return g = {
|
72
|
+
next: verb(0),
|
73
|
+
"throw": verb(1),
|
74
|
+
"return": verb(2)
|
75
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
76
|
+
return this;
|
77
|
+
}), g;
|
78
|
+
function verb(n) {
|
79
|
+
return function(v) {
|
80
|
+
return step([
|
81
|
+
n,
|
82
|
+
v
|
83
|
+
]);
|
84
|
+
};
|
85
|
+
}
|
86
|
+
function step(op) {
|
87
|
+
if (f) throw new TypeError("Generator is already executing.");
|
88
|
+
while(_)try {
|
89
|
+
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;
|
90
|
+
if (y = 0, t) op = [
|
91
|
+
op[0] & 2,
|
92
|
+
t.value
|
93
|
+
];
|
94
|
+
switch(op[0]){
|
95
|
+
case 0:
|
96
|
+
case 1:
|
97
|
+
t = op;
|
98
|
+
break;
|
99
|
+
case 4:
|
100
|
+
_.label++;
|
101
|
+
return {
|
102
|
+
value: op[1],
|
103
|
+
done: false
|
104
|
+
};
|
105
|
+
case 5:
|
106
|
+
_.label++;
|
107
|
+
y = op[1];
|
108
|
+
op = [
|
109
|
+
0
|
110
|
+
];
|
111
|
+
continue;
|
112
|
+
case 7:
|
113
|
+
op = _.ops.pop();
|
114
|
+
_.trys.pop();
|
115
|
+
continue;
|
116
|
+
default:
|
117
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
118
|
+
_ = 0;
|
119
|
+
continue;
|
120
|
+
}
|
121
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
122
|
+
_.label = op[1];
|
123
|
+
break;
|
124
|
+
}
|
125
|
+
if (op[0] === 6 && _.label < t[1]) {
|
126
|
+
_.label = t[1];
|
127
|
+
t = op;
|
128
|
+
break;
|
129
|
+
}
|
130
|
+
if (t && _.label < t[2]) {
|
131
|
+
_.label = t[2];
|
132
|
+
_.ops.push(op);
|
133
|
+
break;
|
134
|
+
}
|
135
|
+
if (t[2]) _.ops.pop();
|
136
|
+
_.trys.pop();
|
137
|
+
continue;
|
138
|
+
}
|
139
|
+
op = body.call(thisArg, _);
|
140
|
+
} catch (e) {
|
141
|
+
op = [
|
142
|
+
6,
|
143
|
+
e
|
144
|
+
];
|
145
|
+
y = 0;
|
146
|
+
} finally{
|
147
|
+
f = t = 0;
|
148
|
+
}
|
149
|
+
if (op[0] & 5) throw op[1];
|
150
|
+
return {
|
151
|
+
value: op[0] ? op[1] : void 0,
|
152
|
+
done: true
|
153
|
+
};
|
154
|
+
}
|
155
|
+
}
|
156
|
+
function datetimeValidation() {
|
157
|
+
return {
|
158
|
+
type: 'medium',
|
159
|
+
// eslint-disable-next-line ts/require-await
|
160
|
+
callback: function() {
|
161
|
+
var _ref = _async_to_generator(function(value, path, _options) {
|
162
|
+
var isValid;
|
163
|
+
return _ts_generator(this, function(_state) {
|
164
|
+
isValid = _instanceof(value, Date) && !isNaN(value.getTime());
|
165
|
+
return [
|
166
|
+
2,
|
167
|
+
{
|
168
|
+
parsed: value,
|
169
|
+
errors: isValid ? [] : [
|
170
|
+
{
|
171
|
+
isValid: false,
|
172
|
+
code: 'datetime',
|
173
|
+
// eslint-disable-next-line ts/no-unnecessary-condition
|
174
|
+
path: path || [],
|
175
|
+
message: 'Value is not a date'
|
176
|
+
}
|
177
|
+
],
|
178
|
+
preventChildValidation: true
|
179
|
+
}
|
180
|
+
];
|
181
|
+
});
|
182
|
+
});
|
183
|
+
return function(value, path, _options) {
|
184
|
+
return _ref.apply(this, arguments);
|
185
|
+
};
|
186
|
+
}()
|
187
|
+
};
|
188
|
+
}
|
189
|
+
function allowStringParser() {
|
190
|
+
return {
|
191
|
+
type: 'high',
|
192
|
+
// eslint-disable-next-line ts/require-await
|
193
|
+
callback: function() {
|
194
|
+
var _ref = _async_to_generator(function(value, _path, _options) {
|
195
|
+
var parsed;
|
196
|
+
return _ts_generator(this, function(_state) {
|
197
|
+
if (typeof value === 'string') {
|
198
|
+
parsed = new Date(value);
|
199
|
+
if (_instanceof(parsed, Date) && !isNaN(parsed.getTime())) {
|
200
|
+
return [
|
201
|
+
2,
|
202
|
+
{
|
203
|
+
parsed: parsed,
|
204
|
+
errors: []
|
205
|
+
}
|
206
|
+
];
|
207
|
+
}
|
208
|
+
}
|
209
|
+
return [
|
210
|
+
2,
|
211
|
+
{
|
212
|
+
parsed: value,
|
213
|
+
errors: []
|
214
|
+
}
|
215
|
+
];
|
216
|
+
});
|
217
|
+
});
|
218
|
+
return function(value, _path, _options) {
|
219
|
+
return _ref.apply(this, arguments);
|
220
|
+
};
|
221
|
+
}()
|
222
|
+
};
|
223
|
+
}
|
224
|
+
function below(args) {
|
225
|
+
return {
|
226
|
+
type: 'low',
|
227
|
+
// eslint-disable-next-line ts/require-await
|
228
|
+
callback: function() {
|
229
|
+
var _ref = _async_to_generator(function(value, path, _options) {
|
230
|
+
var isValid;
|
231
|
+
return _ts_generator(this, function(_state) {
|
232
|
+
isValid = args.inclusive ? value <= args.value : value < args.value;
|
233
|
+
return [
|
234
|
+
2,
|
235
|
+
{
|
236
|
+
parsed: value,
|
237
|
+
errors: isValid ? [] : [
|
238
|
+
{
|
239
|
+
isValid: false,
|
240
|
+
code: 'below',
|
241
|
+
// eslint-disable-next-line ts/no-unnecessary-condition
|
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 above(args) {
|
257
|
+
return {
|
258
|
+
type: 'low',
|
259
|
+
// eslint-disable-next-line ts/require-await
|
260
|
+
callback: function() {
|
261
|
+
var _ref = _async_to_generator(function(value, path, _options) {
|
262
|
+
var isValid;
|
263
|
+
return _ts_generator(this, function(_state) {
|
264
|
+
isValid = args.inclusive ? value <= args.value : value < args.value;
|
265
|
+
return [
|
266
|
+
2,
|
267
|
+
{
|
268
|
+
parsed: value,
|
269
|
+
errors: isValid ? [] : [
|
270
|
+
{
|
271
|
+
isValid: false,
|
272
|
+
code: 'above',
|
273
|
+
// eslint-disable-next-line ts/no-unnecessary-condition
|
274
|
+
path: path || [],
|
275
|
+
message: args.message
|
276
|
+
}
|
277
|
+
]
|
278
|
+
}
|
279
|
+
];
|
280
|
+
});
|
281
|
+
});
|
282
|
+
return function(value, path, _options) {
|
283
|
+
return _ref.apply(this, arguments);
|
284
|
+
};
|
285
|
+
}()
|
286
|
+
};
|
287
|
+
}
|
@@ -0,0 +1,403 @@
|
|
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
|
+
decimalPlaces: function() {
|
13
|
+
return decimalPlaces;
|
14
|
+
},
|
15
|
+
max: function() {
|
16
|
+
return max;
|
17
|
+
},
|
18
|
+
maxDigits: function() {
|
19
|
+
return maxDigits;
|
20
|
+
},
|
21
|
+
min: function() {
|
22
|
+
return min;
|
23
|
+
},
|
24
|
+
negative: function() {
|
25
|
+
return negative;
|
26
|
+
},
|
27
|
+
numberValidation: function() {
|
28
|
+
return numberValidation;
|
29
|
+
},
|
30
|
+
positive: function() {
|
31
|
+
return positive;
|
32
|
+
}
|
33
|
+
});
|
34
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
35
|
+
try {
|
36
|
+
var info = gen[key](arg);
|
37
|
+
var value = info.value;
|
38
|
+
} catch (error) {
|
39
|
+
reject(error);
|
40
|
+
return;
|
41
|
+
}
|
42
|
+
if (info.done) {
|
43
|
+
resolve(value);
|
44
|
+
} else {
|
45
|
+
Promise.resolve(value).then(_next, _throw);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
function _async_to_generator(fn) {
|
49
|
+
return function() {
|
50
|
+
var self = this, args = arguments;
|
51
|
+
return new Promise(function(resolve, reject) {
|
52
|
+
var gen = fn.apply(self, args);
|
53
|
+
function _next(value) {
|
54
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
55
|
+
}
|
56
|
+
function _throw(err) {
|
57
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
58
|
+
}
|
59
|
+
_next(undefined);
|
60
|
+
});
|
61
|
+
};
|
62
|
+
}
|
63
|
+
function _type_of(obj) {
|
64
|
+
"@swc/helpers - typeof";
|
65
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
66
|
+
}
|
67
|
+
function _ts_generator(thisArg, body) {
|
68
|
+
var f, y, t, g, _ = {
|
69
|
+
label: 0,
|
70
|
+
sent: function() {
|
71
|
+
if (t[0] & 1) throw t[1];
|
72
|
+
return t[1];
|
73
|
+
},
|
74
|
+
trys: [],
|
75
|
+
ops: []
|
76
|
+
};
|
77
|
+
return g = {
|
78
|
+
next: verb(0),
|
79
|
+
"throw": verb(1),
|
80
|
+
"return": verb(2)
|
81
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
82
|
+
return this;
|
83
|
+
}), g;
|
84
|
+
function verb(n) {
|
85
|
+
return function(v) {
|
86
|
+
return step([
|
87
|
+
n,
|
88
|
+
v
|
89
|
+
]);
|
90
|
+
};
|
91
|
+
}
|
92
|
+
function step(op) {
|
93
|
+
if (f) throw new TypeError("Generator is already executing.");
|
94
|
+
while(_)try {
|
95
|
+
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;
|
96
|
+
if (y = 0, t) op = [
|
97
|
+
op[0] & 2,
|
98
|
+
t.value
|
99
|
+
];
|
100
|
+
switch(op[0]){
|
101
|
+
case 0:
|
102
|
+
case 1:
|
103
|
+
t = op;
|
104
|
+
break;
|
105
|
+
case 4:
|
106
|
+
_.label++;
|
107
|
+
return {
|
108
|
+
value: op[1],
|
109
|
+
done: false
|
110
|
+
};
|
111
|
+
case 5:
|
112
|
+
_.label++;
|
113
|
+
y = op[1];
|
114
|
+
op = [
|
115
|
+
0
|
116
|
+
];
|
117
|
+
continue;
|
118
|
+
case 7:
|
119
|
+
op = _.ops.pop();
|
120
|
+
_.trys.pop();
|
121
|
+
continue;
|
122
|
+
default:
|
123
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
124
|
+
_ = 0;
|
125
|
+
continue;
|
126
|
+
}
|
127
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
128
|
+
_.label = op[1];
|
129
|
+
break;
|
130
|
+
}
|
131
|
+
if (op[0] === 6 && _.label < t[1]) {
|
132
|
+
_.label = t[1];
|
133
|
+
t = op;
|
134
|
+
break;
|
135
|
+
}
|
136
|
+
if (t && _.label < t[2]) {
|
137
|
+
_.label = t[2];
|
138
|
+
_.ops.push(op);
|
139
|
+
break;
|
140
|
+
}
|
141
|
+
if (t[2]) _.ops.pop();
|
142
|
+
_.trys.pop();
|
143
|
+
continue;
|
144
|
+
}
|
145
|
+
op = body.call(thisArg, _);
|
146
|
+
} catch (e) {
|
147
|
+
op = [
|
148
|
+
6,
|
149
|
+
e
|
150
|
+
];
|
151
|
+
y = 0;
|
152
|
+
} finally{
|
153
|
+
f = t = 0;
|
154
|
+
}
|
155
|
+
if (op[0] & 5) throw op[1];
|
156
|
+
return {
|
157
|
+
value: op[0] ? op[1] : void 0,
|
158
|
+
done: true
|
159
|
+
};
|
160
|
+
}
|
161
|
+
}
|
162
|
+
function numberValidation() {
|
163
|
+
return {
|
164
|
+
type: 'medium',
|
165
|
+
// eslint-disable-next-line ts/require-await
|
166
|
+
callback: function() {
|
167
|
+
var _ref = _async_to_generator(function(value, path, _options) {
|
168
|
+
return _ts_generator(this, function(_state) {
|
169
|
+
return [
|
170
|
+
2,
|
171
|
+
{
|
172
|
+
parsed: value,
|
173
|
+
errors: [
|
174
|
+
{
|
175
|
+
isValid: typeof value === 'number',
|
176
|
+
code: 'number',
|
177
|
+
// eslint-disable-next-line ts/no-unnecessary-condition
|
178
|
+
path: path || [],
|
179
|
+
message: 'The value must be a number. Received: ' + (typeof value === "undefined" ? "undefined" : _type_of(value))
|
180
|
+
}
|
181
|
+
]
|
182
|
+
}
|
183
|
+
];
|
184
|
+
});
|
185
|
+
});
|
186
|
+
return function(value, path, _options) {
|
187
|
+
return _ref.apply(this, arguments);
|
188
|
+
};
|
189
|
+
}()
|
190
|
+
};
|
191
|
+
}
|
192
|
+
function max(args) {
|
193
|
+
return {
|
194
|
+
type: 'low',
|
195
|
+
// eslint-disable-next-line ts/require-await
|
196
|
+
callback: function() {
|
197
|
+
var _ref = _async_to_generator(function(value, path, _options) {
|
198
|
+
return _ts_generator(this, function(_state) {
|
199
|
+
if (args.inclusive) return [
|
200
|
+
2,
|
201
|
+
{
|
202
|
+
parsed: value,
|
203
|
+
errors: [
|
204
|
+
{
|
205
|
+
isValid: value <= args.value,
|
206
|
+
code: 'max',
|
207
|
+
// eslint-disable-next-line ts/no-unnecessary-condition
|
208
|
+
path: path || [],
|
209
|
+
message: args.message
|
210
|
+
}
|
211
|
+
]
|
212
|
+
}
|
213
|
+
];
|
214
|
+
return [
|
215
|
+
2,
|
216
|
+
{
|
217
|
+
parsed: value,
|
218
|
+
errors: [
|
219
|
+
{
|
220
|
+
isValid: value < args.value,
|
221
|
+
code: 'max',
|
222
|
+
// eslint-disable-next-line ts/no-unnecessary-condition
|
223
|
+
path: path || [],
|
224
|
+
message: args.message
|
225
|
+
}
|
226
|
+
]
|
227
|
+
}
|
228
|
+
];
|
229
|
+
});
|
230
|
+
});
|
231
|
+
return function(value, path, _options) {
|
232
|
+
return _ref.apply(this, arguments);
|
233
|
+
};
|
234
|
+
}()
|
235
|
+
};
|
236
|
+
}
|
237
|
+
function min(args) {
|
238
|
+
return {
|
239
|
+
type: 'low',
|
240
|
+
// eslint-disable-next-line ts/require-await
|
241
|
+
callback: function() {
|
242
|
+
var _ref = _async_to_generator(function(value, path) {
|
243
|
+
return _ts_generator(this, function(_state) {
|
244
|
+
if (args.inclusive) return [
|
245
|
+
2,
|
246
|
+
{
|
247
|
+
parsed: value,
|
248
|
+
errors: [
|
249
|
+
{
|
250
|
+
isValid: value >= args.value,
|
251
|
+
message: args.message,
|
252
|
+
code: 'min',
|
253
|
+
path: path || []
|
254
|
+
}
|
255
|
+
]
|
256
|
+
}
|
257
|
+
];
|
258
|
+
return [
|
259
|
+
2,
|
260
|
+
{
|
261
|
+
parsed: value,
|
262
|
+
errors: [
|
263
|
+
{
|
264
|
+
isValid: value > args.value,
|
265
|
+
message: args.message,
|
266
|
+
code: 'min',
|
267
|
+
path: path || []
|
268
|
+
}
|
269
|
+
]
|
270
|
+
}
|
271
|
+
];
|
272
|
+
});
|
273
|
+
});
|
274
|
+
return function(value, path) {
|
275
|
+
return _ref.apply(this, arguments);
|
276
|
+
};
|
277
|
+
}()
|
278
|
+
};
|
279
|
+
}
|
280
|
+
function negative(args) {
|
281
|
+
return {
|
282
|
+
type: 'low',
|
283
|
+
// eslint-disable-next-line ts/require-await
|
284
|
+
callback: function() {
|
285
|
+
var _ref = _async_to_generator(function(value, path) {
|
286
|
+
var isValid;
|
287
|
+
return _ts_generator(this, function(_state) {
|
288
|
+
isValid = args.allowZero ? value < 0 : value <= 0;
|
289
|
+
return [
|
290
|
+
2,
|
291
|
+
{
|
292
|
+
parsed: value,
|
293
|
+
errors: isValid ? [] : [
|
294
|
+
{
|
295
|
+
isValid: isValid,
|
296
|
+
message: args.message,
|
297
|
+
code: 'negative',
|
298
|
+
path: path || []
|
299
|
+
}
|
300
|
+
]
|
301
|
+
}
|
302
|
+
];
|
303
|
+
});
|
304
|
+
});
|
305
|
+
return function(value, path) {
|
306
|
+
return _ref.apply(this, arguments);
|
307
|
+
};
|
308
|
+
}()
|
309
|
+
};
|
310
|
+
}
|
311
|
+
function positive(args) {
|
312
|
+
return {
|
313
|
+
type: 'low',
|
314
|
+
// eslint-disable-next-line ts/require-await
|
315
|
+
callback: function() {
|
316
|
+
var _ref = _async_to_generator(function(value, path) {
|
317
|
+
var isValid;
|
318
|
+
return _ts_generator(this, function(_state) {
|
319
|
+
isValid = args.allowZero ? value > 0 : value >= 0;
|
320
|
+
return [
|
321
|
+
2,
|
322
|
+
{
|
323
|
+
parsed: value,
|
324
|
+
errors: isValid ? [] : [
|
325
|
+
{
|
326
|
+
isValid: isValid,
|
327
|
+
message: args.message,
|
328
|
+
code: 'positive',
|
329
|
+
path: path || []
|
330
|
+
}
|
331
|
+
]
|
332
|
+
}
|
333
|
+
];
|
334
|
+
});
|
335
|
+
});
|
336
|
+
return function(value, path) {
|
337
|
+
return _ref.apply(this, arguments);
|
338
|
+
};
|
339
|
+
}()
|
340
|
+
};
|
341
|
+
}
|
342
|
+
function maxDigits(args) {
|
343
|
+
return {
|
344
|
+
type: 'low',
|
345
|
+
// eslint-disable-next-line ts/require-await
|
346
|
+
callback: function() {
|
347
|
+
var _ref = _async_to_generator(function(value, path) {
|
348
|
+
var isValid;
|
349
|
+
return _ts_generator(this, function(_state) {
|
350
|
+
isValid = value.toString().replace('.', '').length <= args.value;
|
351
|
+
return [
|
352
|
+
2,
|
353
|
+
{
|
354
|
+
parsed: value,
|
355
|
+
errors: isValid ? [] : [
|
356
|
+
{
|
357
|
+
isValid: isValid,
|
358
|
+
message: args.message,
|
359
|
+
code: 'maxDigits',
|
360
|
+
path: path || []
|
361
|
+
}
|
362
|
+
]
|
363
|
+
}
|
364
|
+
];
|
365
|
+
});
|
366
|
+
});
|
367
|
+
return function(value, path) {
|
368
|
+
return _ref.apply(this, arguments);
|
369
|
+
};
|
370
|
+
}()
|
371
|
+
};
|
372
|
+
}
|
373
|
+
function decimalPlaces(args) {
|
374
|
+
return {
|
375
|
+
type: 'low',
|
376
|
+
// eslint-disable-next-line ts/require-await
|
377
|
+
callback: function() {
|
378
|
+
var _ref = _async_to_generator(function(value, path) {
|
379
|
+
var _value_toString_split_, isValid;
|
380
|
+
return _ts_generator(this, function(_state) {
|
381
|
+
isValid = ((_value_toString_split_ = value.toString().split('.')[1]) === null || _value_toString_split_ === void 0 ? void 0 : _value_toString_split_.length) <= args.value;
|
382
|
+
return [
|
383
|
+
2,
|
384
|
+
{
|
385
|
+
parsed: value,
|
386
|
+
errors: isValid ? [] : [
|
387
|
+
{
|
388
|
+
isValid: isValid,
|
389
|
+
message: args.message,
|
390
|
+
code: 'decimalPlaces',
|
391
|
+
path: path || []
|
392
|
+
}
|
393
|
+
]
|
394
|
+
}
|
395
|
+
];
|
396
|
+
});
|
397
|
+
});
|
398
|
+
return function(value, path) {
|
399
|
+
return _ref.apply(this, arguments);
|
400
|
+
};
|
401
|
+
}()
|
402
|
+
};
|
403
|
+
}
|