quival 0.2.2 → 0.2.4
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/README.md +63 -7
- package/dist/locales/en.js +175 -0
- package/dist/locales/en.min.js +6 -0
- package/dist/locales/ms.js +175 -0
- package/dist/locales/ms.min.js +6 -0
- package/dist/quival.js +3036 -0
- package/dist/quival.min.js +6 -0
- package/package.json +12 -3
- package/rollup.config.js +79 -0
- package/src/Checkers.js +11 -11
- package/test/test.js +36 -31
package/dist/quival.js
ADDED
|
@@ -0,0 +1,3036 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* quival v0.2.4 (https://github.com/apih/quival)
|
|
3
|
+
* (c) 2023 Mohd Hafizuddin M Marzuki <hafizuddin_83@yahoo.com>
|
|
4
|
+
* Released under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
var quival = (function (exports) {
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
function _iterableToArrayLimit(arr, i) {
|
|
10
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
11
|
+
if (null != _i) {
|
|
12
|
+
var _s,
|
|
13
|
+
_e,
|
|
14
|
+
_x,
|
|
15
|
+
_r,
|
|
16
|
+
_arr = [],
|
|
17
|
+
_n = !0,
|
|
18
|
+
_d = !1;
|
|
19
|
+
try {
|
|
20
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
21
|
+
if (Object(_i) !== _i) return;
|
|
22
|
+
_n = !1;
|
|
23
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
24
|
+
} catch (err) {
|
|
25
|
+
_d = !0, _e = err;
|
|
26
|
+
} finally {
|
|
27
|
+
try {
|
|
28
|
+
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
29
|
+
} finally {
|
|
30
|
+
if (_d) throw _e;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return _arr;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function _regeneratorRuntime() {
|
|
37
|
+
_regeneratorRuntime = function () {
|
|
38
|
+
return exports;
|
|
39
|
+
};
|
|
40
|
+
var exports = {},
|
|
41
|
+
Op = Object.prototype,
|
|
42
|
+
hasOwn = Op.hasOwnProperty,
|
|
43
|
+
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
|
44
|
+
obj[key] = desc.value;
|
|
45
|
+
},
|
|
46
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
47
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
48
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
49
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
50
|
+
function define(obj, key, value) {
|
|
51
|
+
return Object.defineProperty(obj, key, {
|
|
52
|
+
value: value,
|
|
53
|
+
enumerable: !0,
|
|
54
|
+
configurable: !0,
|
|
55
|
+
writable: !0
|
|
56
|
+
}), obj[key];
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
define({}, "");
|
|
60
|
+
} catch (err) {
|
|
61
|
+
define = function (obj, key, value) {
|
|
62
|
+
return obj[key] = value;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
66
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
67
|
+
generator = Object.create(protoGenerator.prototype),
|
|
68
|
+
context = new Context(tryLocsList || []);
|
|
69
|
+
return defineProperty(generator, "_invoke", {
|
|
70
|
+
value: makeInvokeMethod(innerFn, self, context)
|
|
71
|
+
}), generator;
|
|
72
|
+
}
|
|
73
|
+
function tryCatch(fn, obj, arg) {
|
|
74
|
+
try {
|
|
75
|
+
return {
|
|
76
|
+
type: "normal",
|
|
77
|
+
arg: fn.call(obj, arg)
|
|
78
|
+
};
|
|
79
|
+
} catch (err) {
|
|
80
|
+
return {
|
|
81
|
+
type: "throw",
|
|
82
|
+
arg: err
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.wrap = wrap;
|
|
87
|
+
var ContinueSentinel = {};
|
|
88
|
+
function Generator() {}
|
|
89
|
+
function GeneratorFunction() {}
|
|
90
|
+
function GeneratorFunctionPrototype() {}
|
|
91
|
+
var IteratorPrototype = {};
|
|
92
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
93
|
+
return this;
|
|
94
|
+
});
|
|
95
|
+
var getProto = Object.getPrototypeOf,
|
|
96
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
97
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
98
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
99
|
+
function defineIteratorMethods(prototype) {
|
|
100
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
101
|
+
define(prototype, method, function (arg) {
|
|
102
|
+
return this._invoke(method, arg);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
107
|
+
function invoke(method, arg, resolve, reject) {
|
|
108
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
109
|
+
if ("throw" !== record.type) {
|
|
110
|
+
var result = record.arg,
|
|
111
|
+
value = result.value;
|
|
112
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
113
|
+
invoke("next", value, resolve, reject);
|
|
114
|
+
}, function (err) {
|
|
115
|
+
invoke("throw", err, resolve, reject);
|
|
116
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
117
|
+
result.value = unwrapped, resolve(result);
|
|
118
|
+
}, function (error) {
|
|
119
|
+
return invoke("throw", error, resolve, reject);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
reject(record.arg);
|
|
123
|
+
}
|
|
124
|
+
var previousPromise;
|
|
125
|
+
defineProperty(this, "_invoke", {
|
|
126
|
+
value: function (method, arg) {
|
|
127
|
+
function callInvokeWithMethodAndArg() {
|
|
128
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
129
|
+
invoke(method, arg, resolve, reject);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
137
|
+
var state = "suspendedStart";
|
|
138
|
+
return function (method, arg) {
|
|
139
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
140
|
+
if ("completed" === state) {
|
|
141
|
+
if ("throw" === method) throw arg;
|
|
142
|
+
return doneResult();
|
|
143
|
+
}
|
|
144
|
+
for (context.method = method, context.arg = arg;;) {
|
|
145
|
+
var delegate = context.delegate;
|
|
146
|
+
if (delegate) {
|
|
147
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
148
|
+
if (delegateResult) {
|
|
149
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
150
|
+
return delegateResult;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
154
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
155
|
+
context.dispatchException(context.arg);
|
|
156
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
157
|
+
state = "executing";
|
|
158
|
+
var record = tryCatch(innerFn, self, context);
|
|
159
|
+
if ("normal" === record.type) {
|
|
160
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
161
|
+
return {
|
|
162
|
+
value: record.arg,
|
|
163
|
+
done: context.done
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
171
|
+
var methodName = context.method,
|
|
172
|
+
method = delegate.iterator[methodName];
|
|
173
|
+
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
174
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
175
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
176
|
+
var info = record.arg;
|
|
177
|
+
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
178
|
+
}
|
|
179
|
+
function pushTryEntry(locs) {
|
|
180
|
+
var entry = {
|
|
181
|
+
tryLoc: locs[0]
|
|
182
|
+
};
|
|
183
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
184
|
+
}
|
|
185
|
+
function resetTryEntry(entry) {
|
|
186
|
+
var record = entry.completion || {};
|
|
187
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
188
|
+
}
|
|
189
|
+
function Context(tryLocsList) {
|
|
190
|
+
this.tryEntries = [{
|
|
191
|
+
tryLoc: "root"
|
|
192
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
193
|
+
}
|
|
194
|
+
function values(iterable) {
|
|
195
|
+
if (iterable) {
|
|
196
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
197
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
198
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
199
|
+
if (!isNaN(iterable.length)) {
|
|
200
|
+
var i = -1,
|
|
201
|
+
next = function next() {
|
|
202
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
203
|
+
return next.value = undefined, next.done = !0, next;
|
|
204
|
+
};
|
|
205
|
+
return next.next = next;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
next: doneResult
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function doneResult() {
|
|
213
|
+
return {
|
|
214
|
+
value: undefined,
|
|
215
|
+
done: !0
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
|
219
|
+
value: GeneratorFunctionPrototype,
|
|
220
|
+
configurable: !0
|
|
221
|
+
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
222
|
+
value: GeneratorFunction,
|
|
223
|
+
configurable: !0
|
|
224
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
225
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
226
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
227
|
+
}, exports.mark = function (genFun) {
|
|
228
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
229
|
+
}, exports.awrap = function (arg) {
|
|
230
|
+
return {
|
|
231
|
+
__await: arg
|
|
232
|
+
};
|
|
233
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
234
|
+
return this;
|
|
235
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
236
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
237
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
238
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
239
|
+
return result.done ? result.value : iter.next();
|
|
240
|
+
});
|
|
241
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
242
|
+
return this;
|
|
243
|
+
}), define(Gp, "toString", function () {
|
|
244
|
+
return "[object Generator]";
|
|
245
|
+
}), exports.keys = function (val) {
|
|
246
|
+
var object = Object(val),
|
|
247
|
+
keys = [];
|
|
248
|
+
for (var key in object) keys.push(key);
|
|
249
|
+
return keys.reverse(), function next() {
|
|
250
|
+
for (; keys.length;) {
|
|
251
|
+
var key = keys.pop();
|
|
252
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
253
|
+
}
|
|
254
|
+
return next.done = !0, next;
|
|
255
|
+
};
|
|
256
|
+
}, exports.values = values, Context.prototype = {
|
|
257
|
+
constructor: Context,
|
|
258
|
+
reset: function (skipTempReset) {
|
|
259
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
260
|
+
},
|
|
261
|
+
stop: function () {
|
|
262
|
+
this.done = !0;
|
|
263
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
264
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
265
|
+
return this.rval;
|
|
266
|
+
},
|
|
267
|
+
dispatchException: function (exception) {
|
|
268
|
+
if (this.done) throw exception;
|
|
269
|
+
var context = this;
|
|
270
|
+
function handle(loc, caught) {
|
|
271
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
272
|
+
}
|
|
273
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
274
|
+
var entry = this.tryEntries[i],
|
|
275
|
+
record = entry.completion;
|
|
276
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
277
|
+
if (entry.tryLoc <= this.prev) {
|
|
278
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
279
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
280
|
+
if (hasCatch && hasFinally) {
|
|
281
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
282
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
283
|
+
} else if (hasCatch) {
|
|
284
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
285
|
+
} else {
|
|
286
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
287
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
abrupt: function (type, arg) {
|
|
293
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
294
|
+
var entry = this.tryEntries[i];
|
|
295
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
296
|
+
var finallyEntry = entry;
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
301
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
302
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
303
|
+
},
|
|
304
|
+
complete: function (record, afterLoc) {
|
|
305
|
+
if ("throw" === record.type) throw record.arg;
|
|
306
|
+
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
307
|
+
},
|
|
308
|
+
finish: function (finallyLoc) {
|
|
309
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
310
|
+
var entry = this.tryEntries[i];
|
|
311
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
catch: function (tryLoc) {
|
|
315
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
316
|
+
var entry = this.tryEntries[i];
|
|
317
|
+
if (entry.tryLoc === tryLoc) {
|
|
318
|
+
var record = entry.completion;
|
|
319
|
+
if ("throw" === record.type) {
|
|
320
|
+
var thrown = record.arg;
|
|
321
|
+
resetTryEntry(entry);
|
|
322
|
+
}
|
|
323
|
+
return thrown;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
throw new Error("illegal catch attempt");
|
|
327
|
+
},
|
|
328
|
+
delegateYield: function (iterable, resultName, nextLoc) {
|
|
329
|
+
return this.delegate = {
|
|
330
|
+
iterator: values(iterable),
|
|
331
|
+
resultName: resultName,
|
|
332
|
+
nextLoc: nextLoc
|
|
333
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
334
|
+
}
|
|
335
|
+
}, exports;
|
|
336
|
+
}
|
|
337
|
+
function _typeof(obj) {
|
|
338
|
+
"@babel/helpers - typeof";
|
|
339
|
+
|
|
340
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
341
|
+
return typeof obj;
|
|
342
|
+
} : function (obj) {
|
|
343
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
344
|
+
}, _typeof(obj);
|
|
345
|
+
}
|
|
346
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
347
|
+
try {
|
|
348
|
+
var info = gen[key](arg);
|
|
349
|
+
var value = info.value;
|
|
350
|
+
} catch (error) {
|
|
351
|
+
reject(error);
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
if (info.done) {
|
|
355
|
+
resolve(value);
|
|
356
|
+
} else {
|
|
357
|
+
Promise.resolve(value).then(_next, _throw);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
function _asyncToGenerator(fn) {
|
|
361
|
+
return function () {
|
|
362
|
+
var self = this,
|
|
363
|
+
args = arguments;
|
|
364
|
+
return new Promise(function (resolve, reject) {
|
|
365
|
+
var gen = fn.apply(self, args);
|
|
366
|
+
function _next(value) {
|
|
367
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
368
|
+
}
|
|
369
|
+
function _throw(err) {
|
|
370
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
371
|
+
}
|
|
372
|
+
_next(undefined);
|
|
373
|
+
});
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
function _classCallCheck(instance, Constructor) {
|
|
377
|
+
if (!(instance instanceof Constructor)) {
|
|
378
|
+
throw new TypeError("Cannot call a class as a function");
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function _defineProperties(target, props) {
|
|
382
|
+
for (var i = 0; i < props.length; i++) {
|
|
383
|
+
var descriptor = props[i];
|
|
384
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
385
|
+
descriptor.configurable = true;
|
|
386
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
387
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
391
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
392
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
393
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
394
|
+
writable: false
|
|
395
|
+
});
|
|
396
|
+
return Constructor;
|
|
397
|
+
}
|
|
398
|
+
function _defineProperty(obj, key, value) {
|
|
399
|
+
key = _toPropertyKey(key);
|
|
400
|
+
if (key in obj) {
|
|
401
|
+
Object.defineProperty(obj, key, {
|
|
402
|
+
value: value,
|
|
403
|
+
enumerable: true,
|
|
404
|
+
configurable: true,
|
|
405
|
+
writable: true
|
|
406
|
+
});
|
|
407
|
+
} else {
|
|
408
|
+
obj[key] = value;
|
|
409
|
+
}
|
|
410
|
+
return obj;
|
|
411
|
+
}
|
|
412
|
+
function _slicedToArray(arr, i) {
|
|
413
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
414
|
+
}
|
|
415
|
+
function _toConsumableArray(arr) {
|
|
416
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
417
|
+
}
|
|
418
|
+
function _arrayWithoutHoles(arr) {
|
|
419
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
420
|
+
}
|
|
421
|
+
function _arrayWithHoles(arr) {
|
|
422
|
+
if (Array.isArray(arr)) return arr;
|
|
423
|
+
}
|
|
424
|
+
function _iterableToArray(iter) {
|
|
425
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
426
|
+
}
|
|
427
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
428
|
+
if (!o) return;
|
|
429
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
430
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
431
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
432
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
433
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
434
|
+
}
|
|
435
|
+
function _arrayLikeToArray(arr, len) {
|
|
436
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
437
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
438
|
+
return arr2;
|
|
439
|
+
}
|
|
440
|
+
function _nonIterableSpread() {
|
|
441
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
442
|
+
}
|
|
443
|
+
function _nonIterableRest() {
|
|
444
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
445
|
+
}
|
|
446
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
447
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
448
|
+
if (!it) {
|
|
449
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
450
|
+
if (it) o = it;
|
|
451
|
+
var i = 0;
|
|
452
|
+
var F = function () {};
|
|
453
|
+
return {
|
|
454
|
+
s: F,
|
|
455
|
+
n: function () {
|
|
456
|
+
if (i >= o.length) return {
|
|
457
|
+
done: true
|
|
458
|
+
};
|
|
459
|
+
return {
|
|
460
|
+
done: false,
|
|
461
|
+
value: o[i++]
|
|
462
|
+
};
|
|
463
|
+
},
|
|
464
|
+
e: function (e) {
|
|
465
|
+
throw e;
|
|
466
|
+
},
|
|
467
|
+
f: F
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
471
|
+
}
|
|
472
|
+
var normalCompletion = true,
|
|
473
|
+
didErr = false,
|
|
474
|
+
err;
|
|
475
|
+
return {
|
|
476
|
+
s: function () {
|
|
477
|
+
it = it.call(o);
|
|
478
|
+
},
|
|
479
|
+
n: function () {
|
|
480
|
+
var step = it.next();
|
|
481
|
+
normalCompletion = step.done;
|
|
482
|
+
return step;
|
|
483
|
+
},
|
|
484
|
+
e: function (e) {
|
|
485
|
+
didErr = true;
|
|
486
|
+
err = e;
|
|
487
|
+
},
|
|
488
|
+
f: function () {
|
|
489
|
+
try {
|
|
490
|
+
if (!normalCompletion && it.return != null) it.return();
|
|
491
|
+
} finally {
|
|
492
|
+
if (didErr) throw err;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
function _toPrimitive(input, hint) {
|
|
498
|
+
if (typeof input !== "object" || input === null) return input;
|
|
499
|
+
var prim = input[Symbol.toPrimitive];
|
|
500
|
+
if (prim !== undefined) {
|
|
501
|
+
var res = prim.call(input, hint || "default");
|
|
502
|
+
if (typeof res !== "object") return res;
|
|
503
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
504
|
+
}
|
|
505
|
+
return (hint === "string" ? String : Number)(input);
|
|
506
|
+
}
|
|
507
|
+
function _toPropertyKey(arg) {
|
|
508
|
+
var key = _toPrimitive(arg, "string");
|
|
509
|
+
return typeof key === "symbol" ? key : String(key);
|
|
510
|
+
}
|
|
511
|
+
function _classPrivateFieldGet(receiver, privateMap) {
|
|
512
|
+
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
|
|
513
|
+
return _classApplyDescriptorGet(receiver, descriptor);
|
|
514
|
+
}
|
|
515
|
+
function _classPrivateFieldSet(receiver, privateMap, value) {
|
|
516
|
+
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
|
|
517
|
+
_classApplyDescriptorSet(receiver, descriptor, value);
|
|
518
|
+
return value;
|
|
519
|
+
}
|
|
520
|
+
function _classExtractFieldDescriptor(receiver, privateMap, action) {
|
|
521
|
+
if (!privateMap.has(receiver)) {
|
|
522
|
+
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
523
|
+
}
|
|
524
|
+
return privateMap.get(receiver);
|
|
525
|
+
}
|
|
526
|
+
function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
|
|
527
|
+
_classCheckPrivateStaticAccess(receiver, classConstructor);
|
|
528
|
+
_classCheckPrivateStaticFieldDescriptor(descriptor, "get");
|
|
529
|
+
return _classApplyDescriptorGet(receiver, descriptor);
|
|
530
|
+
}
|
|
531
|
+
function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) {
|
|
532
|
+
_classCheckPrivateStaticAccess(receiver, classConstructor);
|
|
533
|
+
_classCheckPrivateStaticFieldDescriptor(descriptor, "set");
|
|
534
|
+
_classApplyDescriptorSet(receiver, descriptor, value);
|
|
535
|
+
return value;
|
|
536
|
+
}
|
|
537
|
+
function _classApplyDescriptorGet(receiver, descriptor) {
|
|
538
|
+
if (descriptor.get) {
|
|
539
|
+
return descriptor.get.call(receiver);
|
|
540
|
+
}
|
|
541
|
+
return descriptor.value;
|
|
542
|
+
}
|
|
543
|
+
function _classApplyDescriptorSet(receiver, descriptor, value) {
|
|
544
|
+
if (descriptor.set) {
|
|
545
|
+
descriptor.set.call(receiver, value);
|
|
546
|
+
} else {
|
|
547
|
+
if (!descriptor.writable) {
|
|
548
|
+
throw new TypeError("attempted to set read only private field");
|
|
549
|
+
}
|
|
550
|
+
descriptor.value = value;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
function _classCheckPrivateStaticAccess(receiver, classConstructor) {
|
|
554
|
+
if (receiver !== classConstructor) {
|
|
555
|
+
throw new TypeError("Private static access of wrong provenance");
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
function _classCheckPrivateStaticFieldDescriptor(descriptor, action) {
|
|
559
|
+
if (descriptor === undefined) {
|
|
560
|
+
throw new TypeError("attempted to " + action + " private static field before its declaration");
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
function _checkPrivateRedeclaration(obj, privateCollection) {
|
|
564
|
+
if (privateCollection.has(obj)) {
|
|
565
|
+
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) {
|
|
569
|
+
_checkPrivateRedeclaration(obj, privateMap);
|
|
570
|
+
privateMap.set(obj, value);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function toCamelCase(string) {
|
|
574
|
+
return string.replace(/(_\w)/g, function (match) {
|
|
575
|
+
return match[1].toUpperCase();
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
function toSnakeCase(string) {
|
|
579
|
+
return string.replace(/[\w]([A-Z])/g, function (match) {
|
|
580
|
+
return match[0] + '_' + match[1].toLowerCase();
|
|
581
|
+
}).toLowerCase();
|
|
582
|
+
}
|
|
583
|
+
function escapeRegExp(string) {
|
|
584
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
585
|
+
}
|
|
586
|
+
function getByPath(obj, path, defaultValue) {
|
|
587
|
+
var keys = path.split('.');
|
|
588
|
+
var current = obj;
|
|
589
|
+
var _iterator = _createForOfIteratorHelper(keys),
|
|
590
|
+
_step;
|
|
591
|
+
try {
|
|
592
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
593
|
+
var key = _step.value;
|
|
594
|
+
if (!current.hasOwnProperty(key)) {
|
|
595
|
+
return defaultValue;
|
|
596
|
+
}
|
|
597
|
+
current = current[key];
|
|
598
|
+
}
|
|
599
|
+
} catch (err) {
|
|
600
|
+
_iterator.e(err);
|
|
601
|
+
} finally {
|
|
602
|
+
_iterator.f();
|
|
603
|
+
}
|
|
604
|
+
return current;
|
|
605
|
+
}
|
|
606
|
+
function flattenObject(obj) {
|
|
607
|
+
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
608
|
+
return Object.keys(obj).reduce(function (accumulator, key) {
|
|
609
|
+
var prefixedKey = prefix ? "".concat(prefix, ".").concat(key) : key;
|
|
610
|
+
if (_typeof(obj[key]) === 'object' && obj[key] !== null) {
|
|
611
|
+
Object.assign(accumulator, flattenObject(obj[key], prefixedKey));
|
|
612
|
+
} else {
|
|
613
|
+
accumulator[prefixedKey] = obj[key];
|
|
614
|
+
}
|
|
615
|
+
return accumulator;
|
|
616
|
+
}, {});
|
|
617
|
+
}
|
|
618
|
+
function parseDate(value) {
|
|
619
|
+
if (isEmpty(value) || typeof value !== 'string') {
|
|
620
|
+
return new Date('');
|
|
621
|
+
} else if (value instanceof Date) {
|
|
622
|
+
return value;
|
|
623
|
+
}
|
|
624
|
+
var match, years, months, days, hours, minutes, seconds, meridiem;
|
|
625
|
+
var castToIntegers = function castToIntegers(value) {
|
|
626
|
+
return value && /^\d*$/.test(value) ? parseInt(value) : value;
|
|
627
|
+
};
|
|
628
|
+
if ((match = value.match(/^(\d{1,2})[.\/-](\d{1,2})[.\/-](\d{2,4})\s?((\d{1,2}):(\d{1,2})(:(\d{1,2}))?\s?(am|pm)?)?/i)) !== null) {
|
|
629
|
+
var _match$map = match.map(castToIntegers);
|
|
630
|
+
var _match$map2 = _slicedToArray(_match$map, 10);
|
|
631
|
+
days = _match$map2[1];
|
|
632
|
+
months = _match$map2[2];
|
|
633
|
+
years = _match$map2[3];
|
|
634
|
+
var _match$map2$ = _match$map2[5];
|
|
635
|
+
hours = _match$map2$ === void 0 ? 0 : _match$map2$;
|
|
636
|
+
var _match$map2$2 = _match$map2[6];
|
|
637
|
+
minutes = _match$map2$2 === void 0 ? 0 : _match$map2$2;
|
|
638
|
+
var _match$map2$3 = _match$map2[8];
|
|
639
|
+
seconds = _match$map2$3 === void 0 ? 0 : _match$map2$3;
|
|
640
|
+
var _match$map2$4 = _match$map2[9];
|
|
641
|
+
meridiem = _match$map2$4 === void 0 ? 'am' : _match$map2$4;
|
|
642
|
+
} else if ((match = value.match(/^(\d{2,4})[.\/-](\d{1,2})[.\/-](\d{1,2})\s?((\d{1,2}):(\d{1,2})(:(\d{1,2}))?\s?(am|pm)?)?/i)) !== null || (match = value.match(/^(\d{4})(\d{2})(\d{2})\s?((\d{2})(\d{2})((\d{2}))?\s?(am|pm)?)?/i)) !== null) {
|
|
643
|
+
var _match$map3 = match.map(castToIntegers);
|
|
644
|
+
var _match$map4 = _slicedToArray(_match$map3, 10);
|
|
645
|
+
years = _match$map4[1];
|
|
646
|
+
months = _match$map4[2];
|
|
647
|
+
days = _match$map4[3];
|
|
648
|
+
var _match$map4$ = _match$map4[5];
|
|
649
|
+
hours = _match$map4$ === void 0 ? 0 : _match$map4$;
|
|
650
|
+
var _match$map4$2 = _match$map4[6];
|
|
651
|
+
minutes = _match$map4$2 === void 0 ? 0 : _match$map4$2;
|
|
652
|
+
var _match$map4$3 = _match$map4[8];
|
|
653
|
+
seconds = _match$map4$3 === void 0 ? 0 : _match$map4$3;
|
|
654
|
+
var _match$map4$4 = _match$map4[9];
|
|
655
|
+
meridiem = _match$map4$4 === void 0 ? 'am' : _match$map4$4;
|
|
656
|
+
} else if (match = value.match(/(\d{1,2}):(\d{1,2})(:(\d{1,2}))?\s?(am|pm)?\s?(\d{4})[.\/-](\d{2})[.\/-](\d{2})/i)) {
|
|
657
|
+
var _match$map5 = match.map(castToIntegers);
|
|
658
|
+
var _match$map6 = _slicedToArray(_match$map5, 9);
|
|
659
|
+
hours = _match$map6[1];
|
|
660
|
+
minutes = _match$map6[2];
|
|
661
|
+
seconds = _match$map6[4];
|
|
662
|
+
var _match$map6$ = _match$map6[5];
|
|
663
|
+
meridiem = _match$map6$ === void 0 ? 'am' : _match$map6$;
|
|
664
|
+
years = _match$map6[6];
|
|
665
|
+
months = _match$map6[7];
|
|
666
|
+
days = _match$map6[8];
|
|
667
|
+
} else if (match = value.match(/(\d{1,2}):(\d{1,2})(:(\d{1,2}))?\s?(am|pm)?\s?(\d{2})[.\/-](\d{2})[.\/-](\d{4})/i)) {
|
|
668
|
+
var _match$map7 = match.map(castToIntegers);
|
|
669
|
+
var _match$map8 = _slicedToArray(_match$map7, 9);
|
|
670
|
+
hours = _match$map8[1];
|
|
671
|
+
minutes = _match$map8[2];
|
|
672
|
+
seconds = _match$map8[4];
|
|
673
|
+
var _match$map8$ = _match$map8[5];
|
|
674
|
+
meridiem = _match$map8$ === void 0 ? 'am' : _match$map8$;
|
|
675
|
+
days = _match$map8[6];
|
|
676
|
+
months = _match$map8[7];
|
|
677
|
+
years = _match$map8[8];
|
|
678
|
+
} else if (match = value.match(/(\d{1,2}):(\d{1,2})(:(\d{1,2}))?\s?(am|pm)?/i)) {
|
|
679
|
+
var current = new Date();
|
|
680
|
+
years = current.getFullYear();
|
|
681
|
+
months = current.getMonth() + 1;
|
|
682
|
+
days = current.getDate();
|
|
683
|
+
var _match$map9 = match.map(castToIntegers);
|
|
684
|
+
var _match$map10 = _slicedToArray(_match$map9, 6);
|
|
685
|
+
var _match$map10$ = _match$map10[1];
|
|
686
|
+
hours = _match$map10$ === void 0 ? 0 : _match$map10$;
|
|
687
|
+
var _match$map10$2 = _match$map10[2];
|
|
688
|
+
minutes = _match$map10$2 === void 0 ? 0 : _match$map10$2;
|
|
689
|
+
var _match$map10$3 = _match$map10[4];
|
|
690
|
+
seconds = _match$map10$3 === void 0 ? 0 : _match$map10$3;
|
|
691
|
+
var _match$map10$4 = _match$map10[5];
|
|
692
|
+
meridiem = _match$map10$4 === void 0 ? 'am' : _match$map10$4;
|
|
693
|
+
} else {
|
|
694
|
+
return new Date(value);
|
|
695
|
+
}
|
|
696
|
+
if (years >= 10 && years < 100) {
|
|
697
|
+
years += 2000;
|
|
698
|
+
}
|
|
699
|
+
if (meridiem.toLowerCase() === 'pm' && hours < 12) {
|
|
700
|
+
hours += 12;
|
|
701
|
+
}
|
|
702
|
+
return new Date("".concat(years, "-").concat(months, "-").concat(days, " ").concat(hours, ":").concat(minutes, ":").concat(seconds));
|
|
703
|
+
}
|
|
704
|
+
function parseDateByFormat(value, format) {
|
|
705
|
+
var _match$indices$hours, _match$indices$minute, _match$indices$second, _match$indices$meridi;
|
|
706
|
+
if (isEmpty(value)) {
|
|
707
|
+
return new Date('');
|
|
708
|
+
}
|
|
709
|
+
format = format.split('');
|
|
710
|
+
var formats = {
|
|
711
|
+
Y: '(\\d{4})',
|
|
712
|
+
y: '(\\d{2})',
|
|
713
|
+
m: '(\\d{2})',
|
|
714
|
+
n: '([1-9]\\d?)',
|
|
715
|
+
d: '(\\d{2})',
|
|
716
|
+
j: '([1-9]\\d?)',
|
|
717
|
+
G: '([1-9]\\d?)',
|
|
718
|
+
g: '([1-9]\\d?)',
|
|
719
|
+
H: '(\\d{2})',
|
|
720
|
+
h: '(\\d{2})',
|
|
721
|
+
i: '(\\d{2})',
|
|
722
|
+
s: '(\\d{2})',
|
|
723
|
+
A: '(AM|PM)',
|
|
724
|
+
a: '(am|pm)'
|
|
725
|
+
};
|
|
726
|
+
var pattern = '^';
|
|
727
|
+
var indices = {
|
|
728
|
+
years: -1,
|
|
729
|
+
months: -1,
|
|
730
|
+
days: -1,
|
|
731
|
+
hours: -1,
|
|
732
|
+
minutes: -1,
|
|
733
|
+
seconds: -1,
|
|
734
|
+
meridiem: -1
|
|
735
|
+
};
|
|
736
|
+
var index = 1;
|
|
737
|
+
var _iterator3 = _createForOfIteratorHelper(format),
|
|
738
|
+
_step3;
|
|
739
|
+
try {
|
|
740
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
741
|
+
var char = _step3.value;
|
|
742
|
+
if (formats.hasOwnProperty(char)) {
|
|
743
|
+
pattern += formats[char];
|
|
744
|
+
if (['Y', 'y'].indexOf(char) !== -1) {
|
|
745
|
+
indices.years = index++;
|
|
746
|
+
} else if (['m', 'n'].indexOf(char) !== -1) {
|
|
747
|
+
indices.months = index++;
|
|
748
|
+
} else if (['d', 'j'].indexOf(char) !== -1) {
|
|
749
|
+
indices.days = index++;
|
|
750
|
+
} else if (['G', 'g', 'H', 'h'].indexOf(char) !== -1) {
|
|
751
|
+
indices.hours = index++;
|
|
752
|
+
} else if (char === 'i') {
|
|
753
|
+
indices.minutes = index++;
|
|
754
|
+
} else if (char === 's') {
|
|
755
|
+
indices.seconds = index++;
|
|
756
|
+
} else if (['A', 'a'].indexOf(char) !== -1) {
|
|
757
|
+
indices.meridiem = index++;
|
|
758
|
+
}
|
|
759
|
+
} else {
|
|
760
|
+
pattern += '\\' + char;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
} catch (err) {
|
|
764
|
+
_iterator3.e(err);
|
|
765
|
+
} finally {
|
|
766
|
+
_iterator3.f();
|
|
767
|
+
}
|
|
768
|
+
pattern += '$';
|
|
769
|
+
var match = value.match(new RegExp(pattern));
|
|
770
|
+
if (match === null) {
|
|
771
|
+
return new Date('');
|
|
772
|
+
}
|
|
773
|
+
match = match.map(function (value) {
|
|
774
|
+
return value && /^\d*$/.test(value) ? parseInt(value) : value;
|
|
775
|
+
});
|
|
776
|
+
var current = new Date();
|
|
777
|
+
var years = match[indices.years];
|
|
778
|
+
var months = match[indices.months];
|
|
779
|
+
var days = match[indices.days];
|
|
780
|
+
var hours = (_match$indices$hours = match[indices.hours]) !== null && _match$indices$hours !== void 0 ? _match$indices$hours : 0;
|
|
781
|
+
var minutes = (_match$indices$minute = match[indices.minutes]) !== null && _match$indices$minute !== void 0 ? _match$indices$minute : 0;
|
|
782
|
+
var seconds = (_match$indices$second = match[indices.seconds]) !== null && _match$indices$second !== void 0 ? _match$indices$second : 0;
|
|
783
|
+
var meridiem = (_match$indices$meridi = match[indices.meridiem]) !== null && _match$indices$meridi !== void 0 ? _match$indices$meridi : 'am';
|
|
784
|
+
if (!years && !months && !days) {
|
|
785
|
+
years = current.getFullYear();
|
|
786
|
+
months = current.getMonth() + 1;
|
|
787
|
+
days = current.getDate();
|
|
788
|
+
} else if (years && !months && !days) {
|
|
789
|
+
months = 1;
|
|
790
|
+
days = 1;
|
|
791
|
+
} else if (!years && months && !days) {
|
|
792
|
+
years = current.getFullYear();
|
|
793
|
+
days = 1;
|
|
794
|
+
} else if (!years && !months && days) {
|
|
795
|
+
years = current.getFullYear();
|
|
796
|
+
months = current.getMonth() + 1;
|
|
797
|
+
}
|
|
798
|
+
if (years >= 10 && years < 100) {
|
|
799
|
+
years = years + 2000;
|
|
800
|
+
}
|
|
801
|
+
if (meridiem.toLowerCase() === 'pm' && hours < 12) {
|
|
802
|
+
hours += 12;
|
|
803
|
+
}
|
|
804
|
+
return new Date("".concat(years, "-").concat(months, "-").concat(days, " ").concat(hours, ":").concat(minutes, ":").concat(seconds));
|
|
805
|
+
}
|
|
806
|
+
function isDigits(value) {
|
|
807
|
+
return String(value).search(/[^0-9]/) === -1;
|
|
808
|
+
}
|
|
809
|
+
function isEmpty(value) {
|
|
810
|
+
return value === '' || value === null || typeof value === 'undefined';
|
|
811
|
+
}
|
|
812
|
+
function isNumeric(value) {
|
|
813
|
+
var number = Number(value);
|
|
814
|
+
return value !== null && typeof value !== 'boolean' && typeof number === 'number' && !isNaN(number);
|
|
815
|
+
}
|
|
816
|
+
function isPlainObject(value) {
|
|
817
|
+
return Object.prototype.toString.call(value) === '[object Object]';
|
|
818
|
+
}
|
|
819
|
+
function isValidDate(value) {
|
|
820
|
+
return value instanceof Date && value.toDateString() !== 'Invalid Date';
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
var _distinctCache = /*#__PURE__*/new WeakMap();
|
|
824
|
+
var _imageCache = /*#__PURE__*/new WeakMap();
|
|
825
|
+
var Checkers = /*#__PURE__*/function () {
|
|
826
|
+
function Checkers(validator) {
|
|
827
|
+
_classCallCheck(this, Checkers);
|
|
828
|
+
_defineProperty(this, "validator", void 0);
|
|
829
|
+
_classPrivateFieldInitSpec(this, _distinctCache, {
|
|
830
|
+
writable: true,
|
|
831
|
+
value: {}
|
|
832
|
+
});
|
|
833
|
+
_classPrivateFieldInitSpec(this, _imageCache, {
|
|
834
|
+
writable: true,
|
|
835
|
+
value: {}
|
|
836
|
+
});
|
|
837
|
+
this.validator = validator;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
// Internal helpers
|
|
841
|
+
_createClass(Checkers, [{
|
|
842
|
+
key: "clearCaches",
|
|
843
|
+
value: function clearCaches() {
|
|
844
|
+
_classPrivateFieldSet(this, _distinctCache, {});
|
|
845
|
+
_classPrivateFieldSet(this, _imageCache, {});
|
|
846
|
+
}
|
|
847
|
+
}, {
|
|
848
|
+
key: "isDependent",
|
|
849
|
+
value: function isDependent(parameters) {
|
|
850
|
+
var other = this.validator.getValue(parameters[0]);
|
|
851
|
+
return parameters.slice(1).some(function (value) {
|
|
852
|
+
return value == other;
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
}, {
|
|
856
|
+
key: "collectRequiredsThenTest",
|
|
857
|
+
value: function collectRequiredsThenTest(attribute, value, parameters, callback) {
|
|
858
|
+
var result = [];
|
|
859
|
+
var _iterator = _createForOfIteratorHelper(parameters),
|
|
860
|
+
_step;
|
|
861
|
+
try {
|
|
862
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
863
|
+
var other = _step.value;
|
|
864
|
+
result.push(this.checkRequired(other, this.validator.getValue(other)));
|
|
865
|
+
}
|
|
866
|
+
} catch (err) {
|
|
867
|
+
_iterator.e(err);
|
|
868
|
+
} finally {
|
|
869
|
+
_iterator.f();
|
|
870
|
+
}
|
|
871
|
+
if (callback(result)) {
|
|
872
|
+
return this.checkRequired(attribute, value);
|
|
873
|
+
}
|
|
874
|
+
return true;
|
|
875
|
+
}
|
|
876
|
+
}, {
|
|
877
|
+
key: "collectMissingsThenTest",
|
|
878
|
+
value: function collectMissingsThenTest(attribute, value, parameters, callback) {
|
|
879
|
+
var result = [];
|
|
880
|
+
var _iterator2 = _createForOfIteratorHelper(parameters),
|
|
881
|
+
_step2;
|
|
882
|
+
try {
|
|
883
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
884
|
+
var other = _step2.value;
|
|
885
|
+
result.push(this.checkMissing(other));
|
|
886
|
+
}
|
|
887
|
+
} catch (err) {
|
|
888
|
+
_iterator2.e(err);
|
|
889
|
+
} finally {
|
|
890
|
+
_iterator2.f();
|
|
891
|
+
}
|
|
892
|
+
if (callback(result)) {
|
|
893
|
+
return this.checkMissing(attribute);
|
|
894
|
+
}
|
|
895
|
+
return true;
|
|
896
|
+
}
|
|
897
|
+
}, {
|
|
898
|
+
key: "testStringUsingRegex",
|
|
899
|
+
value: function testStringUsingRegex(attribute, value, asciiRegex, unicodeRegex) {
|
|
900
|
+
var isAscii = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
901
|
+
if (typeof value !== 'string' && typeof value !== 'number') {
|
|
902
|
+
return false;
|
|
903
|
+
}
|
|
904
|
+
value = String(value);
|
|
905
|
+
if (isAscii || this.validator.hasRule(attribute, 'ascii')) {
|
|
906
|
+
return asciiRegex.test(value);
|
|
907
|
+
}
|
|
908
|
+
return unicodeRegex.test(value);
|
|
909
|
+
}
|
|
910
|
+
}, {
|
|
911
|
+
key: "compareValues",
|
|
912
|
+
value: function compareValues(attribute, value, parameters, callback) {
|
|
913
|
+
var _parameters$;
|
|
914
|
+
if (isEmpty(value)) {
|
|
915
|
+
return false;
|
|
916
|
+
}
|
|
917
|
+
var other = (_parameters$ = parameters[0]) !== null && _parameters$ !== void 0 ? _parameters$ : '';
|
|
918
|
+
var otherValue = this.validator.getValue(other);
|
|
919
|
+
if (typeof otherValue === 'undefined') {
|
|
920
|
+
if (isNumeric(other)) {
|
|
921
|
+
otherValue = parseFloat(other, 10);
|
|
922
|
+
} else {
|
|
923
|
+
otherValue = null;
|
|
924
|
+
}
|
|
925
|
+
} else {
|
|
926
|
+
otherValue = this.validator.getSize(other, otherValue);
|
|
927
|
+
}
|
|
928
|
+
if (isEmpty(otherValue)) {
|
|
929
|
+
return false;
|
|
930
|
+
}
|
|
931
|
+
return callback(this.validator.getSize(attribute, value), otherValue);
|
|
932
|
+
}
|
|
933
|
+
}, {
|
|
934
|
+
key: "compareDates",
|
|
935
|
+
value: function compareDates(attribute, value, parameters, callback) {
|
|
936
|
+
var _parameters$2;
|
|
937
|
+
var rule = this.validator.getRule(attribute);
|
|
938
|
+
value = rule.hasOwnProperty('date_format') ? parseDateByFormat(value, rule.date_format[0]) : parseDate(value);
|
|
939
|
+
if (!isValidDate(value)) {
|
|
940
|
+
return false;
|
|
941
|
+
}
|
|
942
|
+
var other = (_parameters$2 = parameters[0]) !== null && _parameters$2 !== void 0 ? _parameters$2 : '';
|
|
943
|
+
var otherValue = this.validator.getValue(other);
|
|
944
|
+
if (typeof otherValue === 'undefined') {
|
|
945
|
+
otherValue = parseDate(other);
|
|
946
|
+
} else {
|
|
947
|
+
var otherRule = this.validator.getRule(other);
|
|
948
|
+
otherValue = otherRule.hasOwnProperty('date_format') ? parseDateByFormat(otherValue, otherRule.date_format[0]) : parseDate(otherValue);
|
|
949
|
+
}
|
|
950
|
+
if (!isValidDate(otherValue)) {
|
|
951
|
+
return false;
|
|
952
|
+
}
|
|
953
|
+
return callback(value.getTime(), otherValue.getTime());
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
// Type
|
|
957
|
+
}, {
|
|
958
|
+
key: "checkArray",
|
|
959
|
+
value: function checkArray(attribute, value, parameters) {
|
|
960
|
+
if (!(Array.isArray(value) || isPlainObject(value))) {
|
|
961
|
+
return false;
|
|
962
|
+
}
|
|
963
|
+
if (parameters && parameters.length > 0) {
|
|
964
|
+
for (var _i = 0, _Object$keys = Object.keys(value); _i < _Object$keys.length; _i++) {
|
|
965
|
+
var key = _Object$keys[_i];
|
|
966
|
+
if (!parameters.includes(key)) {
|
|
967
|
+
return false;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
return true;
|
|
972
|
+
}
|
|
973
|
+
}, {
|
|
974
|
+
key: "checkBoolean",
|
|
975
|
+
value: function checkBoolean(attribute, value, parameters) {
|
|
976
|
+
return [true, false, 0, 1, '0', '1'].includes(value);
|
|
977
|
+
}
|
|
978
|
+
}, {
|
|
979
|
+
key: "checkDate",
|
|
980
|
+
value: function checkDate(attribute, value, parameters) {
|
|
981
|
+
return isValidDate(parseDate(value));
|
|
982
|
+
}
|
|
983
|
+
}, {
|
|
984
|
+
key: "checkFile",
|
|
985
|
+
value: function checkFile(attribute, value, parameters) {
|
|
986
|
+
return value instanceof File;
|
|
987
|
+
}
|
|
988
|
+
}, {
|
|
989
|
+
key: "checkInteger",
|
|
990
|
+
value: function checkInteger(attribute, value, parameters) {
|
|
991
|
+
return String(parseInt(value, 10)) === String(value);
|
|
992
|
+
}
|
|
993
|
+
}, {
|
|
994
|
+
key: "checkNumeric",
|
|
995
|
+
value: function checkNumeric(attribute, value, parameters) {
|
|
996
|
+
return isNumeric(value);
|
|
997
|
+
}
|
|
998
|
+
}, {
|
|
999
|
+
key: "checkString",
|
|
1000
|
+
value: function checkString(attribute, value, parameters) {
|
|
1001
|
+
return typeof value === 'string';
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
// Numeric
|
|
1005
|
+
}, {
|
|
1006
|
+
key: "checkDecimal",
|
|
1007
|
+
value: function checkDecimal(attribute, value, parameters) {
|
|
1008
|
+
var _String$split$;
|
|
1009
|
+
if (!this.checkNumeric(attribute, value)) {
|
|
1010
|
+
return false;
|
|
1011
|
+
}
|
|
1012
|
+
var decimals = ((_String$split$ = String(value).split('.')[1]) !== null && _String$split$ !== void 0 ? _String$split$ : '').length;
|
|
1013
|
+
if (parameters.length === 1) {
|
|
1014
|
+
return decimals == parameters[0];
|
|
1015
|
+
}
|
|
1016
|
+
return decimals >= parameters[0] && decimals <= parameters[1];
|
|
1017
|
+
}
|
|
1018
|
+
}, {
|
|
1019
|
+
key: "checkMultipleOf",
|
|
1020
|
+
value: function checkMultipleOf(attribute, value, parameters) {
|
|
1021
|
+
if (!isNumeric(value) || !isNumeric(parameters[0])) {
|
|
1022
|
+
return false;
|
|
1023
|
+
}
|
|
1024
|
+
var numerator = parseInt(value, 10);
|
|
1025
|
+
var denominator = parseInt(parameters[0], 10);
|
|
1026
|
+
if (numerator === 0 && denominator === 0) {
|
|
1027
|
+
return false;
|
|
1028
|
+
} else if (numerator === 0) {
|
|
1029
|
+
return true;
|
|
1030
|
+
} else if (denominator === 0) {
|
|
1031
|
+
return false;
|
|
1032
|
+
}
|
|
1033
|
+
return numerator % denominator === 0;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
// Agreement
|
|
1037
|
+
}, {
|
|
1038
|
+
key: "checkAccepted",
|
|
1039
|
+
value: function checkAccepted(attribute, value, parameters) {
|
|
1040
|
+
return ['yes', 'on', '1', 1, true, 'true'].includes(value);
|
|
1041
|
+
}
|
|
1042
|
+
}, {
|
|
1043
|
+
key: "checkAcceptedIf",
|
|
1044
|
+
value: function checkAcceptedIf(attribute, value, parameters) {
|
|
1045
|
+
if (this.isDependent(parameters)) {
|
|
1046
|
+
return this.checkAccepted(attribute, value, parameters);
|
|
1047
|
+
}
|
|
1048
|
+
return true;
|
|
1049
|
+
}
|
|
1050
|
+
}, {
|
|
1051
|
+
key: "checkDeclined",
|
|
1052
|
+
value: function checkDeclined(attribute, value, parameters) {
|
|
1053
|
+
return ['no', 'off', '0', 0, false, 'false'].includes(value);
|
|
1054
|
+
}
|
|
1055
|
+
}, {
|
|
1056
|
+
key: "checkDeclinedIf",
|
|
1057
|
+
value: function checkDeclinedIf(attribute, value, parameters) {
|
|
1058
|
+
if (this.isDependent(parameters)) {
|
|
1059
|
+
return this.checkDeclined(attribute, value, parameters);
|
|
1060
|
+
}
|
|
1061
|
+
return true;
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
// Existence
|
|
1065
|
+
}, {
|
|
1066
|
+
key: "checkRequired",
|
|
1067
|
+
value: function checkRequired(attribute, value, parameters) {
|
|
1068
|
+
if (isEmpty(value)) {
|
|
1069
|
+
return false;
|
|
1070
|
+
} else if (Array.isArray(value)) {
|
|
1071
|
+
return value.length > 0;
|
|
1072
|
+
} else if (value instanceof File) {
|
|
1073
|
+
return value.size > 0;
|
|
1074
|
+
}
|
|
1075
|
+
value = String(value).replace(/\s/g, '');
|
|
1076
|
+
return value.length > 0;
|
|
1077
|
+
}
|
|
1078
|
+
}, {
|
|
1079
|
+
key: "checkRequiredArrayKeys",
|
|
1080
|
+
value: function checkRequiredArrayKeys(attribute, value, parameters) {
|
|
1081
|
+
if (!this.checkArray(attribute, value)) {
|
|
1082
|
+
return false;
|
|
1083
|
+
}
|
|
1084
|
+
var keys = Object.keys(value);
|
|
1085
|
+
var _iterator3 = _createForOfIteratorHelper(parameters),
|
|
1086
|
+
_step3;
|
|
1087
|
+
try {
|
|
1088
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1089
|
+
var parameter = _step3.value;
|
|
1090
|
+
if (!keys.includes(parameter)) {
|
|
1091
|
+
return false;
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
} catch (err) {
|
|
1095
|
+
_iterator3.e(err);
|
|
1096
|
+
} finally {
|
|
1097
|
+
_iterator3.f();
|
|
1098
|
+
}
|
|
1099
|
+
return true;
|
|
1100
|
+
}
|
|
1101
|
+
}, {
|
|
1102
|
+
key: "checkRequiredIf",
|
|
1103
|
+
value: function checkRequiredIf(attribute, value, parameters) {
|
|
1104
|
+
if (this.isDependent(parameters)) {
|
|
1105
|
+
return this.checkRequired(attribute, value);
|
|
1106
|
+
}
|
|
1107
|
+
return true;
|
|
1108
|
+
}
|
|
1109
|
+
}, {
|
|
1110
|
+
key: "checkRequiredIfAccepted",
|
|
1111
|
+
value: function checkRequiredIfAccepted(attribute, value, parameters) {
|
|
1112
|
+
if (this.checkAccepted(parameters[0], this.validator.getValue(parameters[0]))) {
|
|
1113
|
+
return this.checkRequired(attribute, value);
|
|
1114
|
+
}
|
|
1115
|
+
return true;
|
|
1116
|
+
}
|
|
1117
|
+
}, {
|
|
1118
|
+
key: "checkRequiredUnless",
|
|
1119
|
+
value: function checkRequiredUnless(attribute, value, parameters) {
|
|
1120
|
+
if (!this.isDependent(parameters)) {
|
|
1121
|
+
return this.checkRequired(attribute, value);
|
|
1122
|
+
}
|
|
1123
|
+
return true;
|
|
1124
|
+
}
|
|
1125
|
+
}, {
|
|
1126
|
+
key: "checkRequiredWith",
|
|
1127
|
+
value: function checkRequiredWith(attribute, value, parameters) {
|
|
1128
|
+
return this.collectRequiredsThenTest(attribute, value, parameters, function (result) {
|
|
1129
|
+
return result.includes(true);
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
}, {
|
|
1133
|
+
key: "checkRequiredWithAll",
|
|
1134
|
+
value: function checkRequiredWithAll(attribute, value, parameters) {
|
|
1135
|
+
return this.collectRequiredsThenTest(attribute, value, parameters, function (result) {
|
|
1136
|
+
return !result.includes(false);
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
}, {
|
|
1140
|
+
key: "checkRequiredWithout",
|
|
1141
|
+
value: function checkRequiredWithout(attribute, value, parameters) {
|
|
1142
|
+
return this.collectRequiredsThenTest(attribute, value, parameters, function (result) {
|
|
1143
|
+
return result.includes(false);
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
}, {
|
|
1147
|
+
key: "checkRequiredWithoutAll",
|
|
1148
|
+
value: function checkRequiredWithoutAll(attribute, value, parameters) {
|
|
1149
|
+
return this.collectRequiredsThenTest(attribute, value, parameters, function (result) {
|
|
1150
|
+
return !result.includes(true);
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
}, {
|
|
1154
|
+
key: "checkFilled",
|
|
1155
|
+
value: function checkFilled(attribute, value, parameters) {
|
|
1156
|
+
if (typeof value !== 'undefined') {
|
|
1157
|
+
return this.checkRequired(attribute, value);
|
|
1158
|
+
}
|
|
1159
|
+
return true;
|
|
1160
|
+
}
|
|
1161
|
+
}, {
|
|
1162
|
+
key: "checkPresent",
|
|
1163
|
+
value: function checkPresent(attribute, value, parameters) {
|
|
1164
|
+
return typeof value !== 'undefined';
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
// Missing
|
|
1168
|
+
}, {
|
|
1169
|
+
key: "checkMissing",
|
|
1170
|
+
value: function checkMissing(attribute, value, parameters) {
|
|
1171
|
+
return !this.validator.hasAttribute(attribute);
|
|
1172
|
+
}
|
|
1173
|
+
}, {
|
|
1174
|
+
key: "checkMissingIf",
|
|
1175
|
+
value: function checkMissingIf(attribute, value, parameters) {
|
|
1176
|
+
if (this.isDependent(parameters)) {
|
|
1177
|
+
return this.checkMissing(attribute);
|
|
1178
|
+
}
|
|
1179
|
+
return true;
|
|
1180
|
+
}
|
|
1181
|
+
}, {
|
|
1182
|
+
key: "checkMissingUnless",
|
|
1183
|
+
value: function checkMissingUnless(attribute, value, parameters) {
|
|
1184
|
+
if (!this.isDependent(parameters)) {
|
|
1185
|
+
return this.checkMissing(attribute);
|
|
1186
|
+
}
|
|
1187
|
+
return true;
|
|
1188
|
+
}
|
|
1189
|
+
}, {
|
|
1190
|
+
key: "checkMissingWith",
|
|
1191
|
+
value: function checkMissingWith(attribute, value, parameters) {
|
|
1192
|
+
return this.collectMissingsThenTest(attribute, value, parameters, function (result) {
|
|
1193
|
+
return result.includes(false);
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
}, {
|
|
1197
|
+
key: "checkMissingWithAll",
|
|
1198
|
+
value: function checkMissingWithAll(attribute, value, parameters) {
|
|
1199
|
+
return this.collectMissingsThenTest(attribute, value, parameters, function (result) {
|
|
1200
|
+
return !result.includes(true);
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
// Prohibition
|
|
1205
|
+
}, {
|
|
1206
|
+
key: "checkProhibited",
|
|
1207
|
+
value: function checkProhibited(attribute, value, parameters) {
|
|
1208
|
+
return !this.checkRequired(attribute, value);
|
|
1209
|
+
}
|
|
1210
|
+
}, {
|
|
1211
|
+
key: "checkProhibitedIf",
|
|
1212
|
+
value: function checkProhibitedIf(attribute, value, parameters) {
|
|
1213
|
+
if (this.isDependent(parameters)) {
|
|
1214
|
+
return !this.checkRequired(attribute, value);
|
|
1215
|
+
}
|
|
1216
|
+
return true;
|
|
1217
|
+
}
|
|
1218
|
+
}, {
|
|
1219
|
+
key: "checkProhibitedUnless",
|
|
1220
|
+
value: function checkProhibitedUnless(attribute, value, parameters) {
|
|
1221
|
+
if (!this.isDependent(parameters)) {
|
|
1222
|
+
return !this.checkRequired(attribute, value);
|
|
1223
|
+
}
|
|
1224
|
+
return true;
|
|
1225
|
+
}
|
|
1226
|
+
}, {
|
|
1227
|
+
key: "checkProhibits",
|
|
1228
|
+
value: function checkProhibits(attribute, value, parameters) {
|
|
1229
|
+
if (this.checkRequired(attribute, value)) {
|
|
1230
|
+
var _iterator4 = _createForOfIteratorHelper(parameters),
|
|
1231
|
+
_step4;
|
|
1232
|
+
try {
|
|
1233
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
1234
|
+
var parameter = _step4.value;
|
|
1235
|
+
if (this.checkRequired(parameter, this.validator.getValue(parameter))) {
|
|
1236
|
+
return false;
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
} catch (err) {
|
|
1240
|
+
_iterator4.e(err);
|
|
1241
|
+
} finally {
|
|
1242
|
+
_iterator4.f();
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
return true;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
// Size
|
|
1249
|
+
}, {
|
|
1250
|
+
key: "checkSize",
|
|
1251
|
+
value: function checkSize(attribute, value, parameters) {
|
|
1252
|
+
return this.validator.getSize(attribute, value) === parseFloat(parameters[0]);
|
|
1253
|
+
}
|
|
1254
|
+
}, {
|
|
1255
|
+
key: "checkMin",
|
|
1256
|
+
value: function checkMin(attribute, value, parameters) {
|
|
1257
|
+
return this.validator.getSize(attribute, value) >= parseFloat(parameters[0]);
|
|
1258
|
+
}
|
|
1259
|
+
}, {
|
|
1260
|
+
key: "checkMax",
|
|
1261
|
+
value: function checkMax(attribute, value, parameters) {
|
|
1262
|
+
return this.validator.getSize(attribute, value) <= parseFloat(parameters[0]);
|
|
1263
|
+
}
|
|
1264
|
+
}, {
|
|
1265
|
+
key: "checkBetween",
|
|
1266
|
+
value: function checkBetween(attribute, value, parameters) {
|
|
1267
|
+
return this.checkMin(attribute, value, [parameters[0]]) && this.checkMax(attribute, value, [parameters[1]]);
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
// Digits
|
|
1271
|
+
}, {
|
|
1272
|
+
key: "checkDigits",
|
|
1273
|
+
value: function checkDigits(attribute, value, parameters) {
|
|
1274
|
+
var _value, _parameters$3;
|
|
1275
|
+
var callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function (length, value) {
|
|
1276
|
+
return length === value;
|
|
1277
|
+
};
|
|
1278
|
+
value = String((_value = value) !== null && _value !== void 0 ? _value : '');
|
|
1279
|
+
if (!isDigits(value)) {
|
|
1280
|
+
return false;
|
|
1281
|
+
}
|
|
1282
|
+
return callback(value.length, parseInt(parameters[0], 10), parseInt((_parameters$3 = parameters[1]) !== null && _parameters$3 !== void 0 ? _parameters$3 : 0, 10));
|
|
1283
|
+
}
|
|
1284
|
+
}, {
|
|
1285
|
+
key: "checkMinDigits",
|
|
1286
|
+
value: function checkMinDigits(attribute, value, parameters) {
|
|
1287
|
+
return this.checkDigits(attribute, value, parameters, function (length, value) {
|
|
1288
|
+
return length >= value;
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
}, {
|
|
1292
|
+
key: "checkMaxDigits",
|
|
1293
|
+
value: function checkMaxDigits(attribute, value, parameters) {
|
|
1294
|
+
return this.checkDigits(attribute, value, parameters, function (length, value) {
|
|
1295
|
+
return length <= value;
|
|
1296
|
+
});
|
|
1297
|
+
}
|
|
1298
|
+
}, {
|
|
1299
|
+
key: "checkDigitsBetween",
|
|
1300
|
+
value: function checkDigitsBetween(attribute, value, parameters) {
|
|
1301
|
+
return this.checkDigits(attribute, value, parameters, function (length, value1, value2) {
|
|
1302
|
+
return length >= value1 && length <= value2;
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
// String
|
|
1307
|
+
}, {
|
|
1308
|
+
key: "checkAlpha",
|
|
1309
|
+
value: function checkAlpha(attribute, value, parameters) {
|
|
1310
|
+
return this.testStringUsingRegex(attribute, value, /^[a-z]+$/i, /^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u065F\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06EF\u06FA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07CA-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u0870-\u0887\u0889-\u088E\u0898-\u08E1\u08E3-\u0963\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09F0\u09F1\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u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0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECE\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u103F\u1050-\u108F\u109A-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1715\u171F-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u180B-\u180D\u180F\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F\u1AA7\u1AB0-\u1ACE\u1B00-\u1B4C\u1B6B-\u1B73\u1B80-\u1BAF\u1BBA-\u1BF3\u1C00-\u1C37\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u20D0-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005\u3006\u302A-\u302F\u3031-\u3035\u303B\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA672\uA674-\uA67D\uA67F-\uA6E5\uA6F0\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA827\uA82C\uA840-\uA873\uA880-\uA8C5\uA8E0-\uA8F7\uA8FB\uA8FD-\uA8FF\uA90A-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF\uA9E0-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-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47\uDE50-\uDE99\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDEE0-\uDEF6\uDF00-\uDF10\uDF12-\uDF3A\uDF3E-\uDF42\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC40-\uDC55]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3\uDFE4\uDFF0\uDFF1]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\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D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF]|\uDB40[\uDD00-\uDDEF])+$/, parameters.includes('ascii'));
|
|
1311
|
+
}
|
|
1312
|
+
}, {
|
|
1313
|
+
key: "checkAlphaDash",
|
|
1314
|
+
value: function checkAlphaDash(attribute, value, parameters) {
|
|
1315
|
+
return this.testStringUsingRegex(attribute, value, /^[a-z0-9_-]+$/i, /^(?:[\x2D0-9A-Z_a-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u0870-\u0887\u0889-\u088E\u0898-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09F4-\u09F9\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0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78\u0D7A-\u0D7F\u0D81-\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECE\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F33\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1715\u171F-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u17F0-\u17F9\u180B-\u180D\u180F-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ACE\u1B00-\u1B4C\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u20D0-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2CE4\u2CEB-\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7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DEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3B-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5E-\uDC61\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF1D-\uDF2B\uDF30-\uDF3B\uDF40-\uDF46]|\uD806[\uDC00-\uDC3A\uDCA0-\uDCF2\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD7\uDDDA-\uDDE1\uDDE3\uDDE4\uDE00-\uDE3E\uDE47\uDE50-\uDE99\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC6C\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF6\uDF00-\uDF10\uDF12-\uDF3A\uDF3E-\uDF42\uDF50-\uDF59\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC40-\uDC55]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDE70-\uDEBE\uDEC0-\uDEC9\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE96\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3\uDFE4\uDFF0\uDFF1]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44\uDEC0-\uDED3\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\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FAF]|\uDB40[\uDD00-\uDDEF])+$/, parameters.includes('ascii'));
|
|
1316
|
+
}
|
|
1317
|
+
}, {
|
|
1318
|
+
key: "checkAlphaNum",
|
|
1319
|
+
value: function checkAlphaNum(attribute, value, parameters) {
|
|
1320
|
+
return this.testStringUsingRegex(attribute, value, /^[a-z0-9]+$/i, /^(?:[0-9A-Za-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u0870-\u0887\u0889-\u088E\u0898-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09F4-\u09F9\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB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\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECE\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F33\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1715\u171F-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u17F0-\u17F9\u180B-\u180D\u180F-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ACE\u1B00-\u1B4C\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u20D0-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2CE4\u2CEB-\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA827\uA82C\uA830-\uA835\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uA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C50-\uDC59\uDC5E-\uDC61\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF1D-\uDF2B\uDF30-\uDF3B\uDF40-\uDF46]|\uD806[\uDC00-\uDC3A\uDCA0-\uDCF2\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD7\uDDDA-\uDDE1\uDDE3\uDDE4\uDE00-\uDE3E\uDE47\uDE50-\uDE99\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC6C\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF6\uDF00-\uDF10\uDF12-\uDF3A\uDF3E-\uDF42\uDF50-\uDF59\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC40-\uDC55]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDE70-\uDEBE\uDEC0-\uDEC9\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\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uDC23\uDC24\uDC26-\uDC2A\uDC30-\uDC6D\uDC8F\uDD00-\uDD2C\uDD30-\uDD3D\uDD40-\uDD49\uDD4E\uDE90-\uDEAE\uDEC0-\uDEF9]|\uD839[\uDCD0-\uDCF9\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF]|\uDB40[\uDD00-\uDDEF])+$/, parameters.includes('ascii'));
|
|
1321
|
+
}
|
|
1322
|
+
}, {
|
|
1323
|
+
key: "checkAscii",
|
|
1324
|
+
value: function checkAscii(attribute, value, parameters) {
|
|
1325
|
+
return !/[^\x09\x10\x13\x0A\x0D\x20-\x7E]/.test(value);
|
|
1326
|
+
}
|
|
1327
|
+
}, {
|
|
1328
|
+
key: "checkRegex",
|
|
1329
|
+
value: function checkRegex(attribute, value, parameters) {
|
|
1330
|
+
var _expression$match;
|
|
1331
|
+
var invert = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
1332
|
+
if (!(typeof value === 'string' || isNumeric(value))) {
|
|
1333
|
+
return false;
|
|
1334
|
+
}
|
|
1335
|
+
var expression = parameters.join(',');
|
|
1336
|
+
var _ref = (_expression$match = expression.match(/^\/(.*)\/([gimu]*)$/)) !== null && _expression$match !== void 0 ? _expression$match : [],
|
|
1337
|
+
_ref2 = _slicedToArray(_ref, 3),
|
|
1338
|
+
whole = _ref2[0],
|
|
1339
|
+
pattern = _ref2[1],
|
|
1340
|
+
flags = _ref2[2];
|
|
1341
|
+
if (isEmpty(whole)) {
|
|
1342
|
+
throw new Error("Invalid regular expression pattern: ".concat(expression));
|
|
1343
|
+
}
|
|
1344
|
+
if (flags.includes('u')) {
|
|
1345
|
+
pattern = pattern.replace(/\\A/g, '^').replace(/\\z/gi, '$').replace(/\\([pP])([CLMNPSZ])/g, '\\$1{$2}').replace(/\\\x\{([0-9a-f]+)\}/g, "\\u{$1}");
|
|
1346
|
+
}
|
|
1347
|
+
var result = new RegExp(pattern, flags).test(value);
|
|
1348
|
+
return invert ? !result : result;
|
|
1349
|
+
}
|
|
1350
|
+
}, {
|
|
1351
|
+
key: "checkNotRegex",
|
|
1352
|
+
value: function checkNotRegex(attribute, value, parameters) {
|
|
1353
|
+
return this.checkRegex(attribute, value, parameters, true);
|
|
1354
|
+
}
|
|
1355
|
+
}, {
|
|
1356
|
+
key: "checkLowercase",
|
|
1357
|
+
value: function checkLowercase(attribute, value, parameters) {
|
|
1358
|
+
return value === String(value).toLocaleLowerCase();
|
|
1359
|
+
}
|
|
1360
|
+
}, {
|
|
1361
|
+
key: "checkUppercase",
|
|
1362
|
+
value: function checkUppercase(attribute, value, parameters) {
|
|
1363
|
+
return value === String(value).toLocaleUpperCase();
|
|
1364
|
+
}
|
|
1365
|
+
}, {
|
|
1366
|
+
key: "checkStartsWith",
|
|
1367
|
+
value: function checkStartsWith(attribute, value, parameters) {
|
|
1368
|
+
value = String(value);
|
|
1369
|
+
var _iterator5 = _createForOfIteratorHelper(parameters),
|
|
1370
|
+
_step5;
|
|
1371
|
+
try {
|
|
1372
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
1373
|
+
var parameter = _step5.value;
|
|
1374
|
+
if (value.startsWith(parameter)) {
|
|
1375
|
+
return true;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
} catch (err) {
|
|
1379
|
+
_iterator5.e(err);
|
|
1380
|
+
} finally {
|
|
1381
|
+
_iterator5.f();
|
|
1382
|
+
}
|
|
1383
|
+
return false;
|
|
1384
|
+
}
|
|
1385
|
+
}, {
|
|
1386
|
+
key: "checkDoesntStartWith",
|
|
1387
|
+
value: function checkDoesntStartWith(attribute, value, parameters) {
|
|
1388
|
+
return !this.checkStartsWith(attribute, value, parameters);
|
|
1389
|
+
}
|
|
1390
|
+
}, {
|
|
1391
|
+
key: "checkEndsWith",
|
|
1392
|
+
value: function checkEndsWith(attribute, value, parameters) {
|
|
1393
|
+
value = String(value);
|
|
1394
|
+
var _iterator6 = _createForOfIteratorHelper(parameters),
|
|
1395
|
+
_step6;
|
|
1396
|
+
try {
|
|
1397
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
1398
|
+
var parameter = _step6.value;
|
|
1399
|
+
if (value.endsWith(parameter)) {
|
|
1400
|
+
return true;
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
} catch (err) {
|
|
1404
|
+
_iterator6.e(err);
|
|
1405
|
+
} finally {
|
|
1406
|
+
_iterator6.f();
|
|
1407
|
+
}
|
|
1408
|
+
return false;
|
|
1409
|
+
}
|
|
1410
|
+
}, {
|
|
1411
|
+
key: "checkDoesntEndWith",
|
|
1412
|
+
value: function checkDoesntEndWith(attribute, value, parameters) {
|
|
1413
|
+
return !this.checkEndsWith(attribute, value, parameters);
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
// Compare values
|
|
1417
|
+
}, {
|
|
1418
|
+
key: "checkSame",
|
|
1419
|
+
value: function checkSame(attribute, value, parameters) {
|
|
1420
|
+
var other = this.validator.getValue(parameters[0]);
|
|
1421
|
+
return value === other;
|
|
1422
|
+
}
|
|
1423
|
+
}, {
|
|
1424
|
+
key: "checkDifferent",
|
|
1425
|
+
value: function checkDifferent(attribute, value, parameters) {
|
|
1426
|
+
var _iterator7 = _createForOfIteratorHelper(parameters),
|
|
1427
|
+
_step7;
|
|
1428
|
+
try {
|
|
1429
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
1430
|
+
var parameter = _step7.value;
|
|
1431
|
+
var other = this.validator.getValue(parameter);
|
|
1432
|
+
if (typeof other !== 'undefined' && value === other) {
|
|
1433
|
+
return false;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
} catch (err) {
|
|
1437
|
+
_iterator7.e(err);
|
|
1438
|
+
} finally {
|
|
1439
|
+
_iterator7.f();
|
|
1440
|
+
}
|
|
1441
|
+
return true;
|
|
1442
|
+
}
|
|
1443
|
+
}, {
|
|
1444
|
+
key: "checkConfirmed",
|
|
1445
|
+
value: function checkConfirmed(attribute, value, parameters) {
|
|
1446
|
+
return this.checkSame(attribute, value, [attribute + '_confirmation']);
|
|
1447
|
+
}
|
|
1448
|
+
}, {
|
|
1449
|
+
key: "checkGt",
|
|
1450
|
+
value: function checkGt(attribute, value, parameters) {
|
|
1451
|
+
return this.compareValues(attribute, value, parameters, function (val1, val2) {
|
|
1452
|
+
return val1 > val2;
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
}, {
|
|
1456
|
+
key: "checkGte",
|
|
1457
|
+
value: function checkGte(attribute, value, parameters) {
|
|
1458
|
+
return this.compareValues(attribute, value, parameters, function (val1, val2) {
|
|
1459
|
+
return val1 >= val2;
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
}, {
|
|
1463
|
+
key: "checkLt",
|
|
1464
|
+
value: function checkLt(attribute, value, parameters) {
|
|
1465
|
+
return this.compareValues(attribute, value, parameters, function (val1, val2) {
|
|
1466
|
+
return val1 < val2;
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
}, {
|
|
1470
|
+
key: "checkLte",
|
|
1471
|
+
value: function checkLte(attribute, value, parameters) {
|
|
1472
|
+
return this.compareValues(attribute, value, parameters, function (val1, val2) {
|
|
1473
|
+
return val1 <= val2;
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
// Dates
|
|
1478
|
+
}, {
|
|
1479
|
+
key: "checkAfter",
|
|
1480
|
+
value: function checkAfter(attribute, value, parameters) {
|
|
1481
|
+
return this.compareDates(attribute, value, parameters, function (val1, val2) {
|
|
1482
|
+
return val1 > val2;
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
}, {
|
|
1486
|
+
key: "checkAfterOrEqual",
|
|
1487
|
+
value: function checkAfterOrEqual(attribute, value, parameters) {
|
|
1488
|
+
return this.compareDates(attribute, value, parameters, function (val1, val2) {
|
|
1489
|
+
return val1 >= val2;
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
}, {
|
|
1493
|
+
key: "checkBefore",
|
|
1494
|
+
value: function checkBefore(attribute, value, parameters) {
|
|
1495
|
+
return this.compareDates(attribute, value, parameters, function (val1, val2) {
|
|
1496
|
+
return val1 < val2;
|
|
1497
|
+
});
|
|
1498
|
+
}
|
|
1499
|
+
}, {
|
|
1500
|
+
key: "checkBeforeOrEqual",
|
|
1501
|
+
value: function checkBeforeOrEqual(attribute, value, parameters) {
|
|
1502
|
+
return this.compareDates(attribute, value, parameters, function (val1, val2) {
|
|
1503
|
+
return val1 <= val2;
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
}, {
|
|
1507
|
+
key: "checkDateEquals",
|
|
1508
|
+
value: function checkDateEquals(attribute, value, parameters) {
|
|
1509
|
+
return this.compareDates(attribute, value, parameters, function (val1, val2) {
|
|
1510
|
+
return val1 === val2;
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1513
|
+
}, {
|
|
1514
|
+
key: "checkDateFormat",
|
|
1515
|
+
value: function checkDateFormat(attribute, value, parameters) {
|
|
1516
|
+
var format = parameters[0].split('');
|
|
1517
|
+
var formats = {
|
|
1518
|
+
Y: '(\\d{4})',
|
|
1519
|
+
y: '(\\d{2})',
|
|
1520
|
+
m: '(\\d{2})',
|
|
1521
|
+
n: '([1-9]\\d?)',
|
|
1522
|
+
d: '(\\d{2})',
|
|
1523
|
+
j: '([1-9]\\d?)',
|
|
1524
|
+
G: '([1-9]\\d?)',
|
|
1525
|
+
g: '([1-9]\\d?)',
|
|
1526
|
+
H: '(\\d{2})',
|
|
1527
|
+
h: '(\\d{2})',
|
|
1528
|
+
i: '(\\d{2})',
|
|
1529
|
+
s: '(\\d{2})',
|
|
1530
|
+
A: '(AM|PM)',
|
|
1531
|
+
a: '(am|pm)'
|
|
1532
|
+
};
|
|
1533
|
+
var pattern = '^';
|
|
1534
|
+
var _iterator8 = _createForOfIteratorHelper(format),
|
|
1535
|
+
_step8;
|
|
1536
|
+
try {
|
|
1537
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1538
|
+
var char = _step8.value;
|
|
1539
|
+
if (formats.hasOwnProperty(char)) {
|
|
1540
|
+
pattern += formats[char];
|
|
1541
|
+
} else {
|
|
1542
|
+
pattern += '\\' + char;
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
} catch (err) {
|
|
1546
|
+
_iterator8.e(err);
|
|
1547
|
+
} finally {
|
|
1548
|
+
_iterator8.f();
|
|
1549
|
+
}
|
|
1550
|
+
pattern += '$';
|
|
1551
|
+
return new RegExp(pattern).test(value);
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
// Array / Object
|
|
1555
|
+
}, {
|
|
1556
|
+
key: "checkDistinct",
|
|
1557
|
+
value: function checkDistinct(attribute, value, parameters) {
|
|
1558
|
+
var _stringified$match$le, _stringified$match;
|
|
1559
|
+
var unparsed = this.validator.getPrimaryAttribute(attribute);
|
|
1560
|
+
if (!unparsed.includes('*')) {
|
|
1561
|
+
return true;
|
|
1562
|
+
}
|
|
1563
|
+
var index = unparsed.indexOf('*');
|
|
1564
|
+
var parentPath = unparsed.substring(0, index - 1);
|
|
1565
|
+
var stringified;
|
|
1566
|
+
if (_classPrivateFieldGet(this, _distinctCache).hasOwnProperty(parentPath)) {
|
|
1567
|
+
stringified = _classPrivateFieldGet(this, _distinctCache)[parentPath];
|
|
1568
|
+
} else {
|
|
1569
|
+
var _this$validator$getVa;
|
|
1570
|
+
stringified = JSON.stringify(flattenObject((_this$validator$getVa = this.validator.getValue(parentPath)) !== null && _this$validator$getVa !== void 0 ? _this$validator$getVa : {}));
|
|
1571
|
+
_classPrivateFieldGet(this, _distinctCache)[parentPath] = stringified;
|
|
1572
|
+
}
|
|
1573
|
+
var ignoreCase = parameters.includes('ignore_case');
|
|
1574
|
+
var isStrict = !ignoreCase && parameters.includes('strict');
|
|
1575
|
+
var escapedValue = escapeRegExp(String(value));
|
|
1576
|
+
var pattern = "\"".concat(escapeRegExp(unparsed.substring(index)).replaceAll('\\*', '[^."]+'), "\":");
|
|
1577
|
+
var counter = 0;
|
|
1578
|
+
if (isStrict) {
|
|
1579
|
+
if (typeof value === 'string') {
|
|
1580
|
+
pattern += "\"".concat(escapedValue, "\"");
|
|
1581
|
+
} else {
|
|
1582
|
+
pattern += "".concat(escapedValue);
|
|
1583
|
+
}
|
|
1584
|
+
} else {
|
|
1585
|
+
pattern += "(".concat(escapedValue, "|\"").concat(escapedValue, "\")");
|
|
1586
|
+
}
|
|
1587
|
+
pattern += '[,}]+';
|
|
1588
|
+
counter += (_stringified$match$le = (_stringified$match = stringified.match(new RegExp(pattern, 'g' + (ignoreCase ? 'i' : '')))) === null || _stringified$match === void 0 ? void 0 : _stringified$match.length) !== null && _stringified$match$le !== void 0 ? _stringified$match$le : 0;
|
|
1589
|
+
return counter === 1;
|
|
1590
|
+
}
|
|
1591
|
+
}, {
|
|
1592
|
+
key: "checkInArray",
|
|
1593
|
+
value: function checkInArray(attribute, value, parameters) {
|
|
1594
|
+
var _this$validator$getVa2;
|
|
1595
|
+
var unparsed = this.validator.getPrimaryAttribute(parameters[0]);
|
|
1596
|
+
if (!unparsed.includes('*')) {
|
|
1597
|
+
return false;
|
|
1598
|
+
}
|
|
1599
|
+
var data = (_this$validator$getVa2 = this.validator.getValue(unparsed.split('.*')[0])) !== null && _this$validator$getVa2 !== void 0 ? _this$validator$getVa2 : {};
|
|
1600
|
+
return Object.values(flattenObject(data)).some(function (item) {
|
|
1601
|
+
return item == value;
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
}, {
|
|
1605
|
+
key: "checkIn",
|
|
1606
|
+
value: function checkIn(attribute, value, parameters) {
|
|
1607
|
+
if (!(this.checkArray(attribute, value) && this.validator.hasRule(attribute, 'array'))) {
|
|
1608
|
+
return parameters.some(function (parameter) {
|
|
1609
|
+
return parameter == value;
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
var _loop = function _loop() {
|
|
1613
|
+
var item = _Object$values[_i2];
|
|
1614
|
+
if (!parameters.some(function (parameter) {
|
|
1615
|
+
return parameter == item;
|
|
1616
|
+
})) {
|
|
1617
|
+
return {
|
|
1618
|
+
v: false
|
|
1619
|
+
};
|
|
1620
|
+
}
|
|
1621
|
+
};
|
|
1622
|
+
for (var _i2 = 0, _Object$values = Object.values(value); _i2 < _Object$values.length; _i2++) {
|
|
1623
|
+
var _ret = _loop();
|
|
1624
|
+
if (_typeof(_ret) === "object") return _ret.v;
|
|
1625
|
+
}
|
|
1626
|
+
return true;
|
|
1627
|
+
}
|
|
1628
|
+
}, {
|
|
1629
|
+
key: "checkNotIn",
|
|
1630
|
+
value: function checkNotIn(attribute, value, parameters) {
|
|
1631
|
+
return !this.checkIn(attribute, value, parameters);
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
// File
|
|
1635
|
+
}, {
|
|
1636
|
+
key: "checkMimetypes",
|
|
1637
|
+
value: function checkMimetypes(attribute, value, parameters) {
|
|
1638
|
+
if (this.checkFile(attribute, value)) {
|
|
1639
|
+
return parameters.includes(value.type);
|
|
1640
|
+
}
|
|
1641
|
+
return false;
|
|
1642
|
+
}
|
|
1643
|
+
}, {
|
|
1644
|
+
key: "checkMimes",
|
|
1645
|
+
value: function checkMimes(attribute, value, parameters) {
|
|
1646
|
+
if (this.checkFile(attribute, value)) {
|
|
1647
|
+
return parameters.includes(value.name.split('.').pop().toLowerCase());
|
|
1648
|
+
}
|
|
1649
|
+
return false;
|
|
1650
|
+
}
|
|
1651
|
+
}, {
|
|
1652
|
+
key: "checkImage",
|
|
1653
|
+
value: function () {
|
|
1654
|
+
var _checkImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(attribute, value, parameters) {
|
|
1655
|
+
var _this = this;
|
|
1656
|
+
var result;
|
|
1657
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1658
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1659
|
+
case 0:
|
|
1660
|
+
result = this.checkMimes(attribute, value, ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg', 'webp']);
|
|
1661
|
+
if (!(!result || typeof FileReader === 'undefined')) {
|
|
1662
|
+
_context2.next = 3;
|
|
1663
|
+
break;
|
|
1664
|
+
}
|
|
1665
|
+
return _context2.abrupt("return", result);
|
|
1666
|
+
case 3:
|
|
1667
|
+
_context2.next = 5;
|
|
1668
|
+
return new Promise(function (resolve, reject) {
|
|
1669
|
+
var reader = new FileReader();
|
|
1670
|
+
reader.onload = function (event) {
|
|
1671
|
+
return resolve(event.target.result);
|
|
1672
|
+
};
|
|
1673
|
+
reader.onerror = reject;
|
|
1674
|
+
reader.readAsDataURL(value);
|
|
1675
|
+
}).then( /*#__PURE__*/function () {
|
|
1676
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {
|
|
1677
|
+
var image;
|
|
1678
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1679
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1680
|
+
case 0:
|
|
1681
|
+
image = new Image();
|
|
1682
|
+
image.src = data;
|
|
1683
|
+
_context.next = 4;
|
|
1684
|
+
return image.decode();
|
|
1685
|
+
case 4:
|
|
1686
|
+
_classPrivateFieldGet(_this, _imageCache)[attribute] = image;
|
|
1687
|
+
case 5:
|
|
1688
|
+
case "end":
|
|
1689
|
+
return _context.stop();
|
|
1690
|
+
}
|
|
1691
|
+
}, _callee);
|
|
1692
|
+
}));
|
|
1693
|
+
return function (_x4) {
|
|
1694
|
+
return _ref3.apply(this, arguments);
|
|
1695
|
+
};
|
|
1696
|
+
}()).catch(function () {
|
|
1697
|
+
result = false;
|
|
1698
|
+
});
|
|
1699
|
+
case 5:
|
|
1700
|
+
return _context2.abrupt("return", result);
|
|
1701
|
+
case 6:
|
|
1702
|
+
case "end":
|
|
1703
|
+
return _context2.stop();
|
|
1704
|
+
}
|
|
1705
|
+
}, _callee2, this);
|
|
1706
|
+
}));
|
|
1707
|
+
function checkImage(_x, _x2, _x3) {
|
|
1708
|
+
return _checkImage.apply(this, arguments);
|
|
1709
|
+
}
|
|
1710
|
+
return checkImage;
|
|
1711
|
+
}()
|
|
1712
|
+
}, {
|
|
1713
|
+
key: "checkDimensions",
|
|
1714
|
+
value: function () {
|
|
1715
|
+
var _checkDimensions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(attribute, value, parameters) {
|
|
1716
|
+
var constraints, _iterator9, _step9, parameter, _parameter$split, _parameter$split2, key, _value2, _value2$split$map, _value2$split$map2, numerator, denominator, image, width, height;
|
|
1717
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1718
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
1719
|
+
case 0:
|
|
1720
|
+
if (!(!this.checkImage(attribute, value) || !_classPrivateFieldGet(this, _imageCache).hasOwnProperty(attribute))) {
|
|
1721
|
+
_context3.next = 2;
|
|
1722
|
+
break;
|
|
1723
|
+
}
|
|
1724
|
+
return _context3.abrupt("return", false);
|
|
1725
|
+
case 2:
|
|
1726
|
+
constraints = {};
|
|
1727
|
+
_iterator9 = _createForOfIteratorHelper(parameters);
|
|
1728
|
+
try {
|
|
1729
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1730
|
+
parameter = _step9.value;
|
|
1731
|
+
_parameter$split = parameter.split('=', 2), _parameter$split2 = _slicedToArray(_parameter$split, 2), key = _parameter$split2[0], _value2 = _parameter$split2[1];
|
|
1732
|
+
if (key === 'ratio' && _value2.includes('/')) {
|
|
1733
|
+
_value2$split$map = _value2.split('/', 2).map(function (part) {
|
|
1734
|
+
return parseFloat(part, 10);
|
|
1735
|
+
}), _value2$split$map2 = _slicedToArray(_value2$split$map, 2), numerator = _value2$split$map2[0], denominator = _value2$split$map2[1];
|
|
1736
|
+
constraints[key] = numerator / denominator;
|
|
1737
|
+
} else {
|
|
1738
|
+
constraints[key] = parseFloat(_value2, 10);
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
} catch (err) {
|
|
1742
|
+
_iterator9.e(err);
|
|
1743
|
+
} finally {
|
|
1744
|
+
_iterator9.f();
|
|
1745
|
+
}
|
|
1746
|
+
image = _classPrivateFieldGet(this, _imageCache)[attribute];
|
|
1747
|
+
width = image.naturalWidth;
|
|
1748
|
+
height = image.naturalHeight;
|
|
1749
|
+
if (!(constraints.hasOwnProperty('width') && constraints.width !== width || constraints.hasOwnProperty('height') && constraints.height !== height || constraints.hasOwnProperty('min_width') && constraints.min_width > width || constraints.hasOwnProperty('min_height') && constraints.min_height > height || constraints.hasOwnProperty('max_width') && constraints.max_width < width || constraints.hasOwnProperty('max_height') && constraints.max_height < height)) {
|
|
1750
|
+
_context3.next = 10;
|
|
1751
|
+
break;
|
|
1752
|
+
}
|
|
1753
|
+
return _context3.abrupt("return", false);
|
|
1754
|
+
case 10:
|
|
1755
|
+
if (!constraints.hasOwnProperty('ratio')) {
|
|
1756
|
+
_context3.next = 12;
|
|
1757
|
+
break;
|
|
1758
|
+
}
|
|
1759
|
+
return _context3.abrupt("return", Math.abs(constraints.ratio - width / height) <= 1 / (Math.max(width, height) + 1));
|
|
1760
|
+
case 12:
|
|
1761
|
+
return _context3.abrupt("return", true);
|
|
1762
|
+
case 13:
|
|
1763
|
+
case "end":
|
|
1764
|
+
return _context3.stop();
|
|
1765
|
+
}
|
|
1766
|
+
}, _callee3, this);
|
|
1767
|
+
}));
|
|
1768
|
+
function checkDimensions(_x5, _x6, _x7) {
|
|
1769
|
+
return _checkDimensions.apply(this, arguments);
|
|
1770
|
+
}
|
|
1771
|
+
return checkDimensions;
|
|
1772
|
+
}() // Miscellaneous
|
|
1773
|
+
}, {
|
|
1774
|
+
key: "checkEmail",
|
|
1775
|
+
value: function checkEmail(attribute, value, parameters) {
|
|
1776
|
+
var firstRegex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
1777
|
+
if (!firstRegex.test(value)) {
|
|
1778
|
+
var secondRegex = /^((?:[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]|[^\u0000-\u007F])+@(?:[a-zA-Z0-9]|[^\u0000-\u007F])(?:(?:[a-zA-Z0-9-]|[^\u0000-\u007F]){0,61}(?:[a-zA-Z0-9]|[^\u0000-\u007F]))?(?:\.(?:[a-zA-Z0-9]|[^\u0000-\u007F])(?:(?:[a-zA-Z0-9-]|[^\u0000-\u007F]){0,61}(?:[a-zA-Z0-9]|[^\u0000-\u007F]))?)+)*$/;
|
|
1779
|
+
return secondRegex.test(value);
|
|
1780
|
+
}
|
|
1781
|
+
return true;
|
|
1782
|
+
}
|
|
1783
|
+
}, {
|
|
1784
|
+
key: "checkJson",
|
|
1785
|
+
value: function checkJson(attribute, value, parameters) {
|
|
1786
|
+
try {
|
|
1787
|
+
JSON.parse(value);
|
|
1788
|
+
} catch (error) {
|
|
1789
|
+
return false;
|
|
1790
|
+
}
|
|
1791
|
+
return true;
|
|
1792
|
+
}
|
|
1793
|
+
}, {
|
|
1794
|
+
key: "checkMacAddress",
|
|
1795
|
+
value: function checkMacAddress(attribute, value, parameters) {
|
|
1796
|
+
value = String(value);
|
|
1797
|
+
var separators = {
|
|
1798
|
+
'-': 2,
|
|
1799
|
+
':': 2,
|
|
1800
|
+
'.': 4
|
|
1801
|
+
};
|
|
1802
|
+
var separator, digits;
|
|
1803
|
+
for (var _i3 = 0, _Object$entries = Object.entries(separators); _i3 < _Object$entries.length; _i3++) {
|
|
1804
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i3], 2);
|
|
1805
|
+
separator = _Object$entries$_i[0];
|
|
1806
|
+
digits = _Object$entries$_i[1];
|
|
1807
|
+
if (value.includes(separator)) {
|
|
1808
|
+
break;
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
var blocks = value.split(separator);
|
|
1812
|
+
if (blocks.length !== 12 / digits) {
|
|
1813
|
+
return false;
|
|
1814
|
+
}
|
|
1815
|
+
var _iterator10 = _createForOfIteratorHelper(blocks),
|
|
1816
|
+
_step10;
|
|
1817
|
+
try {
|
|
1818
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
1819
|
+
var block = _step10.value;
|
|
1820
|
+
if (!new RegExp('^[0-9a-f]{' + digits + '}$', 'i').test(block)) {
|
|
1821
|
+
return false;
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
} catch (err) {
|
|
1825
|
+
_iterator10.e(err);
|
|
1826
|
+
} finally {
|
|
1827
|
+
_iterator10.f();
|
|
1828
|
+
}
|
|
1829
|
+
return true;
|
|
1830
|
+
}
|
|
1831
|
+
}, {
|
|
1832
|
+
key: "checkIpv4",
|
|
1833
|
+
value: function checkIpv4(attribute, value, parameters) {
|
|
1834
|
+
if (/[^\d.]/.test(value)) {
|
|
1835
|
+
return false;
|
|
1836
|
+
}
|
|
1837
|
+
var blocks = String(value).split('.');
|
|
1838
|
+
if (blocks.length !== 4) {
|
|
1839
|
+
return false;
|
|
1840
|
+
}
|
|
1841
|
+
var _iterator11 = _createForOfIteratorHelper(blocks),
|
|
1842
|
+
_step11;
|
|
1843
|
+
try {
|
|
1844
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
1845
|
+
var block = _step11.value;
|
|
1846
|
+
if (block < 0 || block > 255) {
|
|
1847
|
+
return false;
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
} catch (err) {
|
|
1851
|
+
_iterator11.e(err);
|
|
1852
|
+
} finally {
|
|
1853
|
+
_iterator11.f();
|
|
1854
|
+
}
|
|
1855
|
+
return true;
|
|
1856
|
+
}
|
|
1857
|
+
}, {
|
|
1858
|
+
key: "checkIpv6",
|
|
1859
|
+
value: function checkIpv6(attribute, value, parameters) {
|
|
1860
|
+
value = String(value);
|
|
1861
|
+
if (value.split('::').length > 2) {
|
|
1862
|
+
return false;
|
|
1863
|
+
}
|
|
1864
|
+
var blocks = value.split(':');
|
|
1865
|
+
if (blocks.length < 3 || blocks.length > 8) {
|
|
1866
|
+
return false;
|
|
1867
|
+
}
|
|
1868
|
+
var _iterator12 = _createForOfIteratorHelper(blocks),
|
|
1869
|
+
_step12;
|
|
1870
|
+
try {
|
|
1871
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
1872
|
+
var block = _step12.value;
|
|
1873
|
+
if (block !== '' && !/^[0-9a-f]{1,4}$/i.test(block)) {
|
|
1874
|
+
return false;
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
} catch (err) {
|
|
1878
|
+
_iterator12.e(err);
|
|
1879
|
+
} finally {
|
|
1880
|
+
_iterator12.f();
|
|
1881
|
+
}
|
|
1882
|
+
return true;
|
|
1883
|
+
}
|
|
1884
|
+
}, {
|
|
1885
|
+
key: "checkIp",
|
|
1886
|
+
value: function checkIp(attribute, value, parameters) {
|
|
1887
|
+
return this.checkIpv4(attribute, value, parameters) || this.checkIpv6(attribute, value, parameters);
|
|
1888
|
+
}
|
|
1889
|
+
}, {
|
|
1890
|
+
key: "checkTimezone",
|
|
1891
|
+
value: function checkTimezone(attribute, value, parameters) {
|
|
1892
|
+
try {
|
|
1893
|
+
Intl.DateTimeFormat(undefined, {
|
|
1894
|
+
timeZone: value
|
|
1895
|
+
});
|
|
1896
|
+
} catch (error) {
|
|
1897
|
+
if (String(error).toLowerCase().includes('invalid time zone')) {
|
|
1898
|
+
return false;
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
return true;
|
|
1902
|
+
}
|
|
1903
|
+
}, {
|
|
1904
|
+
key: "checkUrl",
|
|
1905
|
+
value: function checkUrl(attribute, value, parameters) {
|
|
1906
|
+
try {
|
|
1907
|
+
new URL(value);
|
|
1908
|
+
} catch (error) {
|
|
1909
|
+
return false;
|
|
1910
|
+
}
|
|
1911
|
+
return true;
|
|
1912
|
+
}
|
|
1913
|
+
}, {
|
|
1914
|
+
key: "checkUlid",
|
|
1915
|
+
value: function checkUlid(attribute, value, parameters) {
|
|
1916
|
+
return /[0-7][0-9A-HJKMNP-TV-Z]{25}/.test(value);
|
|
1917
|
+
}
|
|
1918
|
+
}, {
|
|
1919
|
+
key: "checkUuid",
|
|
1920
|
+
value: function checkUuid(attribute, value, parameters) {
|
|
1921
|
+
return /[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(value);
|
|
1922
|
+
}
|
|
1923
|
+
}]);
|
|
1924
|
+
return Checkers;
|
|
1925
|
+
}();
|
|
1926
|
+
|
|
1927
|
+
var _data$1 = /*#__PURE__*/new WeakMap();
|
|
1928
|
+
var ErrorBag = /*#__PURE__*/function () {
|
|
1929
|
+
function ErrorBag() {
|
|
1930
|
+
_classCallCheck(this, ErrorBag);
|
|
1931
|
+
_classPrivateFieldInitSpec(this, _data$1, {
|
|
1932
|
+
writable: true,
|
|
1933
|
+
value: {}
|
|
1934
|
+
});
|
|
1935
|
+
}
|
|
1936
|
+
_createClass(ErrorBag, [{
|
|
1937
|
+
key: "keys",
|
|
1938
|
+
value: function keys() {
|
|
1939
|
+
return Object.keys(_classPrivateFieldGet(this, _data$1));
|
|
1940
|
+
}
|
|
1941
|
+
}, {
|
|
1942
|
+
key: "values",
|
|
1943
|
+
value: function values() {
|
|
1944
|
+
return Object.values(_classPrivateFieldGet(this, _data$1));
|
|
1945
|
+
}
|
|
1946
|
+
}, {
|
|
1947
|
+
key: "entries",
|
|
1948
|
+
value: function entries() {
|
|
1949
|
+
return Object.entries(_classPrivateFieldGet(this, _data$1));
|
|
1950
|
+
}
|
|
1951
|
+
}, {
|
|
1952
|
+
key: "add",
|
|
1953
|
+
value: function add(key, message) {
|
|
1954
|
+
if (_classPrivateFieldGet(this, _data$1).hasOwnProperty(key)) {
|
|
1955
|
+
_classPrivateFieldGet(this, _data$1)[key].push(message);
|
|
1956
|
+
} else {
|
|
1957
|
+
_classPrivateFieldGet(this, _data$1)[key] = [message];
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
}, {
|
|
1961
|
+
key: "get",
|
|
1962
|
+
value: function get(key) {
|
|
1963
|
+
if (!key.includes('*')) {
|
|
1964
|
+
return _classPrivateFieldGet(this, _data$1).hasOwnProperty(key) ? _classPrivateFieldGet(this, _data$1)[key] : {};
|
|
1965
|
+
}
|
|
1966
|
+
var pattern = new RegExp('^' + key.replaceAll('*', '.*?') + '$');
|
|
1967
|
+
var result = {};
|
|
1968
|
+
var _iterator = _createForOfIteratorHelper(this.entries()),
|
|
1969
|
+
_step;
|
|
1970
|
+
try {
|
|
1971
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1972
|
+
var _step$value = _slicedToArray(_step.value, 2),
|
|
1973
|
+
_key = _step$value[0],
|
|
1974
|
+
value = _step$value[1];
|
|
1975
|
+
if (pattern.test(_key)) {
|
|
1976
|
+
result[_key] = value;
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
} catch (err) {
|
|
1980
|
+
_iterator.e(err);
|
|
1981
|
+
} finally {
|
|
1982
|
+
_iterator.f();
|
|
1983
|
+
}
|
|
1984
|
+
return result;
|
|
1985
|
+
}
|
|
1986
|
+
}, {
|
|
1987
|
+
key: "first",
|
|
1988
|
+
value: function first(key) {
|
|
1989
|
+
for (var _i = 0, _Object$values = Object.values(this.get(key)); _i < _Object$values.length; _i++) {
|
|
1990
|
+
var message = _Object$values[_i];
|
|
1991
|
+
return Array.isArray(message) ? message[0] : message;
|
|
1992
|
+
}
|
|
1993
|
+
return '';
|
|
1994
|
+
}
|
|
1995
|
+
}, {
|
|
1996
|
+
key: "has",
|
|
1997
|
+
value: function has(key) {
|
|
1998
|
+
return this.first(key) !== '';
|
|
1999
|
+
}
|
|
2000
|
+
}, {
|
|
2001
|
+
key: "messages",
|
|
2002
|
+
value: function messages() {
|
|
2003
|
+
return _classPrivateFieldGet(this, _data$1);
|
|
2004
|
+
}
|
|
2005
|
+
}, {
|
|
2006
|
+
key: "all",
|
|
2007
|
+
value: function all() {
|
|
2008
|
+
var result = [];
|
|
2009
|
+
this.values().forEach(function (messages) {
|
|
2010
|
+
return result.push.apply(result, _toConsumableArray(messages));
|
|
2011
|
+
});
|
|
2012
|
+
return result;
|
|
2013
|
+
}
|
|
2014
|
+
}, {
|
|
2015
|
+
key: "count",
|
|
2016
|
+
value: function count() {
|
|
2017
|
+
var count = 0;
|
|
2018
|
+
this.values().forEach(function (messages) {
|
|
2019
|
+
return count += messages.length;
|
|
2020
|
+
});
|
|
2021
|
+
return count;
|
|
2022
|
+
}
|
|
2023
|
+
}, {
|
|
2024
|
+
key: "isEmpty",
|
|
2025
|
+
value: function isEmpty() {
|
|
2026
|
+
return this.keys().length === 0;
|
|
2027
|
+
}
|
|
2028
|
+
}, {
|
|
2029
|
+
key: "isNotEmpty",
|
|
2030
|
+
value: function isNotEmpty() {
|
|
2031
|
+
return !this.isEmpty();
|
|
2032
|
+
}
|
|
2033
|
+
}]);
|
|
2034
|
+
return ErrorBag;
|
|
2035
|
+
}();
|
|
2036
|
+
|
|
2037
|
+
var Lang = /*#__PURE__*/function () {
|
|
2038
|
+
function Lang() {
|
|
2039
|
+
_classCallCheck(this, Lang);
|
|
2040
|
+
}
|
|
2041
|
+
_createClass(Lang, null, [{
|
|
2042
|
+
key: "locale",
|
|
2043
|
+
value: function locale(_locale2) {
|
|
2044
|
+
_classStaticPrivateFieldSpecSet(this, Lang, _locale, _locale2);
|
|
2045
|
+
}
|
|
2046
|
+
}, {
|
|
2047
|
+
key: "setMessages",
|
|
2048
|
+
value: function setMessages(locale, messages) {
|
|
2049
|
+
_classStaticPrivateFieldSpecGet(this, Lang, _messages)[locale] = flattenObject(messages);
|
|
2050
|
+
}
|
|
2051
|
+
}, {
|
|
2052
|
+
key: "get",
|
|
2053
|
+
value: function get(path) {
|
|
2054
|
+
if (_classStaticPrivateFieldSpecGet(this, Lang, _messages)[_classStaticPrivateFieldSpecGet(this, Lang, _locale)] && _classStaticPrivateFieldSpecGet(this, Lang, _messages)[_classStaticPrivateFieldSpecGet(this, Lang, _locale)][path]) {
|
|
2055
|
+
return _classStaticPrivateFieldSpecGet(this, Lang, _messages)[_classStaticPrivateFieldSpecGet(this, Lang, _locale)][path];
|
|
2056
|
+
}
|
|
2057
|
+
return;
|
|
2058
|
+
}
|
|
2059
|
+
}, {
|
|
2060
|
+
key: "has",
|
|
2061
|
+
value: function has(path) {
|
|
2062
|
+
return typeof this.get(path) === 'undefined' ? false : true;
|
|
2063
|
+
}
|
|
2064
|
+
}, {
|
|
2065
|
+
key: "set",
|
|
2066
|
+
value: function set(path, value) {
|
|
2067
|
+
if (isPlainObject(value)) {
|
|
2068
|
+
Object.assign(_classStaticPrivateFieldSpecGet(this, Lang, _messages)[_classStaticPrivateFieldSpecGet(this, Lang, _locale)], flattenObject(value, path));
|
|
2069
|
+
} else if (typeof value === 'string') {
|
|
2070
|
+
_classStaticPrivateFieldSpecGet(this, Lang, _messages)[_classStaticPrivateFieldSpecGet(this, Lang, _locale)][path] = value;
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
}]);
|
|
2074
|
+
return Lang;
|
|
2075
|
+
}();
|
|
2076
|
+
var _locale = {
|
|
2077
|
+
writable: true,
|
|
2078
|
+
value: void 0
|
|
2079
|
+
};
|
|
2080
|
+
var _messages = {
|
|
2081
|
+
writable: true,
|
|
2082
|
+
value: {}
|
|
2083
|
+
};
|
|
2084
|
+
|
|
2085
|
+
var Replacers = /*#__PURE__*/function () {
|
|
2086
|
+
function Replacers(validator) {
|
|
2087
|
+
_classCallCheck(this, Replacers);
|
|
2088
|
+
_defineProperty(this, "validator", void 0);
|
|
2089
|
+
this.validator = validator;
|
|
2090
|
+
}
|
|
2091
|
+
_createClass(Replacers, [{
|
|
2092
|
+
key: "replace",
|
|
2093
|
+
value: function replace(message, data) {
|
|
2094
|
+
Object.entries(data).forEach(function (_ref) {
|
|
2095
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
2096
|
+
key = _ref2[0],
|
|
2097
|
+
value = _ref2[1];
|
|
2098
|
+
return message = message.replaceAll(':' + key, value);
|
|
2099
|
+
});
|
|
2100
|
+
return message;
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
// Numeric
|
|
2104
|
+
}, {
|
|
2105
|
+
key: "replaceDecimal",
|
|
2106
|
+
value: function replaceDecimal(message, attribute, rule, parameters) {
|
|
2107
|
+
return this.replace(message, {
|
|
2108
|
+
decimal: parameters.join('-')
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
2111
|
+
}, {
|
|
2112
|
+
key: "replaceMultipleOf",
|
|
2113
|
+
value: function replaceMultipleOf(message, attribute, rule, parameters) {
|
|
2114
|
+
return this.replace(message, {
|
|
2115
|
+
value: parameters[0]
|
|
2116
|
+
});
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
// Agreement
|
|
2120
|
+
}, {
|
|
2121
|
+
key: "replaceAcceptedIf",
|
|
2122
|
+
value: function replaceAcceptedIf(message, attribute, rule, parameters) {
|
|
2123
|
+
return this.replace(message, {
|
|
2124
|
+
other: this.validator.getDisplayableAttribute(parameters[0]),
|
|
2125
|
+
value: this.validator.getDisplayableValue(parameters[0], this.validator.getValue(parameters[0]))
|
|
2126
|
+
});
|
|
2127
|
+
}
|
|
2128
|
+
}, {
|
|
2129
|
+
key: "replaceDeclinedIf",
|
|
2130
|
+
value: function replaceDeclinedIf(message, attribute, rule, parameters) {
|
|
2131
|
+
return this.replaceAcceptedIf(message, attribute, rule, parameters);
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
// Existence
|
|
2135
|
+
}, {
|
|
2136
|
+
key: "replaceRequiredArrayKeys",
|
|
2137
|
+
value: function replaceRequiredArrayKeys(message, attribute, rule, parameters) {
|
|
2138
|
+
var _this = this;
|
|
2139
|
+
return this.replace(message, {
|
|
2140
|
+
values: parameters.map(function (value) {
|
|
2141
|
+
return _this.validator.getDisplayableValue(attribute, value);
|
|
2142
|
+
}).join(', ')
|
|
2143
|
+
});
|
|
2144
|
+
}
|
|
2145
|
+
}, {
|
|
2146
|
+
key: "replaceRequiredIf",
|
|
2147
|
+
value: function replaceRequiredIf(message, attribute, rule, parameters) {
|
|
2148
|
+
return this.replaceAcceptedIf(message, attribute, rule, parameters);
|
|
2149
|
+
}
|
|
2150
|
+
}, {
|
|
2151
|
+
key: "replaceRequiredIfAccepted",
|
|
2152
|
+
value: function replaceRequiredIfAccepted(message, attribute, rule, parameters) {
|
|
2153
|
+
return this.replaceAcceptedIf(message, attribute, rule, parameters);
|
|
2154
|
+
}
|
|
2155
|
+
}, {
|
|
2156
|
+
key: "replaceRequiredUnless",
|
|
2157
|
+
value: function replaceRequiredUnless(message, attribute, rule, parameters) {
|
|
2158
|
+
var _this2 = this;
|
|
2159
|
+
return this.replace(message, {
|
|
2160
|
+
other: this.validator.getDisplayableAttribute(parameters[0]),
|
|
2161
|
+
values: parameters.slice(1).map(function (value) {
|
|
2162
|
+
return _this2.validator.getDisplayableValue(parameters[0], value);
|
|
2163
|
+
}).join(', ')
|
|
2164
|
+
});
|
|
2165
|
+
}
|
|
2166
|
+
}, {
|
|
2167
|
+
key: "replaceRequiredWith",
|
|
2168
|
+
value: function replaceRequiredWith(message, attribute, rule, parameters) {
|
|
2169
|
+
var _this3 = this;
|
|
2170
|
+
return this.replace(message, {
|
|
2171
|
+
values: parameters.map(function (value) {
|
|
2172
|
+
return _this3.validator.getDisplayableAttribute(value);
|
|
2173
|
+
}).join(' / ')
|
|
2174
|
+
});
|
|
2175
|
+
}
|
|
2176
|
+
}, {
|
|
2177
|
+
key: "replaceRequiredWithAll",
|
|
2178
|
+
value: function replaceRequiredWithAll(message, attribute, rule, parameters) {
|
|
2179
|
+
return this.replaceRequiredWith(message, attribute, rule, parameters);
|
|
2180
|
+
}
|
|
2181
|
+
}, {
|
|
2182
|
+
key: "replaceRequiredWithout",
|
|
2183
|
+
value: function replaceRequiredWithout(message, attribute, rule, parameters) {
|
|
2184
|
+
return this.replaceRequiredWith(message, attribute, rule, parameters);
|
|
2185
|
+
}
|
|
2186
|
+
}, {
|
|
2187
|
+
key: "replaceRequiredWithoutAll",
|
|
2188
|
+
value: function replaceRequiredWithoutAll(message, attribute, rule, parameters) {
|
|
2189
|
+
return this.replaceRequiredWith(message, attribute, rule, parameters);
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2192
|
+
// Missing
|
|
2193
|
+
}, {
|
|
2194
|
+
key: "replaceMissingIf",
|
|
2195
|
+
value: function replaceMissingIf(message, attribute, rule, parameters) {
|
|
2196
|
+
return this.replaceAcceptedIf(message, attribute, rule, parameters);
|
|
2197
|
+
}
|
|
2198
|
+
}, {
|
|
2199
|
+
key: "replaceMissingUnless",
|
|
2200
|
+
value: function replaceMissingUnless(message, attribute, rule, parameters) {
|
|
2201
|
+
return this.replace(this.replaceRequiredUnless(message, attribute, rule, parameters), {
|
|
2202
|
+
value: this.validator.getDisplayableValue(parameters[0], parameters[1])
|
|
2203
|
+
});
|
|
2204
|
+
}
|
|
2205
|
+
}, {
|
|
2206
|
+
key: "replaceMissingWith",
|
|
2207
|
+
value: function replaceMissingWith(message, attribute, rule, parameters) {
|
|
2208
|
+
return this.replaceRequiredWith(message, attribute, rule, parameters);
|
|
2209
|
+
}
|
|
2210
|
+
}, {
|
|
2211
|
+
key: "replaceMissingWithAll",
|
|
2212
|
+
value: function replaceMissingWithAll(message, attribute, rule, parameters) {
|
|
2213
|
+
return this.replaceRequiredWith(message, attribute, rule, parameters);
|
|
2214
|
+
}
|
|
2215
|
+
|
|
2216
|
+
// Prohibition
|
|
2217
|
+
}, {
|
|
2218
|
+
key: "replaceProhibitedIf",
|
|
2219
|
+
value: function replaceProhibitedIf(message, attribute, rule, parameters) {
|
|
2220
|
+
return this.replaceAcceptedIf(message, attribute, rule, parameters);
|
|
2221
|
+
}
|
|
2222
|
+
}, {
|
|
2223
|
+
key: "replaceProhibitedUnless",
|
|
2224
|
+
value: function replaceProhibitedUnless(message, attribute, rule, parameters) {
|
|
2225
|
+
return this.replaceRequiredUnless(message, attribute, rule, parameters);
|
|
2226
|
+
}
|
|
2227
|
+
}, {
|
|
2228
|
+
key: "replaceProhibits",
|
|
2229
|
+
value: function replaceProhibits(message, attribute, rule, parameters) {
|
|
2230
|
+
var _this4 = this;
|
|
2231
|
+
return this.replace(message, {
|
|
2232
|
+
other: parameters.map(function (value) {
|
|
2233
|
+
return _this4.validator.getDisplayableAttribute(value);
|
|
2234
|
+
}).join(' / ')
|
|
2235
|
+
});
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
// Size
|
|
2239
|
+
}, {
|
|
2240
|
+
key: "replaceSize",
|
|
2241
|
+
value: function replaceSize(message, attribute, rule, parameters) {
|
|
2242
|
+
return this.replace(message, {
|
|
2243
|
+
size: parameters[0]
|
|
2244
|
+
});
|
|
2245
|
+
}
|
|
2246
|
+
}, {
|
|
2247
|
+
key: "replaceMin",
|
|
2248
|
+
value: function replaceMin(message, attribute, rule, parameters) {
|
|
2249
|
+
return this.replace(message, {
|
|
2250
|
+
min: parameters[0]
|
|
2251
|
+
});
|
|
2252
|
+
}
|
|
2253
|
+
}, {
|
|
2254
|
+
key: "replaceMax",
|
|
2255
|
+
value: function replaceMax(message, attribute, rule, parameters) {
|
|
2256
|
+
return this.replace(message, {
|
|
2257
|
+
max: parameters[0]
|
|
2258
|
+
});
|
|
2259
|
+
}
|
|
2260
|
+
}, {
|
|
2261
|
+
key: "replaceBetween",
|
|
2262
|
+
value: function replaceBetween(message, attribute, rule, parameters) {
|
|
2263
|
+
return this.replace(message, {
|
|
2264
|
+
min: parameters[0],
|
|
2265
|
+
max: parameters[1]
|
|
2266
|
+
});
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
// Digits
|
|
2270
|
+
}, {
|
|
2271
|
+
key: "replaceDigits",
|
|
2272
|
+
value: function replaceDigits(message, attribute, rule, parameters) {
|
|
2273
|
+
return this.replace(message, {
|
|
2274
|
+
digits: parameters[0]
|
|
2275
|
+
});
|
|
2276
|
+
}
|
|
2277
|
+
}, {
|
|
2278
|
+
key: "replaceMinDigits",
|
|
2279
|
+
value: function replaceMinDigits(message, attribute, rule, parameters) {
|
|
2280
|
+
return this.replaceMin(message, attribute, rule, parameters);
|
|
2281
|
+
}
|
|
2282
|
+
}, {
|
|
2283
|
+
key: "replaceMaxDigits",
|
|
2284
|
+
value: function replaceMaxDigits(message, attribute, rule, parameters) {
|
|
2285
|
+
return this.replaceMax(message, attribute, rule, parameters);
|
|
2286
|
+
}
|
|
2287
|
+
}, {
|
|
2288
|
+
key: "replaceDigitsBetween",
|
|
2289
|
+
value: function replaceDigitsBetween(message, attribute, rule, parameters) {
|
|
2290
|
+
return this.replaceBetween(message, attribute, rule, parameters);
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
// String
|
|
2294
|
+
}, {
|
|
2295
|
+
key: "replaceStartsWith",
|
|
2296
|
+
value: function replaceStartsWith(message, attribute, rule, parameters) {
|
|
2297
|
+
return this.replaceRequiredArrayKeys(message, attribute, rule, parameters);
|
|
2298
|
+
}
|
|
2299
|
+
}, {
|
|
2300
|
+
key: "replaceDoesntStartWith",
|
|
2301
|
+
value: function replaceDoesntStartWith(message, attribute, rule, parameters) {
|
|
2302
|
+
return this.replaceRequiredArrayKeys(message, attribute, rule, parameters);
|
|
2303
|
+
}
|
|
2304
|
+
}, {
|
|
2305
|
+
key: "replaceEndsWith",
|
|
2306
|
+
value: function replaceEndsWith(message, attribute, rule, parameters) {
|
|
2307
|
+
return this.replaceRequiredArrayKeys(message, attribute, rule, parameters);
|
|
2308
|
+
}
|
|
2309
|
+
}, {
|
|
2310
|
+
key: "replaceDoesntEndWith",
|
|
2311
|
+
value: function replaceDoesntEndWith(message, attribute, rule, parameters) {
|
|
2312
|
+
return this.replaceRequiredArrayKeys(message, attribute, rule, parameters);
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
// Compare values
|
|
2316
|
+
}, {
|
|
2317
|
+
key: "replaceSame",
|
|
2318
|
+
value: function replaceSame(message, attribute, rule, parameters) {
|
|
2319
|
+
return this.replaceAcceptedIf(message, attribute, rule, parameters);
|
|
2320
|
+
}
|
|
2321
|
+
}, {
|
|
2322
|
+
key: "replaceDifferent",
|
|
2323
|
+
value: function replaceDifferent(message, attribute, rule, parameters) {
|
|
2324
|
+
return this.replaceAcceptedIf(message, attribute, rule, parameters);
|
|
2325
|
+
}
|
|
2326
|
+
}, {
|
|
2327
|
+
key: "replaceGt",
|
|
2328
|
+
value: function replaceGt(message, attribute, rule, parameters) {
|
|
2329
|
+
var value = this.validator.getValue(parameters[0]);
|
|
2330
|
+
return this.replace(message, {
|
|
2331
|
+
value: value ? this.validator.getSize(parameters[0], value) : this.validator.getDisplayableAttribute(parameters[0])
|
|
2332
|
+
});
|
|
2333
|
+
}
|
|
2334
|
+
}, {
|
|
2335
|
+
key: "replaceGte",
|
|
2336
|
+
value: function replaceGte(message, attribute, rule, parameters) {
|
|
2337
|
+
return this.replaceGt(message, attribute, rule, parameters);
|
|
2338
|
+
}
|
|
2339
|
+
}, {
|
|
2340
|
+
key: "replaceLt",
|
|
2341
|
+
value: function replaceLt(message, attribute, rule, parameters) {
|
|
2342
|
+
return this.replaceGt(message, attribute, rule, parameters);
|
|
2343
|
+
}
|
|
2344
|
+
}, {
|
|
2345
|
+
key: "replaceLte",
|
|
2346
|
+
value: function replaceLte(message, attribute, rule, parameters) {
|
|
2347
|
+
return this.replaceGt(message, attribute, rule, parameters);
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
// Dates
|
|
2351
|
+
}, {
|
|
2352
|
+
key: "replaceAfter",
|
|
2353
|
+
value: function replaceAfter(message, attribute, rule, parameters) {
|
|
2354
|
+
var other = parameters[0];
|
|
2355
|
+
return this.replace(message, {
|
|
2356
|
+
date: this.validator.hasAttribute(other) ? this.validator.getDisplayableAttribute(other) : other
|
|
2357
|
+
});
|
|
2358
|
+
}
|
|
2359
|
+
}, {
|
|
2360
|
+
key: "replaceAfterOrEqual",
|
|
2361
|
+
value: function replaceAfterOrEqual(message, attribute, rule, parameters) {
|
|
2362
|
+
return this.replaceAfter(message, attribute, rule, parameters);
|
|
2363
|
+
}
|
|
2364
|
+
}, {
|
|
2365
|
+
key: "replaceBefore",
|
|
2366
|
+
value: function replaceBefore(message, attribute, rule, parameters) {
|
|
2367
|
+
return this.replaceAfter(message, attribute, rule, parameters);
|
|
2368
|
+
}
|
|
2369
|
+
}, {
|
|
2370
|
+
key: "replaceBeforeOrEqual",
|
|
2371
|
+
value: function replaceBeforeOrEqual(message, attribute, rule, parameters) {
|
|
2372
|
+
return this.replaceAfter(message, attribute, rule, parameters);
|
|
2373
|
+
}
|
|
2374
|
+
}, {
|
|
2375
|
+
key: "replaceDateEquals",
|
|
2376
|
+
value: function replaceDateEquals(message, attribute, rule, parameters) {
|
|
2377
|
+
return this.replaceAfter(message, attribute, rule, parameters);
|
|
2378
|
+
}
|
|
2379
|
+
}, {
|
|
2380
|
+
key: "replaceDateFormat",
|
|
2381
|
+
value: function replaceDateFormat(message, attribute, rule, parameters) {
|
|
2382
|
+
return this.replace(message, {
|
|
2383
|
+
format: parameters[0]
|
|
2384
|
+
});
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
// Array
|
|
2388
|
+
}, {
|
|
2389
|
+
key: "replaceInArray",
|
|
2390
|
+
value: function replaceInArray(message, attribute, rule, parameters) {
|
|
2391
|
+
return this.replaceAcceptedIf(message, attribute, rule, parameters);
|
|
2392
|
+
}
|
|
2393
|
+
}, {
|
|
2394
|
+
key: "replaceIn",
|
|
2395
|
+
value: function replaceIn(message, attribute, rule, parameters) {
|
|
2396
|
+
return this.replaceRequiredArrayKeys(message, attribute, rule, parameters);
|
|
2397
|
+
}
|
|
2398
|
+
}, {
|
|
2399
|
+
key: "replaceNotIn",
|
|
2400
|
+
value: function replaceNotIn(message, attribute, rule, parameters) {
|
|
2401
|
+
return this.replaceRequiredArrayKeys(message, attribute, rule, parameters);
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
// File
|
|
2405
|
+
}, {
|
|
2406
|
+
key: "replaceMimetypes",
|
|
2407
|
+
value: function replaceMimetypes(message, attribute, rule, parameters) {
|
|
2408
|
+
return this.replace(message, {
|
|
2409
|
+
values: parameters.join(', ')
|
|
2410
|
+
});
|
|
2411
|
+
}
|
|
2412
|
+
}, {
|
|
2413
|
+
key: "replaceMimes",
|
|
2414
|
+
value: function replaceMimes(message, attribute, rule, parameters) {
|
|
2415
|
+
return this.replaceMimetypes(message, attribute, rule, parameters);
|
|
2416
|
+
}
|
|
2417
|
+
}]);
|
|
2418
|
+
return Replacers;
|
|
2419
|
+
}();
|
|
2420
|
+
|
|
2421
|
+
var _data = /*#__PURE__*/new WeakMap();
|
|
2422
|
+
var _rules = /*#__PURE__*/new WeakMap();
|
|
2423
|
+
var _customMessages = /*#__PURE__*/new WeakMap();
|
|
2424
|
+
var _customAttributes = /*#__PURE__*/new WeakMap();
|
|
2425
|
+
var _customValues = /*#__PURE__*/new WeakMap();
|
|
2426
|
+
var _checkers = /*#__PURE__*/new WeakMap();
|
|
2427
|
+
var _replacers = /*#__PURE__*/new WeakMap();
|
|
2428
|
+
var _errors = /*#__PURE__*/new WeakMap();
|
|
2429
|
+
var _implicitAttributes = /*#__PURE__*/new WeakMap();
|
|
2430
|
+
var _stopOnFirstFailure = /*#__PURE__*/new WeakMap();
|
|
2431
|
+
var _alwaysBail = /*#__PURE__*/new WeakMap();
|
|
2432
|
+
var Validator = /*#__PURE__*/function () {
|
|
2433
|
+
function Validator() {
|
|
2434
|
+
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2435
|
+
var rules = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2436
|
+
var messages = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2437
|
+
var attributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2438
|
+
var values = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
2439
|
+
_classCallCheck(this, Validator);
|
|
2440
|
+
_classPrivateFieldInitSpec(this, _data, {
|
|
2441
|
+
writable: true,
|
|
2442
|
+
value: void 0
|
|
2443
|
+
});
|
|
2444
|
+
_classPrivateFieldInitSpec(this, _rules, {
|
|
2445
|
+
writable: true,
|
|
2446
|
+
value: void 0
|
|
2447
|
+
});
|
|
2448
|
+
_classPrivateFieldInitSpec(this, _customMessages, {
|
|
2449
|
+
writable: true,
|
|
2450
|
+
value: void 0
|
|
2451
|
+
});
|
|
2452
|
+
_classPrivateFieldInitSpec(this, _customAttributes, {
|
|
2453
|
+
writable: true,
|
|
2454
|
+
value: void 0
|
|
2455
|
+
});
|
|
2456
|
+
_classPrivateFieldInitSpec(this, _customValues, {
|
|
2457
|
+
writable: true,
|
|
2458
|
+
value: void 0
|
|
2459
|
+
});
|
|
2460
|
+
_classPrivateFieldInitSpec(this, _checkers, {
|
|
2461
|
+
writable: true,
|
|
2462
|
+
value: void 0
|
|
2463
|
+
});
|
|
2464
|
+
_classPrivateFieldInitSpec(this, _replacers, {
|
|
2465
|
+
writable: true,
|
|
2466
|
+
value: void 0
|
|
2467
|
+
});
|
|
2468
|
+
_classPrivateFieldInitSpec(this, _errors, {
|
|
2469
|
+
writable: true,
|
|
2470
|
+
value: void 0
|
|
2471
|
+
});
|
|
2472
|
+
_classPrivateFieldInitSpec(this, _implicitAttributes, {
|
|
2473
|
+
writable: true,
|
|
2474
|
+
value: {}
|
|
2475
|
+
});
|
|
2476
|
+
_classPrivateFieldInitSpec(this, _stopOnFirstFailure, {
|
|
2477
|
+
writable: true,
|
|
2478
|
+
value: false
|
|
2479
|
+
});
|
|
2480
|
+
_classPrivateFieldInitSpec(this, _alwaysBail, {
|
|
2481
|
+
writable: true,
|
|
2482
|
+
value: false
|
|
2483
|
+
});
|
|
2484
|
+
_defineProperty(this, "fileRules", ['file', 'image', 'mimetypes', 'mimes']);
|
|
2485
|
+
_defineProperty(this, "numericRules", ['decimal', 'numeric', 'integer']);
|
|
2486
|
+
_defineProperty(this, "sizeRules", ['size', 'between', 'min', 'max', 'gt', 'lt', 'gte', 'lte']);
|
|
2487
|
+
this.setProperties(data, rules, messages, attributes, values);
|
|
2488
|
+
_classPrivateFieldSet(this, _checkers, new Checkers(this));
|
|
2489
|
+
_classPrivateFieldSet(this, _replacers, new Replacers(this));
|
|
2490
|
+
for (var _i = 0, _Object$entries = Object.entries(_classStaticPrivateFieldSpecGet(Validator, Validator, _customCheckers)); _i < _Object$entries.length; _i++) {
|
|
2491
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
2492
|
+
rule = _Object$entries$_i[0],
|
|
2493
|
+
checker = _Object$entries$_i[1];
|
|
2494
|
+
_classPrivateFieldGet(this, _checkers)[toCamelCase('check_' + rule)] = checker;
|
|
2495
|
+
}
|
|
2496
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(_classStaticPrivateFieldSpecGet(Validator, Validator, _customReplacers)); _i2 < _Object$entries2.length; _i2++) {
|
|
2497
|
+
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
|
2498
|
+
_rule = _Object$entries2$_i[0],
|
|
2499
|
+
replacer = _Object$entries2$_i[1];
|
|
2500
|
+
_classPrivateFieldGet(this, _replacers)[toCamelCase('replace_' + _rule)] = replacer;
|
|
2501
|
+
}
|
|
2502
|
+
_classPrivateFieldSet(this, _errors, new ErrorBag());
|
|
2503
|
+
}
|
|
2504
|
+
_createClass(Validator, [{
|
|
2505
|
+
key: "setProperties",
|
|
2506
|
+
value: function setProperties() {
|
|
2507
|
+
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2508
|
+
var rules = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2509
|
+
var messages = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2510
|
+
var attributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2511
|
+
var values = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
2512
|
+
_classPrivateFieldSet(this, _data, data);
|
|
2513
|
+
_classPrivateFieldSet(this, _rules, this.parseRules(rules));
|
|
2514
|
+
_classPrivateFieldSet(this, _customMessages, messages);
|
|
2515
|
+
_classPrivateFieldSet(this, _customAttributes, attributes);
|
|
2516
|
+
_classPrivateFieldSet(this, _customValues, flattenObject(values));
|
|
2517
|
+
return this;
|
|
2518
|
+
}
|
|
2519
|
+
}, {
|
|
2520
|
+
key: "setData",
|
|
2521
|
+
value: function setData(data) {
|
|
2522
|
+
_classPrivateFieldSet(this, _data, data);
|
|
2523
|
+
return this;
|
|
2524
|
+
}
|
|
2525
|
+
}, {
|
|
2526
|
+
key: "setRules",
|
|
2527
|
+
value: function setRules(rules) {
|
|
2528
|
+
_classPrivateFieldSet(this, _rules, this.parseRules(rules));
|
|
2529
|
+
return this;
|
|
2530
|
+
}
|
|
2531
|
+
}, {
|
|
2532
|
+
key: "setCustomMessages",
|
|
2533
|
+
value: function setCustomMessages(messages) {
|
|
2534
|
+
_classPrivateFieldSet(this, _customMessages, messages);
|
|
2535
|
+
return this;
|
|
2536
|
+
}
|
|
2537
|
+
}, {
|
|
2538
|
+
key: "setCustomAttributes",
|
|
2539
|
+
value: function setCustomAttributes(attributes) {
|
|
2540
|
+
_classPrivateFieldSet(this, _customAttributes, attributes);
|
|
2541
|
+
return this;
|
|
2542
|
+
}
|
|
2543
|
+
}, {
|
|
2544
|
+
key: "setCustomValues",
|
|
2545
|
+
value: function setCustomValues(values) {
|
|
2546
|
+
_classPrivateFieldSet(this, _customValues, flattenObject(values));
|
|
2547
|
+
return this;
|
|
2548
|
+
}
|
|
2549
|
+
}, {
|
|
2550
|
+
key: "addImplicitAttribute",
|
|
2551
|
+
value: function addImplicitAttribute(implicitAttribute, attribute) {
|
|
2552
|
+
_classPrivateFieldGet(this, _implicitAttributes)[implicitAttribute] = attribute;
|
|
2553
|
+
return this;
|
|
2554
|
+
}
|
|
2555
|
+
}, {
|
|
2556
|
+
key: "stopOnFirstFailure",
|
|
2557
|
+
value: function stopOnFirstFailure() {
|
|
2558
|
+
var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
2559
|
+
_classPrivateFieldSet(this, _stopOnFirstFailure, flag);
|
|
2560
|
+
return this;
|
|
2561
|
+
}
|
|
2562
|
+
}, {
|
|
2563
|
+
key: "alwaysBail",
|
|
2564
|
+
value: function alwaysBail() {
|
|
2565
|
+
var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
2566
|
+
_classPrivateFieldSet(this, _alwaysBail, flag);
|
|
2567
|
+
return this;
|
|
2568
|
+
}
|
|
2569
|
+
}, {
|
|
2570
|
+
key: "parseRules",
|
|
2571
|
+
value: function parseRules(rules) {
|
|
2572
|
+
var parsedRules = {};
|
|
2573
|
+
var parseAttributeRules = function parseAttributeRules(rules) {
|
|
2574
|
+
if (Array.isArray(rules)) {
|
|
2575
|
+
return rules;
|
|
2576
|
+
} else {
|
|
2577
|
+
return String(rules).split('|');
|
|
2578
|
+
}
|
|
2579
|
+
};
|
|
2580
|
+
for (var _i3 = 0, _Object$entries3 = Object.entries(rules); _i3 < _Object$entries3.length; _i3++) {
|
|
2581
|
+
var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
|
|
2582
|
+
attribute = _Object$entries3$_i[0],
|
|
2583
|
+
attributeRules = _Object$entries3$_i[1];
|
|
2584
|
+
var attributes = attribute.includes('*') ? this.parseWildcardAttribute(attribute) : [attribute];
|
|
2585
|
+
var _iterator = _createForOfIteratorHelper(attributes),
|
|
2586
|
+
_step;
|
|
2587
|
+
try {
|
|
2588
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2589
|
+
var _attribute = _step.value;
|
|
2590
|
+
var parsedAttributeRules = {};
|
|
2591
|
+
var _iterator2 = _createForOfIteratorHelper(parseAttributeRules(attributeRules)),
|
|
2592
|
+
_step2;
|
|
2593
|
+
try {
|
|
2594
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2595
|
+
var attributeRule = _step2.value;
|
|
2596
|
+
var parts = attributeRule.split(':');
|
|
2597
|
+
var rule = parts[0];
|
|
2598
|
+
var parameters = parts.slice(1).join(':').split(',').filter(function (part) {
|
|
2599
|
+
return part !== '';
|
|
2600
|
+
});
|
|
2601
|
+
parsedAttributeRules[rule] = parameters;
|
|
2602
|
+
}
|
|
2603
|
+
} catch (err) {
|
|
2604
|
+
_iterator2.e(err);
|
|
2605
|
+
} finally {
|
|
2606
|
+
_iterator2.f();
|
|
2607
|
+
}
|
|
2608
|
+
parsedRules[_attribute] = parsedAttributeRules;
|
|
2609
|
+
}
|
|
2610
|
+
} catch (err) {
|
|
2611
|
+
_iterator.e(err);
|
|
2612
|
+
} finally {
|
|
2613
|
+
_iterator.f();
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
2616
|
+
return parsedRules;
|
|
2617
|
+
}
|
|
2618
|
+
}, {
|
|
2619
|
+
key: "parseWildcardAttribute",
|
|
2620
|
+
value: function parseWildcardAttribute(attribute) {
|
|
2621
|
+
var _this = this;
|
|
2622
|
+
var attributes = [];
|
|
2623
|
+
var index = attribute.indexOf('*');
|
|
2624
|
+
var parentPath = attribute.substring(0, index - 1);
|
|
2625
|
+
var childPath = attribute.substring(index + 2);
|
|
2626
|
+
var data = this.getValue(parentPath);
|
|
2627
|
+
if (!(Array.isArray(data) || isPlainObject(data))) {
|
|
2628
|
+
return [attribute];
|
|
2629
|
+
}
|
|
2630
|
+
Object.entries(data).forEach(function (_ref) {
|
|
2631
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
2632
|
+
key = _ref2[0];
|
|
2633
|
+
_ref2[1];
|
|
2634
|
+
var implicitAttribute = "".concat(parentPath, ".").concat(key, ".").concat(childPath).replace(/\.$/, '');
|
|
2635
|
+
var implicitAttributes = implicitAttribute.includes('*') ? _this.parseWildcardAttribute(implicitAttribute) : [implicitAttribute];
|
|
2636
|
+
attributes.push.apply(attributes, _toConsumableArray(implicitAttributes));
|
|
2637
|
+
implicitAttributes.forEach(function (value) {
|
|
2638
|
+
return _classPrivateFieldGet(_this, _implicitAttributes)[value] = attribute;
|
|
2639
|
+
});
|
|
2640
|
+
});
|
|
2641
|
+
return attributes;
|
|
2642
|
+
}
|
|
2643
|
+
}, {
|
|
2644
|
+
key: "validate",
|
|
2645
|
+
value: function () {
|
|
2646
|
+
var _validate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
2647
|
+
var _i4, _Object$entries4, _Object$entries4$_i, attribute, rules, value, doBail, isNullable, hasError, _i5, _Object$entries5, _Object$entries5$_i, rule, parameters, result, status, message, camelRule, _result;
|
|
2648
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2649
|
+
while (1) switch (_context.prev = _context.next) {
|
|
2650
|
+
case 0:
|
|
2651
|
+
_classPrivateFieldGet(this, _checkers).clearCaches();
|
|
2652
|
+
_classPrivateFieldSet(this, _errors, new ErrorBag());
|
|
2653
|
+
_i4 = 0, _Object$entries4 = Object.entries(_classPrivateFieldGet(this, _rules));
|
|
2654
|
+
case 3:
|
|
2655
|
+
if (!(_i4 < _Object$entries4.length)) {
|
|
2656
|
+
_context.next = 45;
|
|
2657
|
+
break;
|
|
2658
|
+
}
|
|
2659
|
+
_Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2), attribute = _Object$entries4$_i[0], rules = _Object$entries4$_i[1];
|
|
2660
|
+
value = this.getValue(attribute);
|
|
2661
|
+
if (!(rules.hasOwnProperty('sometimes') && typeof value === 'undefined')) {
|
|
2662
|
+
_context.next = 8;
|
|
2663
|
+
break;
|
|
2664
|
+
}
|
|
2665
|
+
return _context.abrupt("continue", 42);
|
|
2666
|
+
case 8:
|
|
2667
|
+
doBail = _classPrivateFieldGet(this, _alwaysBail) || rules.hasOwnProperty('bail');
|
|
2668
|
+
isNullable = rules.hasOwnProperty('nullable');
|
|
2669
|
+
hasError = false;
|
|
2670
|
+
_i5 = 0, _Object$entries5 = Object.entries(rules);
|
|
2671
|
+
case 12:
|
|
2672
|
+
if (!(_i5 < _Object$entries5.length)) {
|
|
2673
|
+
_context.next = 40;
|
|
2674
|
+
break;
|
|
2675
|
+
}
|
|
2676
|
+
_Object$entries5$_i = _slicedToArray(_Object$entries5[_i5], 2), rule = _Object$entries5$_i[0], parameters = _Object$entries5$_i[1];
|
|
2677
|
+
if (!(!_classStaticPrivateFieldSpecGet(Validator, Validator, _implicitRules).includes(rule) && (typeof value == 'undefined' || typeof value === 'string' && value.trim() === '' || isNullable && value === null))) {
|
|
2678
|
+
_context.next = 16;
|
|
2679
|
+
break;
|
|
2680
|
+
}
|
|
2681
|
+
return _context.abrupt("break", 40);
|
|
2682
|
+
case 16:
|
|
2683
|
+
result = void 0, status = void 0, message = void 0;
|
|
2684
|
+
camelRule = toCamelCase('check_' + rule);
|
|
2685
|
+
if (!(typeof _classPrivateFieldGet(this, _checkers)[camelRule] === 'function')) {
|
|
2686
|
+
_context.next = 24;
|
|
2687
|
+
break;
|
|
2688
|
+
}
|
|
2689
|
+
_context.next = 21;
|
|
2690
|
+
return _classPrivateFieldGet(this, _checkers)[camelRule](attribute, value, parameters);
|
|
2691
|
+
case 21:
|
|
2692
|
+
result = _context.sent;
|
|
2693
|
+
_context.next = 29;
|
|
2694
|
+
break;
|
|
2695
|
+
case 24:
|
|
2696
|
+
if (!_classStaticPrivateFieldSpecGet(Validator, Validator, _dummyRules).includes(rule)) {
|
|
2697
|
+
_context.next = 28;
|
|
2698
|
+
break;
|
|
2699
|
+
}
|
|
2700
|
+
result = true;
|
|
2701
|
+
_context.next = 29;
|
|
2702
|
+
break;
|
|
2703
|
+
case 28:
|
|
2704
|
+
throw new Error("Invalid validation rule: ".concat(rule));
|
|
2705
|
+
case 29:
|
|
2706
|
+
if (typeof result === 'boolean') {
|
|
2707
|
+
status = result;
|
|
2708
|
+
} else {
|
|
2709
|
+
_result = result;
|
|
2710
|
+
status = _result.status;
|
|
2711
|
+
message = _result.message;
|
|
2712
|
+
}
|
|
2713
|
+
if (status) {
|
|
2714
|
+
_context.next = 37;
|
|
2715
|
+
break;
|
|
2716
|
+
}
|
|
2717
|
+
hasError = true;
|
|
2718
|
+
message = isEmpty(message) ? this.getMessage(attribute, rule) : message;
|
|
2719
|
+
message = this.makeReplacements(message, attribute, rule, parameters);
|
|
2720
|
+
_classPrivateFieldGet(this, _errors).add(attribute, message);
|
|
2721
|
+
if (!(doBail || _classStaticPrivateFieldSpecGet(Validator, Validator, _implicitRules).includes(rule))) {
|
|
2722
|
+
_context.next = 37;
|
|
2723
|
+
break;
|
|
2724
|
+
}
|
|
2725
|
+
return _context.abrupt("break", 40);
|
|
2726
|
+
case 37:
|
|
2727
|
+
_i5++;
|
|
2728
|
+
_context.next = 12;
|
|
2729
|
+
break;
|
|
2730
|
+
case 40:
|
|
2731
|
+
if (!(_classPrivateFieldGet(this, _stopOnFirstFailure) && hasError)) {
|
|
2732
|
+
_context.next = 42;
|
|
2733
|
+
break;
|
|
2734
|
+
}
|
|
2735
|
+
return _context.abrupt("break", 45);
|
|
2736
|
+
case 42:
|
|
2737
|
+
_i4++;
|
|
2738
|
+
_context.next = 3;
|
|
2739
|
+
break;
|
|
2740
|
+
case 45:
|
|
2741
|
+
if (!_classPrivateFieldGet(this, _errors).isNotEmpty()) {
|
|
2742
|
+
_context.next = 47;
|
|
2743
|
+
break;
|
|
2744
|
+
}
|
|
2745
|
+
throw _classPrivateFieldGet(this, _errors);
|
|
2746
|
+
case 47:
|
|
2747
|
+
case "end":
|
|
2748
|
+
return _context.stop();
|
|
2749
|
+
}
|
|
2750
|
+
}, _callee, this);
|
|
2751
|
+
}));
|
|
2752
|
+
function validate() {
|
|
2753
|
+
return _validate.apply(this, arguments);
|
|
2754
|
+
}
|
|
2755
|
+
return validate;
|
|
2756
|
+
}()
|
|
2757
|
+
}, {
|
|
2758
|
+
key: "passes",
|
|
2759
|
+
value: function () {
|
|
2760
|
+
var _passes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
2761
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
2762
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
2763
|
+
case 0:
|
|
2764
|
+
_context2.prev = 0;
|
|
2765
|
+
_context2.next = 3;
|
|
2766
|
+
return this.validate();
|
|
2767
|
+
case 3:
|
|
2768
|
+
_context2.next = 10;
|
|
2769
|
+
break;
|
|
2770
|
+
case 5:
|
|
2771
|
+
_context2.prev = 5;
|
|
2772
|
+
_context2.t0 = _context2["catch"](0);
|
|
2773
|
+
if (!(_context2.t0 instanceof Error)) {
|
|
2774
|
+
_context2.next = 9;
|
|
2775
|
+
break;
|
|
2776
|
+
}
|
|
2777
|
+
throw _context2.t0;
|
|
2778
|
+
case 9:
|
|
2779
|
+
return _context2.abrupt("return", false);
|
|
2780
|
+
case 10:
|
|
2781
|
+
return _context2.abrupt("return", true);
|
|
2782
|
+
case 11:
|
|
2783
|
+
case "end":
|
|
2784
|
+
return _context2.stop();
|
|
2785
|
+
}
|
|
2786
|
+
}, _callee2, this, [[0, 5]]);
|
|
2787
|
+
}));
|
|
2788
|
+
function passes() {
|
|
2789
|
+
return _passes.apply(this, arguments);
|
|
2790
|
+
}
|
|
2791
|
+
return passes;
|
|
2792
|
+
}()
|
|
2793
|
+
}, {
|
|
2794
|
+
key: "fails",
|
|
2795
|
+
value: function () {
|
|
2796
|
+
var _fails = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
2797
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
2798
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
2799
|
+
case 0:
|
|
2800
|
+
_context3.next = 2;
|
|
2801
|
+
return this.passes();
|
|
2802
|
+
case 2:
|
|
2803
|
+
return _context3.abrupt("return", !_context3.sent);
|
|
2804
|
+
case 3:
|
|
2805
|
+
case "end":
|
|
2806
|
+
return _context3.stop();
|
|
2807
|
+
}
|
|
2808
|
+
}, _callee3, this);
|
|
2809
|
+
}));
|
|
2810
|
+
function fails() {
|
|
2811
|
+
return _fails.apply(this, arguments);
|
|
2812
|
+
}
|
|
2813
|
+
return fails;
|
|
2814
|
+
}()
|
|
2815
|
+
}, {
|
|
2816
|
+
key: "getMessage",
|
|
2817
|
+
value: function getMessage(attribute, rule) {
|
|
2818
|
+
var _message;
|
|
2819
|
+
var value = this.getValue(attribute);
|
|
2820
|
+
attribute = this.getPrimaryAttribute(attribute);
|
|
2821
|
+
var message;
|
|
2822
|
+
for (var _i6 = 0, _arr = ["".concat(attribute, ".").concat(rule), rule]; _i6 < _arr.length; _i6++) {
|
|
2823
|
+
var key = _arr[_i6];
|
|
2824
|
+
if (_classPrivateFieldGet(this, _customMessages).hasOwnProperty(key)) {
|
|
2825
|
+
message = _classPrivateFieldGet(this, _customMessages)[key];
|
|
2826
|
+
break;
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
if (!message) {
|
|
2830
|
+
var _key = rule;
|
|
2831
|
+
if (this.sizeRules.includes(_key)) {
|
|
2832
|
+
if (Array.isArray(value) || isPlainObject(value) || this.hasRule(attribute, 'array')) {
|
|
2833
|
+
_key += '.array';
|
|
2834
|
+
} else if (value instanceof File || this.hasRule(attribute, this.fileRules)) {
|
|
2835
|
+
_key += '.file';
|
|
2836
|
+
} else if (typeof value === 'number' || this.hasRule(attribute, this.numericRules)) {
|
|
2837
|
+
_key += '.numeric';
|
|
2838
|
+
} else {
|
|
2839
|
+
_key += '.string';
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
message = Lang.get(_key);
|
|
2843
|
+
}
|
|
2844
|
+
return (_message = message) !== null && _message !== void 0 ? _message : "validation.".concat(rule);
|
|
2845
|
+
}
|
|
2846
|
+
}, {
|
|
2847
|
+
key: "makeReplacements",
|
|
2848
|
+
value: function makeReplacements(message, attribute, rule, parameters) {
|
|
2849
|
+
var attributeName = this.getDisplayableAttribute(attribute);
|
|
2850
|
+
var value = this.getValue(attribute);
|
|
2851
|
+
var data = {
|
|
2852
|
+
attribute: attributeName,
|
|
2853
|
+
ATTRIBUTE: attributeName.toLocaleUpperCase(),
|
|
2854
|
+
Attribute: attributeName.charAt(0).toLocaleUpperCase() + attributeName.substring(1),
|
|
2855
|
+
input: this.getDisplayableValue(attribute, value)
|
|
2856
|
+
};
|
|
2857
|
+
for (var _i7 = 0, _Object$entries6 = Object.entries(data); _i7 < _Object$entries6.length; _i7++) {
|
|
2858
|
+
var _Object$entries6$_i = _slicedToArray(_Object$entries6[_i7], 2),
|
|
2859
|
+
key = _Object$entries6$_i[0],
|
|
2860
|
+
_value = _Object$entries6$_i[1];
|
|
2861
|
+
message = message.replaceAll(':' + key, _value);
|
|
2862
|
+
}
|
|
2863
|
+
var match = attribute.match(/\.(\d+)\.?/);
|
|
2864
|
+
var index = match === null ? -1 : parseInt(match[1], 10);
|
|
2865
|
+
if (index !== -1) {
|
|
2866
|
+
message = message.replaceAll(':index', index).replaceAll(':position', index + 1);
|
|
2867
|
+
}
|
|
2868
|
+
var camelRule = toCamelCase('replace_' + rule);
|
|
2869
|
+
if (typeof _classPrivateFieldGet(this, _replacers)[camelRule] === 'function') {
|
|
2870
|
+
message = _classPrivateFieldGet(this, _replacers)[camelRule](message, attribute, rule, parameters);
|
|
2871
|
+
}
|
|
2872
|
+
return message;
|
|
2873
|
+
}
|
|
2874
|
+
}, {
|
|
2875
|
+
key: "getDisplayableAttribute",
|
|
2876
|
+
value: function getDisplayableAttribute(attribute) {
|
|
2877
|
+
var unparsed = this.getPrimaryAttribute(attribute);
|
|
2878
|
+
for (var _i8 = 0, _arr2 = [attribute, unparsed]; _i8 < _arr2.length; _i8++) {
|
|
2879
|
+
var name = _arr2[_i8];
|
|
2880
|
+
if (_classPrivateFieldGet(this, _customAttributes).hasOwnProperty(name)) {
|
|
2881
|
+
return _classPrivateFieldGet(this, _customAttributes)[name];
|
|
2882
|
+
} else if (Lang.has("attributes.".concat(name))) {
|
|
2883
|
+
return Lang.get("attributes.".concat(name));
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
if (_classPrivateFieldGet(this, _implicitAttributes).hasOwnProperty(attribute)) {
|
|
2887
|
+
return attribute;
|
|
2888
|
+
}
|
|
2889
|
+
return toSnakeCase(attribute).replaceAll('_', ' ');
|
|
2890
|
+
}
|
|
2891
|
+
}, {
|
|
2892
|
+
key: "getDisplayableValue",
|
|
2893
|
+
value: function getDisplayableValue(attribute, value) {
|
|
2894
|
+
attribute = this.getPrimaryAttribute(attribute);
|
|
2895
|
+
var path = "".concat(attribute, ".").concat(value);
|
|
2896
|
+
if (isEmpty(value)) {
|
|
2897
|
+
return 'empty';
|
|
2898
|
+
} else if (typeof value === 'boolean' || this.hasRule(attribute, 'boolean')) {
|
|
2899
|
+
return Number(value) ? 'true' : 'false';
|
|
2900
|
+
} else if (_classPrivateFieldGet(this, _customValues).hasOwnProperty(path)) {
|
|
2901
|
+
return _classPrivateFieldGet(this, _customValues)[path];
|
|
2902
|
+
} else if (Lang.has("values.".concat(path))) {
|
|
2903
|
+
return Lang.get("values.".concat(path));
|
|
2904
|
+
}
|
|
2905
|
+
return value;
|
|
2906
|
+
}
|
|
2907
|
+
}, {
|
|
2908
|
+
key: "getSize",
|
|
2909
|
+
value: function getSize(attribute, value) {
|
|
2910
|
+
if (isEmpty(value)) {
|
|
2911
|
+
return 0;
|
|
2912
|
+
} else if (isNumeric(value) && this.hasRule(attribute, this.numericRules)) {
|
|
2913
|
+
return parseFloat(typeof value === 'string' ? value.trim() : value, 10);
|
|
2914
|
+
} else if (value instanceof File) {
|
|
2915
|
+
return value.size / 1024;
|
|
2916
|
+
} else if (isPlainObject(value)) {
|
|
2917
|
+
return Object.keys(value).length;
|
|
2918
|
+
} else if (value.hasOwnProperty('length')) {
|
|
2919
|
+
return value.length;
|
|
2920
|
+
}
|
|
2921
|
+
return value;
|
|
2922
|
+
}
|
|
2923
|
+
}, {
|
|
2924
|
+
key: "getRule",
|
|
2925
|
+
value: function getRule(attribute) {
|
|
2926
|
+
var _classPrivateFieldGet2;
|
|
2927
|
+
attribute = this.getPrimaryAttribute(attribute);
|
|
2928
|
+
return (_classPrivateFieldGet2 = _classPrivateFieldGet(this, _rules)[attribute]) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : {};
|
|
2929
|
+
}
|
|
2930
|
+
}, {
|
|
2931
|
+
key: "hasRule",
|
|
2932
|
+
value: function hasRule(attribute, rules) {
|
|
2933
|
+
attribute = this.getPrimaryAttribute(attribute);
|
|
2934
|
+
rules = typeof rules === 'string' ? [rules] : rules;
|
|
2935
|
+
if (!_classPrivateFieldGet(this, _rules).hasOwnProperty(attribute)) {
|
|
2936
|
+
return false;
|
|
2937
|
+
}
|
|
2938
|
+
var _iterator3 = _createForOfIteratorHelper(rules),
|
|
2939
|
+
_step3;
|
|
2940
|
+
try {
|
|
2941
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
2942
|
+
var rule = _step3.value;
|
|
2943
|
+
if (_classPrivateFieldGet(this, _rules)[attribute].hasOwnProperty(rule)) {
|
|
2944
|
+
return true;
|
|
2945
|
+
}
|
|
2946
|
+
}
|
|
2947
|
+
} catch (err) {
|
|
2948
|
+
_iterator3.e(err);
|
|
2949
|
+
} finally {
|
|
2950
|
+
_iterator3.f();
|
|
2951
|
+
}
|
|
2952
|
+
return false;
|
|
2953
|
+
}
|
|
2954
|
+
}, {
|
|
2955
|
+
key: "getPrimaryAttribute",
|
|
2956
|
+
value: function getPrimaryAttribute(attribute) {
|
|
2957
|
+
return _classPrivateFieldGet(this, _implicitAttributes).hasOwnProperty(attribute) ? _classPrivateFieldGet(this, _implicitAttributes)[attribute] : attribute;
|
|
2958
|
+
}
|
|
2959
|
+
}, {
|
|
2960
|
+
key: "hasAttribute",
|
|
2961
|
+
value: function hasAttribute(attribute) {
|
|
2962
|
+
return typeof this.getValue(attribute) !== 'undefined';
|
|
2963
|
+
}
|
|
2964
|
+
}, {
|
|
2965
|
+
key: "getValue",
|
|
2966
|
+
value: function getValue(attribute) {
|
|
2967
|
+
return getByPath(_classPrivateFieldGet(this, _data), attribute);
|
|
2968
|
+
}
|
|
2969
|
+
}, {
|
|
2970
|
+
key: "errors",
|
|
2971
|
+
value: function errors() {
|
|
2972
|
+
return _classPrivateFieldGet(this, _errors);
|
|
2973
|
+
}
|
|
2974
|
+
}], [{
|
|
2975
|
+
key: "setLocale",
|
|
2976
|
+
value: function setLocale(locale) {
|
|
2977
|
+
Lang.locale(locale);
|
|
2978
|
+
}
|
|
2979
|
+
}, {
|
|
2980
|
+
key: "setMessages",
|
|
2981
|
+
value: function setMessages(locale, messages) {
|
|
2982
|
+
Lang.setMessages(locale, messages);
|
|
2983
|
+
}
|
|
2984
|
+
}, {
|
|
2985
|
+
key: "addChecker",
|
|
2986
|
+
value: function addChecker(rule, method, message) {
|
|
2987
|
+
_classStaticPrivateFieldSpecGet(Validator, Validator, _customCheckers)[rule] = method;
|
|
2988
|
+
if (message) {
|
|
2989
|
+
Lang.set(rule, message);
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2992
|
+
}, {
|
|
2993
|
+
key: "addImplicitChecker",
|
|
2994
|
+
value: function addImplicitChecker(rule, method, message) {
|
|
2995
|
+
Validator.addChecker(rule, method, message);
|
|
2996
|
+
_classStaticPrivateFieldSpecGet(Validator, Validator, _implicitRules).push(rule);
|
|
2997
|
+
}
|
|
2998
|
+
}, {
|
|
2999
|
+
key: "addReplacer",
|
|
3000
|
+
value: function addReplacer(rule, method) {
|
|
3001
|
+
_classStaticPrivateFieldSpecGet(Validator, Validator, _customReplacers)[rule] = method;
|
|
3002
|
+
}
|
|
3003
|
+
}, {
|
|
3004
|
+
key: "addDummyRule",
|
|
3005
|
+
value: function addDummyRule(rule) {
|
|
3006
|
+
_classStaticPrivateFieldSpecGet(Validator, Validator, _dummyRules).push(rule);
|
|
3007
|
+
}
|
|
3008
|
+
}]);
|
|
3009
|
+
return Validator;
|
|
3010
|
+
}();
|
|
3011
|
+
var _customCheckers = {
|
|
3012
|
+
writable: true,
|
|
3013
|
+
value: {}
|
|
3014
|
+
};
|
|
3015
|
+
var _customReplacers = {
|
|
3016
|
+
writable: true,
|
|
3017
|
+
value: {}
|
|
3018
|
+
};
|
|
3019
|
+
var _dummyRules = {
|
|
3020
|
+
writable: true,
|
|
3021
|
+
value: ['active_url', 'bail', 'current_password', 'enum', 'exclude', 'exclude_if', 'exclude_unless', 'exclude_with', 'exclude_without', 'exists', 'nullable', 'sometimes', 'unique']
|
|
3022
|
+
};
|
|
3023
|
+
var _implicitRules = {
|
|
3024
|
+
writable: true,
|
|
3025
|
+
value: ['accepted', 'accepted_if', 'declined', 'declined_if', 'filled', 'missing', 'missing_if', 'missing_unless', 'missing_with', 'missing_with_all', 'present', 'required', 'required_if', 'required_if_accepted', 'required_unless', 'required_with', 'required_with_all', 'required_without', 'required_without_all']
|
|
3026
|
+
};
|
|
3027
|
+
|
|
3028
|
+
exports.Checkers = Checkers;
|
|
3029
|
+
exports.ErrorBag = ErrorBag;
|
|
3030
|
+
exports.Lang = Lang;
|
|
3031
|
+
exports.Replacers = Replacers;
|
|
3032
|
+
exports.Validator = Validator;
|
|
3033
|
+
|
|
3034
|
+
return exports;
|
|
3035
|
+
|
|
3036
|
+
})({});
|