kanun 1.1.0 → 1.2.0
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 +7 -7
- package/dist/index.cjs +456 -294
- package/dist/index.d.ts +517 -510
- package/dist/index.js +443 -280
- package/package.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -7,16 +7,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
20
16
|
}
|
|
21
17
|
return to;
|
|
22
18
|
};
|
|
@@ -24,16 +20,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
20
|
value: mod,
|
|
25
21
|
enumerable: true
|
|
26
22
|
}) : target, mod));
|
|
27
|
-
|
|
28
23
|
//#endregion
|
|
29
24
|
let node_async_hooks = require("node:async_hooks");
|
|
30
25
|
let node_url = require("node:url");
|
|
31
26
|
let node_net = require("node:net");
|
|
32
27
|
let dayjs_plugin_customParseFormat_js = require("dayjs/plugin/customParseFormat.js");
|
|
33
|
-
dayjs_plugin_customParseFormat_js = __toESM(dayjs_plugin_customParseFormat_js);
|
|
28
|
+
dayjs_plugin_customParseFormat_js = __toESM(dayjs_plugin_customParseFormat_js, 1);
|
|
34
29
|
let dayjs = require("dayjs");
|
|
35
|
-
dayjs = __toESM(dayjs);
|
|
36
|
-
|
|
30
|
+
dayjs = __toESM(dayjs, 1);
|
|
37
31
|
//#region src/Context.ts
|
|
38
32
|
const validatorContextStorage = new node_async_hooks.AsyncLocalStorage();
|
|
39
33
|
/**
|
|
@@ -72,255 +66,244 @@ function runWithValidatorContext(context, callback) {
|
|
|
72
66
|
...context
|
|
73
67
|
}, callback);
|
|
74
68
|
}
|
|
75
|
-
|
|
76
69
|
//#endregion
|
|
77
70
|
//#region src/Rules/baseRule.ts
|
|
78
71
|
var BaseRule = class {};
|
|
79
|
-
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/locales/en.ts
|
|
82
|
-
var en_default = {
|
|
83
|
-
accepted: "The :attribute must be accepted.",
|
|
84
|
-
accepted_if: "The :attribute must be accepted when :other is :value.",
|
|
85
|
-
after: "The :attribute must be a date after :date.",
|
|
86
|
-
after_or_equal: "The :attribute must be a date after or equal to :date.",
|
|
87
|
-
alpha: "The :attribute must only contain letters.",
|
|
88
|
-
alpha_dash: "The :attribute must only contain at least one letter or one number, and optionally dashes and underscores.",
|
|
89
|
-
alpha_num: "The :attribute must only contain letters and numbers.",
|
|
90
|
-
array: "The :attribute must be an array.",
|
|
91
|
-
array_unique: "The :attribute must be an array with unique values.",
|
|
92
|
-
before: "The :attribute must be a date before :date.",
|
|
93
|
-
before_or_equal: "The :attribute must be a date before or equal to :date.",
|
|
94
|
-
between: {
|
|
95
|
-
number: "The :attribute must be between :min and :max.",
|
|
96
|
-
string: "The :attribute must be between :min and :max characters.",
|
|
97
|
-
array: "The :attribute must have between :min and :max items.",
|
|
98
|
-
object: "The :attribute must have between :min and :max items."
|
|
99
|
-
},
|
|
100
|
-
boolean: "The :attribute field must be true or false.",
|
|
101
|
-
confirmed: "The :attribute confirmation does not match.",
|
|
102
|
-
date: "The :attribute is not a valid date.",
|
|
103
|
-
datetime: "The :attribute must be a valid date matching the format :format.",
|
|
104
|
-
date_equals: "The :attribute must be a date equal to :date.",
|
|
105
|
-
declined: "The :attribute must be declined.",
|
|
106
|
-
declined_if: "The :attribute must be declined when :other is :value.",
|
|
107
|
-
different: "The :attribute and :other must be different.",
|
|
108
|
-
distinct: "The :attribute field has a duplicate value.",
|
|
109
|
-
digits: "The :attribute must be :digits digits.",
|
|
110
|
-
digits_between: "The :attribute must be between :min and :max digits.",
|
|
111
|
-
email: "The :attribute must be a valid email address.",
|
|
112
|
-
ends_with: "The :attribute must end with one of the following: :values.",
|
|
113
|
-
filled: "The :attribute field must have a value.",
|
|
114
|
-
exists: "The selected :attribute is invalid.",
|
|
115
|
-
gt: {
|
|
116
|
-
number: "The :attribute must be greater than :value.",
|
|
117
|
-
string: "The :attribute must be greater than :value characters.",
|
|
118
|
-
array: "The :attribute must have more than :value items.",
|
|
119
|
-
object: "The :attribute must have more than :value items."
|
|
120
|
-
},
|
|
121
|
-
gte: {
|
|
122
|
-
number: "The :attribute must be greater than or equal :value.",
|
|
123
|
-
string: "The :attribute must be greater than or equal :value characters.",
|
|
124
|
-
array: "The :attribute must have :value items or more.",
|
|
125
|
-
object: "The :attribute must have :value items or more."
|
|
126
|
-
},
|
|
127
|
-
hex: "The :attribute must be a valid hexadecimal color.",
|
|
128
|
-
in: "The :attribute must be one of the following :values.",
|
|
129
|
-
includes: "The :attribute must include one of the following values: :values.",
|
|
130
|
-
integer: "The :attribute must be an integer.",
|
|
131
|
-
ip: "The :attribute must be a valid IP address.",
|
|
132
|
-
ipv4: "The :attribute must be a valid IPv4 address.",
|
|
133
|
-
ipv6: "The :attribute must be a valid IPv6 address.",
|
|
134
|
-
json: "The :attribute must be a valid JSON string.",
|
|
135
|
-
lt: {
|
|
136
|
-
number: "The :attribute must be less than :value.",
|
|
137
|
-
string: "The :attribute must be less than :value characters.",
|
|
138
|
-
array: "The :attribute must have less than :value items.",
|
|
139
|
-
object: "The :attribute must have less than :value items."
|
|
140
|
-
},
|
|
141
|
-
lte: {
|
|
142
|
-
number: "The :attribute must be less than or equal :value.",
|
|
143
|
-
string: "The :attribute must be less than or equal :value characters.",
|
|
144
|
-
array: "The :attribute must have :value items or less.",
|
|
145
|
-
object: "The :attribute must have :value items or less."
|
|
146
|
-
},
|
|
147
|
-
max: {
|
|
148
|
-
number: "The :attribute must not be greater than :max.",
|
|
149
|
-
string: "The :attribute must not be greater than :max characters.",
|
|
150
|
-
array: "The :attribute must not have more than :max items.",
|
|
151
|
-
object: "The :attribute must not have more than :max items."
|
|
152
|
-
},
|
|
153
|
-
min: {
|
|
154
|
-
number: "The :attribute must be at least :min.",
|
|
155
|
-
string: "The :attribute must be at least :min characters.",
|
|
156
|
-
array: "The :attribute must have at least :min items.",
|
|
157
|
-
object: "The :attribute must have at least :min items."
|
|
158
|
-
},
|
|
159
|
-
mac_address: "The :attribute must be a valid MAC address.",
|
|
160
|
-
not_in: "The selected :attribute is invalid.",
|
|
161
|
-
not_regex: "The :attribute format is invalid.",
|
|
162
|
-
not_includes: "The :attribute must not include any of the following values: :values.",
|
|
163
|
-
numeric: "The :attribute must be a number.",
|
|
164
|
-
object: "The :attribute must be an object.",
|
|
165
|
-
password: {
|
|
166
|
-
letter: "The :attribute must contain at least one letter.",
|
|
167
|
-
letters: "The :attribute must contain at least :amount letters.",
|
|
168
|
-
lower_case: "The :attribute must contain at least one lowercase letter.",
|
|
169
|
-
lower_cases: "The :attribute must contain at least :amount lowercase letters.",
|
|
170
|
-
number: "The :attribute must contain at least one number.",
|
|
171
|
-
numbers: "The :attribute must contain at least :amount numbers.",
|
|
172
|
-
symbol: "The :attribute must contain at least one symbol.",
|
|
173
|
-
symbols: "The :attribute must contain at least :amount symbols.",
|
|
174
|
-
upper_case: "The :attribute must contain at least one uppercase letter.",
|
|
175
|
-
upper_cases: "The :attribute must contain at least :amount uppercase letters."
|
|
176
|
-
},
|
|
177
|
-
present: "The :attribute field must be present.",
|
|
178
|
-
presentsame: "The :attribute field must be present.",
|
|
179
|
-
prohibited: "The :attribute field is prohibited.",
|
|
180
|
-
prohibited_unless: "The :attribute field is prohibited unless :other is in :values.",
|
|
181
|
-
prohibits: "The :attribute field prohibits :values from being present.",
|
|
182
|
-
regex: "The :attribute format is invalid.",
|
|
183
|
-
required: "The :attribute field is required.",
|
|
184
|
-
required_if: "The :attribute field is required when :other is :value.",
|
|
185
|
-
required_unless: "The :attribute field is required unless :other is in :values.",
|
|
186
|
-
required_with: "The :attribute field is required when :values is present.",
|
|
187
|
-
required_with_all: "The :attribute field is required when :values are present.",
|
|
188
|
-
required_without: "The :attribute field is required when :values is not present.",
|
|
189
|
-
required_without_all: "The :attribute field is required when none of :values are present.",
|
|
190
|
-
starts_with: "The :attribute must start with one of the following: :values.",
|
|
191
|
-
same: "The :attribute and :other must match.",
|
|
192
|
-
size: {
|
|
193
|
-
number: "The :attribute must be :size.",
|
|
194
|
-
string: "The :attribute must be :size characters.",
|
|
195
|
-
array: "The :attribute must contain :size items.",
|
|
196
|
-
object: "The :attribute must contain :size items."
|
|
197
|
-
},
|
|
198
|
-
string: "The :attribute must be a string.",
|
|
199
|
-
timezone: "The :attribute must be a valid timezone.",
|
|
200
|
-
unique: "The :attribute has already been taken.",
|
|
201
|
-
url: "The :attribute must have a valid URL format.",
|
|
202
|
-
multiple_of: "The :attribute must be a multiple of :value."
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
//#endregion
|
|
206
|
-
//#region src/locales/ar.ts
|
|
207
|
-
var ar_default = {
|
|
208
|
-
accepted: "يجب قبول الحقل :attribute",
|
|
209
|
-
accepted_if: "الحقل :attribute مقبول في حال ما إذا كان :other يساوي :value.",
|
|
210
|
-
after: "يجب على الحقل :attribute أن يكون تاريخا لاحقا للتاريخ :date.",
|
|
211
|
-
after_or_equal: "الحقل :attribute يجب أن يكون تاريخاً لاحقاً أو مطابقاً للتاريخ :date.",
|
|
212
|
-
alpha: "يجب أن لا يحتوي الحقل :attribute سوى على حروف",
|
|
213
|
-
alpha_dash: "يجب أن يحتوي الحقل :attribute على حرف واحد أو رقم واحد على الأقل، بالإضافة إلى شرطات وشرطات سفلية بشكل اختياري",
|
|
214
|
-
alpha_num: "يجب أن يحتوي :attribute على حروف وأرقام فقط",
|
|
215
|
-
array: "يجب أن يكون الحقل :attribute ًمصفوفة",
|
|
216
|
-
before: "يجب على الحقل :attribute أن يكون تاريخا سابقا للتاريخ :date.",
|
|
217
|
-
before_or_equal: "الحقل :attribute يجب أن يكون تاريخا سابقا أو مطابقا للتاريخ :date",
|
|
218
|
-
between: {
|
|
219
|
-
number: "يجب أن تكون قيمة :attribute بين :min و :max.",
|
|
220
|
-
string: "يجب أن يكون عدد حروف النّص :attribute بين :min و :max",
|
|
221
|
-
array: "يجب أن يحتوي :attribute على عدد من العناصر بين :min و :max",
|
|
222
|
-
object: "يجب أن يحتوي :attribute على عدد من العناصر بين :min و :max"
|
|
223
|
-
},
|
|
224
|
-
boolean: "يجب أن تكون قيمة الحقل :attribute إما true أو false",
|
|
225
|
-
confirmed: "حقل التأكيد غير مُطابق للحقل :attribute",
|
|
226
|
-
date: "الحقل :attribute ليس تاريخًا صحيحًا",
|
|
227
|
-
datetime: "الحقل :attribute يجب أن يكون تاريخًا صالحًا يطابق الصيغة :format.",
|
|
228
|
-
date_equals: "لا يساوي الحقل :attribute مع :date.",
|
|
229
|
-
declined: "يجب رفض الحقل :attribute",
|
|
230
|
-
declined_if: "الحقل :attribute مرفوض في حال ما إذا كان :other يساوي :value.",
|
|
231
|
-
different: "يجب أن يكون الحقلان :attribute و :other مُختلفان",
|
|
232
|
-
digits: "يجب أن يحتوي الحقل :attribute على :digits رقمًا/أرقام",
|
|
233
|
-
digits_between: "يجب أن يحتوي الحقل :attribute بين :min و :max رقمًا/أرقام",
|
|
234
|
-
email: "يجب أن يكون :attribute عنوان بريد إلكتروني صحيح البُنية",
|
|
235
|
-
ends_with: "حقل :attribute يجب ان ينتهي بأحد القيم التالية :value.",
|
|
236
|
-
exists: "الحقل :attribute غير موجود",
|
|
237
|
-
gt: {
|
|
238
|
-
number: "حقل :attribute يجب ان يكون اكبر من :value.",
|
|
239
|
-
string: "حقل :attribute يجب ان يكون اكبر من :value حروفٍ/حرفًا.",
|
|
240
|
-
array: "حقل :attribute يجب ان يحتوي علي اكثر من :value عناصر/عنصر.",
|
|
241
|
-
object: "حقل :attribute يجب ان يحتوي علي اكثر من :value عناصر/عنصر."
|
|
242
|
-
},
|
|
243
|
-
gte: {
|
|
244
|
-
number: "حقل :attribute يجب ان يكون اكبر من او يساوي :value.",
|
|
245
|
-
string: "حقل :attribute يجب ان يكون اكبر من او يساوي :value حروفٍ/حرفًا.",
|
|
246
|
-
array: "حقل :attribute يجب ان يحتوي علي :value عناصر/عنصر او اكثر.",
|
|
247
|
-
object: "حقل :attribute يجب ان يحتوي علي :value عناصر/عنصر او اكثر."
|
|
248
|
-
},
|
|
249
|
-
hex: "الحقل :attribute يجب أن يكون لونًا سداسيًا صالحًا.",
|
|
250
|
-
in: "الحقل :attribute غير صالح",
|
|
251
|
-
includes: "الحقل :attribute يجب أن يحتوي على أحد القيم التالية: :values.",
|
|
252
|
-
integer: "يجب أن يكون الحقل :attribute عددًا صحيحًا",
|
|
253
|
-
json: "يجب أن يكون الحقل :attribute نصا من نوع JSON.",
|
|
254
|
-
lt: {
|
|
255
|
-
number: "حقل :attribute يجب ان يكون اقل من :value.",
|
|
256
|
-
string: "حقل :attribute يجب ان يكون اقل من :value حروفٍ/حرفًا.",
|
|
257
|
-
array: "حقل :attribute يجب ان يحتوي علي اقل من :value عناصر/عنصر.",
|
|
258
|
-
object: "حقل :attribute يجب ان يحتوي علي اقل من :value عناصر/عنصر."
|
|
259
|
-
},
|
|
260
|
-
lte: {
|
|
261
|
-
number: "حقل :attribute يجب ان يكون اقل من او يساوي :value.",
|
|
262
|
-
string: "حقل :attribute يجب ان يكون اقل من او يساوي :value حروفٍ/حرفًا.",
|
|
263
|
-
array: "حقل :attribute يجب ان يحتوي علي اكثر من :value عناصر/عنصر.",
|
|
264
|
-
object: "حقل :attribute يجب ان يحتوي علي اكثر من :value عناصر/عنصر."
|
|
265
|
-
},
|
|
266
|
-
max: {
|
|
267
|
-
number: "يجب أن تكون قيمة الحقل :attribute مساوية أو أصغر لـ :max.",
|
|
268
|
-
string: "يجب أن لا يتجاوز طول نص :attribute :max حروفٍ/حرفًا",
|
|
269
|
-
array: "يجب أن لا يحتوي الحقل :attribute على أكثر من :max عناصر/عنصر.",
|
|
270
|
-
object: "يجب أن لا يحتوي الحقل :attribute على أكثر من :max عناصر/عنصر."
|
|
271
|
-
},
|
|
272
|
-
min: {
|
|
273
|
-
number: "يجب أن تكون قيمة الحقل :attribute مساوية أو أكبر لـ :min.",
|
|
274
|
-
string: "يجب أن يكون طول نص :attribute على الأقل :min حروفٍ/حرفًا",
|
|
275
|
-
array: "يجب أن يحتوي الحقل :attribute على الأقل على :min عُنصرًا/عناصر",
|
|
276
|
-
object: "يجب أن يحتوي الحقل :attribute على الأقل على :min عُنصرًا/عناصر"
|
|
277
|
-
},
|
|
278
|
-
not_in: "الحقل :attribute غير صالح",
|
|
279
|
-
not_regex: "الحقل :attribute نوعه غير صالح",
|
|
280
|
-
not_includes: "الحقل :attribute يجب ألا يحتوي على أي من القيم التالية: :values.",
|
|
281
|
-
numeric: "يجب على الحقل :attribute أن يكون رقمًا",
|
|
282
|
-
object: "الحقل :attribute يجب ان يكون من نوع object.",
|
|
283
|
-
password: {
|
|
284
|
-
letter: "يجب ان يشمل حقل :attribute على حرف واحد على الاقل.",
|
|
285
|
-
letters: "يجب ان يشمل حقل :attribute على عدد :amount حروف على الاقل.",
|
|
286
|
-
lower_case: "يجب ان يشمل حقل :attribute على حرف واحد من صيغة صغيرة على الاقل.",
|
|
287
|
-
lower_cases: "يجب ان يشمل حقل :attribute على عدد :amount حروف صغيرة على الاقل.",
|
|
288
|
-
number: "يجب ان يشمل حقل :attribute على رقم واحد على الاقل.",
|
|
289
|
-
numbers: "يجب ان يشمل حقل :attribute على عدد :amount من الارقام على الاقل.",
|
|
290
|
-
symbol: "يجب ان يشمل حقل :attribute على رمز واحد على الاقل.",
|
|
291
|
-
symbols: "يجب ان يشمل حقل :attribute على عدد :amount رموز على الاقل.",
|
|
292
|
-
upper_case: "يجب ان يشمل حقل :attribute على حرف كبير واحد على الاقل.",
|
|
293
|
-
upper_cases: "يجب ان يشمل حقل :attribute على عدد :amount حروف كبيرة على الاقل."
|
|
294
|
-
},
|
|
295
|
-
present: "يجب تقديم الحقل :attribute",
|
|
296
|
-
regex: "صيغة الحقل :attribute .غير صحيحة",
|
|
297
|
-
required: "الحقل :attribute مطلوب.",
|
|
298
|
-
required_if: "الحقل :attribute مطلوب في حال ما إذا كان :other يساوي :value.",
|
|
299
|
-
required_unless: "الحقل :attribute مطلوب في حال ما لم يكن :other يساوي :values.",
|
|
300
|
-
required_with: "الحقل :attribute اجباري إذا توفّر :values.",
|
|
301
|
-
required_with_all: "الحقل :attribute اجباري إذا توفّر :values.",
|
|
302
|
-
required_without: "الحقل :attribute اجباري إذا لم يتوفّر :values.",
|
|
303
|
-
required_without_all: "الحقل :attribute اجباري إذا لم يتوفّر :values.",
|
|
304
|
-
starts_with: "الحقل :attribute يجب ان يبدأ بأحد القيم التالية: :values.",
|
|
305
|
-
same: "يجب أن يتطابق الحقل :attribute مع :other",
|
|
306
|
-
size: {
|
|
307
|
-
number: "يجب أن تكون قيمة الحقل :attribute مساوية لـ :size",
|
|
308
|
-
string: "يجب أن يحتوي النص :attribute على :size حروفٍ/حرفًا بالظبط",
|
|
309
|
-
array: "يجب أن يحتوي الحقل :attribute على :size عنصرٍ/عناصر بالظبط",
|
|
310
|
-
object: "يجب أن يحتوي الحقل :attribute على :size عنصرٍ/عناصر بالظبط"
|
|
311
|
-
},
|
|
312
|
-
string: "يجب أن يكون الحقل :attribute نصآ.",
|
|
313
|
-
unique: "الحقل :attribute مستخدم بالفعل.",
|
|
314
|
-
url: "صيغة الرابط :attribute غير صحيحة"
|
|
315
|
-
};
|
|
316
|
-
|
|
317
72
|
//#endregion
|
|
318
73
|
//#region src/locales/index.ts
|
|
319
74
|
var locales_default = {
|
|
320
|
-
en:
|
|
321
|
-
|
|
75
|
+
en: {
|
|
76
|
+
accepted: "The :attribute must be accepted.",
|
|
77
|
+
accepted_if: "The :attribute must be accepted when :other is :value.",
|
|
78
|
+
after: "The :attribute must be a date after :date.",
|
|
79
|
+
after_or_equal: "The :attribute must be a date after or equal to :date.",
|
|
80
|
+
alpha: "The :attribute must only contain letters.",
|
|
81
|
+
alpha_dash: "The :attribute must only contain at least one letter or one number, and optionally dashes and underscores.",
|
|
82
|
+
alpha_num: "The :attribute must only contain letters and numbers.",
|
|
83
|
+
array: "The :attribute must be an array.",
|
|
84
|
+
array_unique: "The :attribute must be an array with unique values.",
|
|
85
|
+
before: "The :attribute must be a date before :date.",
|
|
86
|
+
before_or_equal: "The :attribute must be a date before or equal to :date.",
|
|
87
|
+
between: {
|
|
88
|
+
number: "The :attribute must be between :min and :max.",
|
|
89
|
+
string: "The :attribute must be between :min and :max characters.",
|
|
90
|
+
array: "The :attribute must have between :min and :max items.",
|
|
91
|
+
object: "The :attribute must have between :min and :max items."
|
|
92
|
+
},
|
|
93
|
+
boolean: "The :attribute field must be true or false.",
|
|
94
|
+
confirmed: "The :attribute confirmation does not match.",
|
|
95
|
+
date: "The :attribute is not a valid date.",
|
|
96
|
+
datetime: "The :attribute must be a valid date matching the format :format.",
|
|
97
|
+
date_equals: "The :attribute must be a date equal to :date.",
|
|
98
|
+
declined: "The :attribute must be declined.",
|
|
99
|
+
declined_if: "The :attribute must be declined when :other is :value.",
|
|
100
|
+
different: "The :attribute and :other must be different.",
|
|
101
|
+
distinct: "The :attribute field has a duplicate value.",
|
|
102
|
+
digits: "The :attribute must be :digits digits.",
|
|
103
|
+
digits_between: "The :attribute must be between :min and :max digits.",
|
|
104
|
+
email: "The :attribute must be a valid email address.",
|
|
105
|
+
ends_with: "The :attribute must end with one of the following: :values.",
|
|
106
|
+
filled: "The :attribute field must have a value.",
|
|
107
|
+
exists: "The selected :attribute is invalid.",
|
|
108
|
+
gt: {
|
|
109
|
+
number: "The :attribute must be greater than :value.",
|
|
110
|
+
string: "The :attribute must be greater than :value characters.",
|
|
111
|
+
array: "The :attribute must have more than :value items.",
|
|
112
|
+
object: "The :attribute must have more than :value items."
|
|
113
|
+
},
|
|
114
|
+
gte: {
|
|
115
|
+
number: "The :attribute must be greater than or equal :value.",
|
|
116
|
+
string: "The :attribute must be greater than or equal :value characters.",
|
|
117
|
+
array: "The :attribute must have :value items or more.",
|
|
118
|
+
object: "The :attribute must have :value items or more."
|
|
119
|
+
},
|
|
120
|
+
hex: "The :attribute must be a valid hexadecimal color.",
|
|
121
|
+
in: "The :attribute must be one of the following :values.",
|
|
122
|
+
includes: "The :attribute must include one of the following values: :values.",
|
|
123
|
+
integer: "The :attribute must be an integer.",
|
|
124
|
+
ip: "The :attribute must be a valid IP address.",
|
|
125
|
+
ipv4: "The :attribute must be a valid IPv4 address.",
|
|
126
|
+
ipv6: "The :attribute must be a valid IPv6 address.",
|
|
127
|
+
json: "The :attribute must be a valid JSON string.",
|
|
128
|
+
lt: {
|
|
129
|
+
number: "The :attribute must be less than :value.",
|
|
130
|
+
string: "The :attribute must be less than :value characters.",
|
|
131
|
+
array: "The :attribute must have less than :value items.",
|
|
132
|
+
object: "The :attribute must have less than :value items."
|
|
133
|
+
},
|
|
134
|
+
lte: {
|
|
135
|
+
number: "The :attribute must be less than or equal :value.",
|
|
136
|
+
string: "The :attribute must be less than or equal :value characters.",
|
|
137
|
+
array: "The :attribute must have :value items or less.",
|
|
138
|
+
object: "The :attribute must have :value items or less."
|
|
139
|
+
},
|
|
140
|
+
max: {
|
|
141
|
+
number: "The :attribute must not be greater than :max.",
|
|
142
|
+
string: "The :attribute must not be greater than :max characters.",
|
|
143
|
+
array: "The :attribute must not have more than :max items.",
|
|
144
|
+
object: "The :attribute must not have more than :max items."
|
|
145
|
+
},
|
|
146
|
+
min: {
|
|
147
|
+
number: "The :attribute must be at least :min.",
|
|
148
|
+
string: "The :attribute must be at least :min characters.",
|
|
149
|
+
array: "The :attribute must have at least :min items.",
|
|
150
|
+
object: "The :attribute must have at least :min items."
|
|
151
|
+
},
|
|
152
|
+
mac_address: "The :attribute must be a valid MAC address.",
|
|
153
|
+
not_in: "The selected :attribute is invalid.",
|
|
154
|
+
not_regex: "The :attribute format is invalid.",
|
|
155
|
+
not_includes: "The :attribute must not include any of the following values: :values.",
|
|
156
|
+
numeric: "The :attribute must be a number.",
|
|
157
|
+
object: "The :attribute must be an object.",
|
|
158
|
+
password: {
|
|
159
|
+
letter: "The :attribute must contain at least one letter.",
|
|
160
|
+
letters: "The :attribute must contain at least :amount letters.",
|
|
161
|
+
lower_case: "The :attribute must contain at least one lowercase letter.",
|
|
162
|
+
lower_cases: "The :attribute must contain at least :amount lowercase letters.",
|
|
163
|
+
number: "The :attribute must contain at least one number.",
|
|
164
|
+
numbers: "The :attribute must contain at least :amount numbers.",
|
|
165
|
+
symbol: "The :attribute must contain at least one symbol.",
|
|
166
|
+
symbols: "The :attribute must contain at least :amount symbols.",
|
|
167
|
+
upper_case: "The :attribute must contain at least one uppercase letter.",
|
|
168
|
+
upper_cases: "The :attribute must contain at least :amount uppercase letters."
|
|
169
|
+
},
|
|
170
|
+
present: "The :attribute field must be present.",
|
|
171
|
+
presentsame: "The :attribute field must be present.",
|
|
172
|
+
prohibited: "The :attribute field is prohibited.",
|
|
173
|
+
prohibited_unless: "The :attribute field is prohibited unless :other is in :values.",
|
|
174
|
+
prohibits: "The :attribute field prohibits :values from being present.",
|
|
175
|
+
regex: "The :attribute format is invalid.",
|
|
176
|
+
required: "The :attribute field is required.",
|
|
177
|
+
required_if: "The :attribute field is required when :other is :value.",
|
|
178
|
+
required_unless: "The :attribute field is required unless :other is in :values.",
|
|
179
|
+
required_with: "The :attribute field is required when :values is present.",
|
|
180
|
+
required_with_all: "The :attribute field is required when :values are present.",
|
|
181
|
+
required_without: "The :attribute field is required when :values is not present.",
|
|
182
|
+
required_without_all: "The :attribute field is required when none of :values are present.",
|
|
183
|
+
starts_with: "The :attribute must start with one of the following: :values.",
|
|
184
|
+
same: "The :attribute and :other must match.",
|
|
185
|
+
size: {
|
|
186
|
+
number: "The :attribute must be :size.",
|
|
187
|
+
string: "The :attribute must be :size characters.",
|
|
188
|
+
array: "The :attribute must contain :size items.",
|
|
189
|
+
object: "The :attribute must contain :size items."
|
|
190
|
+
},
|
|
191
|
+
string: "The :attribute must be a string.",
|
|
192
|
+
timezone: "The :attribute must be a valid timezone.",
|
|
193
|
+
unique: "The :attribute has already been taken.",
|
|
194
|
+
url: "The :attribute must have a valid URL format.",
|
|
195
|
+
multiple_of: "The :attribute must be a multiple of :value."
|
|
196
|
+
},
|
|
197
|
+
ar: {
|
|
198
|
+
accepted: "يجب قبول الحقل :attribute",
|
|
199
|
+
accepted_if: "الحقل :attribute مقبول في حال ما إذا كان :other يساوي :value.",
|
|
200
|
+
after: "يجب على الحقل :attribute أن يكون تاريخا لاحقا للتاريخ :date.",
|
|
201
|
+
after_or_equal: "الحقل :attribute يجب أن يكون تاريخاً لاحقاً أو مطابقاً للتاريخ :date.",
|
|
202
|
+
alpha: "يجب أن لا يحتوي الحقل :attribute سوى على حروف",
|
|
203
|
+
alpha_dash: "يجب أن يحتوي الحقل :attribute على حرف واحد أو رقم واحد على الأقل، بالإضافة إلى شرطات وشرطات سفلية بشكل اختياري",
|
|
204
|
+
alpha_num: "يجب أن يحتوي :attribute على حروف وأرقام فقط",
|
|
205
|
+
array: "يجب أن يكون الحقل :attribute ًمصفوفة",
|
|
206
|
+
before: "يجب على الحقل :attribute أن يكون تاريخا سابقا للتاريخ :date.",
|
|
207
|
+
before_or_equal: "الحقل :attribute يجب أن يكون تاريخا سابقا أو مطابقا للتاريخ :date",
|
|
208
|
+
between: {
|
|
209
|
+
number: "يجب أن تكون قيمة :attribute بين :min و :max.",
|
|
210
|
+
string: "يجب أن يكون عدد حروف النّص :attribute بين :min و :max",
|
|
211
|
+
array: "يجب أن يحتوي :attribute على عدد من العناصر بين :min و :max",
|
|
212
|
+
object: "يجب أن يحتوي :attribute على عدد من العناصر بين :min و :max"
|
|
213
|
+
},
|
|
214
|
+
boolean: "يجب أن تكون قيمة الحقل :attribute إما true أو false",
|
|
215
|
+
confirmed: "حقل التأكيد غير مُطابق للحقل :attribute",
|
|
216
|
+
date: "الحقل :attribute ليس تاريخًا صحيحًا",
|
|
217
|
+
datetime: "الحقل :attribute يجب أن يكون تاريخًا صالحًا يطابق الصيغة :format.",
|
|
218
|
+
date_equals: "لا يساوي الحقل :attribute مع :date.",
|
|
219
|
+
declined: "يجب رفض الحقل :attribute",
|
|
220
|
+
declined_if: "الحقل :attribute مرفوض في حال ما إذا كان :other يساوي :value.",
|
|
221
|
+
different: "يجب أن يكون الحقلان :attribute و :other مُختلفان",
|
|
222
|
+
digits: "يجب أن يحتوي الحقل :attribute على :digits رقمًا/أرقام",
|
|
223
|
+
digits_between: "يجب أن يحتوي الحقل :attribute بين :min و :max رقمًا/أرقام",
|
|
224
|
+
email: "يجب أن يكون :attribute عنوان بريد إلكتروني صحيح البُنية",
|
|
225
|
+
ends_with: "حقل :attribute يجب ان ينتهي بأحد القيم التالية :value.",
|
|
226
|
+
exists: "الحقل :attribute غير موجود",
|
|
227
|
+
gt: {
|
|
228
|
+
number: "حقل :attribute يجب ان يكون اكبر من :value.",
|
|
229
|
+
string: "حقل :attribute يجب ان يكون اكبر من :value حروفٍ/حرفًا.",
|
|
230
|
+
array: "حقل :attribute يجب ان يحتوي علي اكثر من :value عناصر/عنصر.",
|
|
231
|
+
object: "حقل :attribute يجب ان يحتوي علي اكثر من :value عناصر/عنصر."
|
|
232
|
+
},
|
|
233
|
+
gte: {
|
|
234
|
+
number: "حقل :attribute يجب ان يكون اكبر من او يساوي :value.",
|
|
235
|
+
string: "حقل :attribute يجب ان يكون اكبر من او يساوي :value حروفٍ/حرفًا.",
|
|
236
|
+
array: "حقل :attribute يجب ان يحتوي علي :value عناصر/عنصر او اكثر.",
|
|
237
|
+
object: "حقل :attribute يجب ان يحتوي علي :value عناصر/عنصر او اكثر."
|
|
238
|
+
},
|
|
239
|
+
hex: "الحقل :attribute يجب أن يكون لونًا سداسيًا صالحًا.",
|
|
240
|
+
in: "الحقل :attribute غير صالح",
|
|
241
|
+
includes: "الحقل :attribute يجب أن يحتوي على أحد القيم التالية: :values.",
|
|
242
|
+
integer: "يجب أن يكون الحقل :attribute عددًا صحيحًا",
|
|
243
|
+
json: "يجب أن يكون الحقل :attribute نصا من نوع JSON.",
|
|
244
|
+
lt: {
|
|
245
|
+
number: "حقل :attribute يجب ان يكون اقل من :value.",
|
|
246
|
+
string: "حقل :attribute يجب ان يكون اقل من :value حروفٍ/حرفًا.",
|
|
247
|
+
array: "حقل :attribute يجب ان يحتوي علي اقل من :value عناصر/عنصر.",
|
|
248
|
+
object: "حقل :attribute يجب ان يحتوي علي اقل من :value عناصر/عنصر."
|
|
249
|
+
},
|
|
250
|
+
lte: {
|
|
251
|
+
number: "حقل :attribute يجب ان يكون اقل من او يساوي :value.",
|
|
252
|
+
string: "حقل :attribute يجب ان يكون اقل من او يساوي :value حروفٍ/حرفًا.",
|
|
253
|
+
array: "حقل :attribute يجب ان يحتوي علي اكثر من :value عناصر/عنصر.",
|
|
254
|
+
object: "حقل :attribute يجب ان يحتوي علي اكثر من :value عناصر/عنصر."
|
|
255
|
+
},
|
|
256
|
+
max: {
|
|
257
|
+
number: "يجب أن تكون قيمة الحقل :attribute مساوية أو أصغر لـ :max.",
|
|
258
|
+
string: "يجب أن لا يتجاوز طول نص :attribute :max حروفٍ/حرفًا",
|
|
259
|
+
array: "يجب أن لا يحتوي الحقل :attribute على أكثر من :max عناصر/عنصر.",
|
|
260
|
+
object: "يجب أن لا يحتوي الحقل :attribute على أكثر من :max عناصر/عنصر."
|
|
261
|
+
},
|
|
262
|
+
min: {
|
|
263
|
+
number: "يجب أن تكون قيمة الحقل :attribute مساوية أو أكبر لـ :min.",
|
|
264
|
+
string: "يجب أن يكون طول نص :attribute على الأقل :min حروفٍ/حرفًا",
|
|
265
|
+
array: "يجب أن يحتوي الحقل :attribute على الأقل على :min عُنصرًا/عناصر",
|
|
266
|
+
object: "يجب أن يحتوي الحقل :attribute على الأقل على :min عُنصرًا/عناصر"
|
|
267
|
+
},
|
|
268
|
+
not_in: "الحقل :attribute غير صالح",
|
|
269
|
+
not_regex: "الحقل :attribute نوعه غير صالح",
|
|
270
|
+
not_includes: "الحقل :attribute يجب ألا يحتوي على أي من القيم التالية: :values.",
|
|
271
|
+
numeric: "يجب على الحقل :attribute أن يكون رقمًا",
|
|
272
|
+
object: "الحقل :attribute يجب ان يكون من نوع object.",
|
|
273
|
+
password: {
|
|
274
|
+
letter: "يجب ان يشمل حقل :attribute على حرف واحد على الاقل.",
|
|
275
|
+
letters: "يجب ان يشمل حقل :attribute على عدد :amount حروف على الاقل.",
|
|
276
|
+
lower_case: "يجب ان يشمل حقل :attribute على حرف واحد من صيغة صغيرة على الاقل.",
|
|
277
|
+
lower_cases: "يجب ان يشمل حقل :attribute على عدد :amount حروف صغيرة على الاقل.",
|
|
278
|
+
number: "يجب ان يشمل حقل :attribute على رقم واحد على الاقل.",
|
|
279
|
+
numbers: "يجب ان يشمل حقل :attribute على عدد :amount من الارقام على الاقل.",
|
|
280
|
+
symbol: "يجب ان يشمل حقل :attribute على رمز واحد على الاقل.",
|
|
281
|
+
symbols: "يجب ان يشمل حقل :attribute على عدد :amount رموز على الاقل.",
|
|
282
|
+
upper_case: "يجب ان يشمل حقل :attribute على حرف كبير واحد على الاقل.",
|
|
283
|
+
upper_cases: "يجب ان يشمل حقل :attribute على عدد :amount حروف كبيرة على الاقل."
|
|
284
|
+
},
|
|
285
|
+
present: "يجب تقديم الحقل :attribute",
|
|
286
|
+
regex: "صيغة الحقل :attribute .غير صحيحة",
|
|
287
|
+
required: "الحقل :attribute مطلوب.",
|
|
288
|
+
required_if: "الحقل :attribute مطلوب في حال ما إذا كان :other يساوي :value.",
|
|
289
|
+
required_unless: "الحقل :attribute مطلوب في حال ما لم يكن :other يساوي :values.",
|
|
290
|
+
required_with: "الحقل :attribute اجباري إذا توفّر :values.",
|
|
291
|
+
required_with_all: "الحقل :attribute اجباري إذا توفّر :values.",
|
|
292
|
+
required_without: "الحقل :attribute اجباري إذا لم يتوفّر :values.",
|
|
293
|
+
required_without_all: "الحقل :attribute اجباري إذا لم يتوفّر :values.",
|
|
294
|
+
starts_with: "الحقل :attribute يجب ان يبدأ بأحد القيم التالية: :values.",
|
|
295
|
+
same: "يجب أن يتطابق الحقل :attribute مع :other",
|
|
296
|
+
size: {
|
|
297
|
+
number: "يجب أن تكون قيمة الحقل :attribute مساوية لـ :size",
|
|
298
|
+
string: "يجب أن يحتوي النص :attribute على :size حروفٍ/حرفًا بالظبط",
|
|
299
|
+
array: "يجب أن يحتوي الحقل :attribute على :size عنصرٍ/عناصر بالظبط",
|
|
300
|
+
object: "يجب أن يحتوي الحقل :attribute على :size عنصرٍ/عناصر بالظبط"
|
|
301
|
+
},
|
|
302
|
+
string: "يجب أن يكون الحقل :attribute نصآ.",
|
|
303
|
+
unique: "الحقل :attribute مستخدم بالفعل.",
|
|
304
|
+
url: "صيغة الرابط :attribute غير صحيحة"
|
|
305
|
+
}
|
|
322
306
|
};
|
|
323
|
-
|
|
324
307
|
//#endregion
|
|
325
308
|
//#region src/utilities/helpers.ts
|
|
326
309
|
/**
|
|
@@ -375,7 +358,6 @@ function deepFindMessage(obj, path) {
|
|
|
375
358
|
}
|
|
376
359
|
return obj;
|
|
377
360
|
}
|
|
378
|
-
|
|
379
361
|
//#endregion
|
|
380
362
|
//#region src/Lang.ts
|
|
381
363
|
var Lang = class {
|
|
@@ -489,7 +471,6 @@ var Lang = class {
|
|
|
489
471
|
this.fallbackMessages = locales_default.en;
|
|
490
472
|
}
|
|
491
473
|
};
|
|
492
|
-
|
|
493
474
|
//#endregion
|
|
494
475
|
//#region src/Rules/IRuleContract.ts
|
|
495
476
|
var IRuleContract = class {
|
|
@@ -541,7 +522,6 @@ var IRuleContract = class {
|
|
|
541
522
|
return message;
|
|
542
523
|
}
|
|
543
524
|
};
|
|
544
|
-
|
|
545
525
|
//#endregion
|
|
546
526
|
//#region src/utilities/date.ts
|
|
547
527
|
/**
|
|
@@ -551,10 +531,12 @@ function toDate(value) {
|
|
|
551
531
|
const date = Date.parse(value);
|
|
552
532
|
return !isNaN(date) ? new Date(date) : null;
|
|
553
533
|
}
|
|
554
|
-
|
|
555
534
|
//#endregion
|
|
556
535
|
//#region src/validators/replaceAttributes.ts
|
|
557
536
|
const replaceAttributes = {
|
|
537
|
+
/**
|
|
538
|
+
* Replace all place-holders for the accepted_if rule.
|
|
539
|
+
*/
|
|
558
540
|
replaceAcceptedIf: function({ data, message, parameters, getDisplayableAttribute }) {
|
|
559
541
|
const [other] = parameters;
|
|
560
542
|
const result = deepFind(data, other);
|
|
@@ -564,19 +546,34 @@ const replaceAttributes = {
|
|
|
564
546
|
};
|
|
565
547
|
return message.replace(/:other|:value/gi, (matched) => values[matched]);
|
|
566
548
|
},
|
|
549
|
+
/**
|
|
550
|
+
* Replace all place-holders for the after rule.
|
|
551
|
+
*/
|
|
567
552
|
replaceAfter: function(payload) {
|
|
568
553
|
return this.replaceBefore(payload);
|
|
569
554
|
},
|
|
555
|
+
/**
|
|
556
|
+
* Replace all place-holders for the after_or_equal rule.
|
|
557
|
+
*/
|
|
570
558
|
replaceAfterOrEqual: function(payload) {
|
|
571
559
|
return this.replaceBefore(payload);
|
|
572
560
|
},
|
|
561
|
+
/**
|
|
562
|
+
* Replace all place-holders for the before rule.
|
|
563
|
+
*/
|
|
573
564
|
replaceBefore: function({ message, parameters, getDisplayableAttribute }) {
|
|
574
565
|
if (!toDate(parameters[0])) return message.replace(":date", getDisplayableAttribute(parameters[0]));
|
|
575
566
|
return message.replace(":date", parameters[0]);
|
|
576
567
|
},
|
|
568
|
+
/**
|
|
569
|
+
* Replace all place-holders for the before_or_equal rule.
|
|
570
|
+
*/
|
|
577
571
|
replaceBeforeOrEqual: function(payload) {
|
|
578
572
|
return this.replaceBefore(payload);
|
|
579
573
|
},
|
|
574
|
+
/**
|
|
575
|
+
* Replace all the place-holders for the between rule.
|
|
576
|
+
*/
|
|
580
577
|
replaceBetween: function({ message, parameters }) {
|
|
581
578
|
const values = {
|
|
582
579
|
":min": parameters[0],
|
|
@@ -584,12 +581,21 @@ const replaceAttributes = {
|
|
|
584
581
|
};
|
|
585
582
|
return message.replace(/:min|:max/gi, (matched) => values[matched]);
|
|
586
583
|
},
|
|
584
|
+
/**
|
|
585
|
+
* Replace all place-holders for the before_or_equal rule.
|
|
586
|
+
*/
|
|
587
587
|
replaceDateEquals: function(payload) {
|
|
588
588
|
return this.replaceBefore(payload);
|
|
589
589
|
},
|
|
590
|
+
/**
|
|
591
|
+
* Replace all place-holders for the datetime rule.
|
|
592
|
+
*/
|
|
590
593
|
replaceDatetime: function({ message, parameters }) {
|
|
591
594
|
return message.replace(":format", parameters[0]);
|
|
592
595
|
},
|
|
596
|
+
/**
|
|
597
|
+
* Replace all place-holders for the declined_if rule.
|
|
598
|
+
*/
|
|
593
599
|
replaceDeclinedIf: function({ message, parameters, data, getDisplayableAttribute }) {
|
|
594
600
|
const [other] = parameters;
|
|
595
601
|
const result = deepFind(data, other);
|
|
@@ -599,66 +605,126 @@ const replaceAttributes = {
|
|
|
599
605
|
};
|
|
600
606
|
return message.replace(/:other|:value/gi, (matched) => values[matched]);
|
|
601
607
|
},
|
|
608
|
+
/**
|
|
609
|
+
* Replace all place-holders for the different rule.
|
|
610
|
+
*/
|
|
602
611
|
replaceDifferent: function(payload) {
|
|
603
612
|
return this.replaceSame(payload);
|
|
604
613
|
},
|
|
614
|
+
/**
|
|
615
|
+
* Replace all place-holders for the digits rule.
|
|
616
|
+
*/
|
|
605
617
|
replaceDigits: function({ message, parameters }) {
|
|
606
618
|
return message.replace(":digits", parameters[0]);
|
|
607
619
|
},
|
|
620
|
+
/**
|
|
621
|
+
* Replace all place-holders for the digits (between) rule.
|
|
622
|
+
*/
|
|
608
623
|
replaceDigitsBetween: function(payload) {
|
|
609
624
|
return this.replaceBetween(payload);
|
|
610
625
|
},
|
|
626
|
+
/**
|
|
627
|
+
* Replace all place-holders for the ends_with rule.
|
|
628
|
+
*/
|
|
611
629
|
replaceEndsWith: function({ message, parameters }) {
|
|
612
630
|
return message.replace(":values", parameters.join(", "));
|
|
613
631
|
},
|
|
632
|
+
/**
|
|
633
|
+
* Replace all place-holders for the exists rule.
|
|
634
|
+
*/
|
|
614
635
|
replaceExists: function({ message, parameters, data }) {
|
|
615
636
|
return message.replace(":value", data[parameters[1]]);
|
|
616
637
|
},
|
|
638
|
+
/**
|
|
639
|
+
* Replace all place-holders for the in rule.
|
|
640
|
+
*/
|
|
617
641
|
replaceIn: function({ message, parameters }) {
|
|
618
642
|
return message.replace(":values", parameters.join(", "));
|
|
619
643
|
},
|
|
644
|
+
/**
|
|
645
|
+
* Replace all place-holders for the not_includes rule.
|
|
646
|
+
*/
|
|
620
647
|
replaceIncludes: function({ message, parameters }) {
|
|
621
648
|
return message.replace(":values", parameters.join(", "));
|
|
622
649
|
},
|
|
650
|
+
/**
|
|
651
|
+
* Replace all place-holders for the starts_with rule.
|
|
652
|
+
*/
|
|
623
653
|
replaceStartsWith: function({ message, parameters }) {
|
|
624
654
|
return message.replace(":values", parameters.join(", "));
|
|
625
655
|
},
|
|
656
|
+
/**
|
|
657
|
+
* Replace all place-holders for the min rule.
|
|
658
|
+
*/
|
|
626
659
|
replaceMin: function({ message, parameters }) {
|
|
627
660
|
return message.replace(":min", parameters[0]);
|
|
628
661
|
},
|
|
662
|
+
/**
|
|
663
|
+
* Replace all place-holders for the max rule.
|
|
664
|
+
*/
|
|
629
665
|
replaceMax: function({ message, parameters }) {
|
|
630
666
|
return message.replace(":max", parameters[0]);
|
|
631
667
|
},
|
|
668
|
+
/**
|
|
669
|
+
* Replace all place-holders for the not_includes rule.
|
|
670
|
+
*/
|
|
632
671
|
replaceNotIncludes: function({ message, parameters }) {
|
|
633
672
|
return message.replace(":values", parameters.join(", "));
|
|
634
673
|
},
|
|
674
|
+
/**
|
|
675
|
+
* Replace all place-holders for the required_with rule.
|
|
676
|
+
*/
|
|
635
677
|
replaceRequiredWith: function({ message, parameters, getDisplayableAttribute }) {
|
|
636
678
|
return message.replace(":values", parameters.map((attribute) => getDisplayableAttribute(attribute)).join(", "));
|
|
637
679
|
},
|
|
680
|
+
/**
|
|
681
|
+
* Replace all place-holders for the required_with_all rule.
|
|
682
|
+
*/
|
|
638
683
|
replaceRequiredWithAll: function(payload) {
|
|
639
684
|
return this.replaceRequiredWith(payload);
|
|
640
685
|
},
|
|
686
|
+
/**
|
|
687
|
+
* Replace all place-holders for the required_without rule.
|
|
688
|
+
*/
|
|
641
689
|
replaceRequiredWithout: function(payload) {
|
|
642
690
|
return this.replaceRequiredWith(payload);
|
|
643
691
|
},
|
|
692
|
+
/**
|
|
693
|
+
* Replace all place-holders for the required_without_all rule.
|
|
694
|
+
*/
|
|
644
695
|
replaceRequiredWithoutAll: function(payload) {
|
|
645
696
|
return this.replaceRequiredWith(payload);
|
|
646
697
|
},
|
|
698
|
+
/**
|
|
699
|
+
* Replace all place-holders for the gt rule.
|
|
700
|
+
*/
|
|
647
701
|
replaceGt: function({ message, parameters, data, hasNumericRule }) {
|
|
648
702
|
const [value] = parameters;
|
|
649
703
|
const result = deepFind(data, value);
|
|
650
704
|
if (typeof result === "undefined") return message.replace(":value", value);
|
|
651
705
|
return message.replace(":value", getSize(result, hasNumericRule).toString());
|
|
652
706
|
},
|
|
707
|
+
/**
|
|
708
|
+
* Replace all place-holders for the lt rule.
|
|
709
|
+
*/
|
|
653
710
|
replaceLt: function(payload) {
|
|
654
711
|
return this.replaceGt(payload);
|
|
655
712
|
},
|
|
713
|
+
/**
|
|
714
|
+
* Replace all place-holders for the gte rule.
|
|
715
|
+
*/
|
|
656
716
|
replaceGte: function(payload) {
|
|
657
717
|
return this.replaceGt(payload);
|
|
658
718
|
},
|
|
719
|
+
/**
|
|
720
|
+
* Replace all place-holders for the lte rule.
|
|
721
|
+
*/
|
|
659
722
|
replaceLte: function(payload) {
|
|
660
723
|
return this.replaceGt(payload);
|
|
661
724
|
},
|
|
725
|
+
/**
|
|
726
|
+
* Replace all place-holders for the required_if rule.
|
|
727
|
+
*/
|
|
662
728
|
replaceRequiredIf: function({ message, parameters, data, getDisplayableAttribute }) {
|
|
663
729
|
const [other] = parameters;
|
|
664
730
|
const result = deepFind(data, other);
|
|
@@ -668,12 +734,21 @@ const replaceAttributes = {
|
|
|
668
734
|
};
|
|
669
735
|
return message.replace(/:other|:value/gi, (matched) => values[matched]);
|
|
670
736
|
},
|
|
737
|
+
/**
|
|
738
|
+
* Replace all place-holders for the prohibited_unless rule.
|
|
739
|
+
*/
|
|
671
740
|
replaceProhibitedUnless: function(payload) {
|
|
672
741
|
return this.replaceRequiredUnless(payload);
|
|
673
742
|
},
|
|
743
|
+
/**
|
|
744
|
+
* Replace all place-holders for the prohibits rule.
|
|
745
|
+
*/
|
|
674
746
|
replaceProhibits: function({ message, parameters, getDisplayableAttribute }) {
|
|
675
747
|
return message.replace(":values", parameters.map((attribute) => getDisplayableAttribute(attribute)).join(", "));
|
|
676
748
|
},
|
|
749
|
+
/**
|
|
750
|
+
* Replace all the place-holders for the required_unless rule.
|
|
751
|
+
*/
|
|
677
752
|
replaceRequiredUnless: function({ message, parameters, getDisplayableAttribute }) {
|
|
678
753
|
const [other] = parameters;
|
|
679
754
|
const values = {
|
|
@@ -682,23 +757,41 @@ const replaceAttributes = {
|
|
|
682
757
|
};
|
|
683
758
|
return message.replace(/:other|:values/gi, (matched) => values[matched]);
|
|
684
759
|
},
|
|
760
|
+
/**
|
|
761
|
+
* Replace all place-holders for the same rule.
|
|
762
|
+
*/
|
|
685
763
|
replaceSame: function({ message, parameters, getDisplayableAttribute }) {
|
|
686
764
|
return message.replace(":other", getDisplayableAttribute(parameters[0]));
|
|
687
765
|
},
|
|
766
|
+
/**
|
|
767
|
+
* Replace all place-holders for the size rule.
|
|
768
|
+
*/
|
|
688
769
|
replaceSize: function({ message, parameters }) {
|
|
689
770
|
return message.replace(":size", parameters[0]);
|
|
690
771
|
},
|
|
772
|
+
/**
|
|
773
|
+
* Replace all place-holders for the multiple_of rule.
|
|
774
|
+
*/
|
|
691
775
|
replaceMultipleOf: function({ message, parameters }) {
|
|
692
776
|
return message.replace(":value", parameters[0]);
|
|
693
777
|
},
|
|
778
|
+
/**
|
|
779
|
+
* Replace all place-holders for the unique rule.
|
|
780
|
+
*/
|
|
694
781
|
replaceUnique: function({ message, parameters, data }) {
|
|
695
782
|
return message.replace(":value", data[parameters[1]]);
|
|
696
783
|
}
|
|
697
784
|
};
|
|
698
|
-
|
|
699
785
|
//#endregion
|
|
700
786
|
//#region src/validators/validationData.ts
|
|
701
787
|
const validationData = {
|
|
788
|
+
/**
|
|
789
|
+
* initialize and gather data for the given attribute.
|
|
790
|
+
*
|
|
791
|
+
* @param attribute
|
|
792
|
+
* @param masterData
|
|
793
|
+
* @returns
|
|
794
|
+
*/
|
|
702
795
|
initializeAndGatherData: function(attribute, masterData) {
|
|
703
796
|
const data = dotify(this.initializeAttributeOnData(attribute, masterData));
|
|
704
797
|
return {
|
|
@@ -706,6 +799,13 @@ const validationData = {
|
|
|
706
799
|
...this.extractValuesFromWildCards(masterData, data, attribute)
|
|
707
800
|
};
|
|
708
801
|
},
|
|
802
|
+
/**
|
|
803
|
+
* Gather a copy of the attribute data filled with any missing attributes.
|
|
804
|
+
*
|
|
805
|
+
* @param attribute
|
|
806
|
+
* @param masterData
|
|
807
|
+
* @returns
|
|
808
|
+
*/
|
|
709
809
|
initializeAttributeOnData: function(attribute, masterData) {
|
|
710
810
|
const explicitPath = this.getLeadingExplicitAttributePath(attribute);
|
|
711
811
|
const data = this.extractDataFromPath(explicitPath, JSON.parse(JSON.stringify(masterData)));
|
|
@@ -713,6 +813,14 @@ const validationData = {
|
|
|
713
813
|
deepSet(data, attribute, null);
|
|
714
814
|
return data;
|
|
715
815
|
},
|
|
816
|
+
/**
|
|
817
|
+
* Get all of the exact attribute values for a given wildcard attribute.
|
|
818
|
+
*
|
|
819
|
+
* @param masterData
|
|
820
|
+
* @param data
|
|
821
|
+
* @param attribute
|
|
822
|
+
* @returns
|
|
823
|
+
*/
|
|
716
824
|
extractValuesFromWildCards(masterData, data, attribute) {
|
|
717
825
|
const keys = [];
|
|
718
826
|
const pattern = new RegExp("^" + attribute.replace(/\*/g, "[^\\.]*"));
|
|
@@ -725,9 +833,22 @@ const validationData = {
|
|
|
725
833
|
keys.forEach((key) => data[key] = deepFind(masterData, key));
|
|
726
834
|
return data;
|
|
727
835
|
},
|
|
836
|
+
/**
|
|
837
|
+
* Get the explicit part of the attribute name - ex: 'foo.bar.*.baz' -> 'foo.bar'
|
|
838
|
+
*
|
|
839
|
+
* @param attribute
|
|
840
|
+
* @returns
|
|
841
|
+
*/
|
|
728
842
|
getLeadingExplicitAttributePath: function(attribute) {
|
|
729
843
|
return attribute.split("*")[0].replace(/\.$/, "");
|
|
730
844
|
},
|
|
845
|
+
/**
|
|
846
|
+
* Extract data based on the given dot-notated path.
|
|
847
|
+
*
|
|
848
|
+
* @param path
|
|
849
|
+
* @param masterData
|
|
850
|
+
* @returns
|
|
851
|
+
*/
|
|
731
852
|
extractDataFromPath(path, masterData) {
|
|
732
853
|
const results = {};
|
|
733
854
|
const value = deepFind(masterData, path);
|
|
@@ -735,7 +856,6 @@ const validationData = {
|
|
|
735
856
|
return results;
|
|
736
857
|
}
|
|
737
858
|
};
|
|
738
|
-
|
|
739
859
|
//#endregion
|
|
740
860
|
//#region src/Rules/closureValidationRule.ts
|
|
741
861
|
var ClosureValidationRule = class extends IRuleContract {
|
|
@@ -764,10 +884,16 @@ var ClosureValidationRule = class extends IRuleContract {
|
|
|
764
884
|
return !this.failed;
|
|
765
885
|
}
|
|
766
886
|
};
|
|
767
|
-
|
|
768
887
|
//#endregion
|
|
769
888
|
//#region src/validators/validationRuleParser.ts
|
|
770
889
|
const validationRuleParser = {
|
|
890
|
+
/**
|
|
891
|
+
* Convert rules to array
|
|
892
|
+
*
|
|
893
|
+
* @param rules
|
|
894
|
+
* @param data
|
|
895
|
+
* @returns
|
|
896
|
+
*/
|
|
771
897
|
explodeRules: function(rules, data = {}) {
|
|
772
898
|
const implicitAttributes = {};
|
|
773
899
|
for (const key in rules) if (key.indexOf("*") !== -1) {
|
|
@@ -780,6 +906,15 @@ const validationRuleParser = {
|
|
|
780
906
|
implicitAttributes
|
|
781
907
|
};
|
|
782
908
|
},
|
|
909
|
+
/**
|
|
910
|
+
* Define a set of rules that apply to each element in an array attribute.
|
|
911
|
+
*
|
|
912
|
+
* @param results
|
|
913
|
+
* @param attribute
|
|
914
|
+
* @param masterData
|
|
915
|
+
* @param implicitAttributes
|
|
916
|
+
* @returns
|
|
917
|
+
*/
|
|
783
918
|
explodeWildCardRules: function(results, attribute, masterData, implicitAttributes) {
|
|
784
919
|
const pattern = new RegExp("^" + attribute.replace(/\*/g, "[^.]*") + "$");
|
|
785
920
|
const data = validationData.initializeAndGatherData(attribute, masterData);
|
|
@@ -791,25 +926,45 @@ const validationRuleParser = {
|
|
|
791
926
|
}
|
|
792
927
|
return results;
|
|
793
928
|
},
|
|
929
|
+
/**
|
|
930
|
+
* Merge additional rules into a given attribute.
|
|
931
|
+
*
|
|
932
|
+
* @param results
|
|
933
|
+
* @param attribute
|
|
934
|
+
* @param rules
|
|
935
|
+
* @returns
|
|
936
|
+
*/
|
|
794
937
|
mergeRulesForAttribute(results, attribute, rules) {
|
|
795
938
|
const merge = this.explodeRules([rules]).rules[0];
|
|
796
939
|
results[attribute] = [...results[attribute] ? this.explodeExplicitRules(results[attribute]) : [], ...merge];
|
|
797
940
|
return results;
|
|
798
941
|
},
|
|
942
|
+
/**
|
|
943
|
+
* In case the rules specified by the user are a string seperated with '|' - convert them to an array
|
|
944
|
+
*/
|
|
799
945
|
explodeExplicitRules: function(rules) {
|
|
800
946
|
if (typeof rules === "string") return rules.split("|");
|
|
801
947
|
if (!Array.isArray(rules)) return [this.prepareRule(rules)];
|
|
802
948
|
return rules.map((rule) => this.prepareRule(rule));
|
|
803
949
|
},
|
|
950
|
+
/**
|
|
951
|
+
* Prepare the given rule for the Validator.
|
|
952
|
+
*/
|
|
804
953
|
prepareRule(rule) {
|
|
805
954
|
if (rule instanceof IRuleContract) return rule;
|
|
806
955
|
if (typeof rule === "function") return new ClosureValidationRule(rule);
|
|
807
956
|
return rule.toString();
|
|
808
957
|
},
|
|
958
|
+
/**
|
|
959
|
+
* Extract the rule name and parameters from a rule.
|
|
960
|
+
*/
|
|
809
961
|
parse(rule) {
|
|
810
962
|
if (rule instanceof IRuleContract) return [rule, []];
|
|
811
963
|
return this.parseStringRule(rule);
|
|
812
964
|
},
|
|
965
|
+
/**
|
|
966
|
+
* Parse the parameters associated with a rule
|
|
967
|
+
*/
|
|
813
968
|
parseStringRule: function(rule) {
|
|
814
969
|
let parameters = [];
|
|
815
970
|
let parameter;
|
|
@@ -819,6 +974,14 @@ const validationRuleParser = {
|
|
|
819
974
|
}
|
|
820
975
|
return [rule, parameters];
|
|
821
976
|
},
|
|
977
|
+
/**
|
|
978
|
+
* Get a rule and its parameters for a given attribute.
|
|
979
|
+
*
|
|
980
|
+
* @param attribute
|
|
981
|
+
* @param searchRules
|
|
982
|
+
* @param availableRules
|
|
983
|
+
* @returns
|
|
984
|
+
*/
|
|
822
985
|
getRule: function(attribute, searchRules, availableRules) {
|
|
823
986
|
if (!availableRules[attribute]) return [];
|
|
824
987
|
searchRules = Array.isArray(searchRules) ? searchRules : [searchRules];
|
|
@@ -828,11 +991,13 @@ const validationRuleParser = {
|
|
|
828
991
|
}
|
|
829
992
|
return [];
|
|
830
993
|
},
|
|
994
|
+
/**
|
|
995
|
+
* Determine if the given attribute has a rule in the given set of available rules.
|
|
996
|
+
*/
|
|
831
997
|
hasRule: function(attribute, searchRules, availableRules) {
|
|
832
998
|
return this.getRule(attribute, searchRules, availableRules).length > 0;
|
|
833
999
|
}
|
|
834
1000
|
};
|
|
835
|
-
|
|
836
1001
|
//#endregion
|
|
837
1002
|
//#region src/validators/validateAttributes.ts
|
|
838
1003
|
var validateAttributes = class {
|
|
@@ -1436,7 +1601,7 @@ var validateAttributes = class {
|
|
|
1436
1601
|
*/
|
|
1437
1602
|
validateUrl(value) {
|
|
1438
1603
|
if (typeof value !== "string") return false;
|
|
1439
|
-
return new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|localhost|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$", "i").test(value);
|
|
1604
|
+
return (/* @__PURE__ */ new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|localhost|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$", "i")).test(value);
|
|
1440
1605
|
}
|
|
1441
1606
|
/**
|
|
1442
1607
|
* Determine if a comparison passes between the given values.
|
|
@@ -1519,7 +1684,6 @@ var validateAttributes = class {
|
|
|
1519
1684
|
return stringValue.split(".")[1]?.length ?? 0;
|
|
1520
1685
|
}
|
|
1521
1686
|
};
|
|
1522
|
-
|
|
1523
1687
|
//#endregion
|
|
1524
1688
|
//#region src/Rules/registerRule.ts
|
|
1525
1689
|
function register(rule, validate, replaceMessage) {
|
|
@@ -1532,17 +1696,20 @@ function register(rule, validate, replaceMessage) {
|
|
|
1532
1696
|
function registerImplicit(rule, validate, replaceMessage) {
|
|
1533
1697
|
if (register(rule, validate, replaceMessage) === true) addImplicitRule(rule);
|
|
1534
1698
|
}
|
|
1535
|
-
|
|
1536
1699
|
//#endregion
|
|
1537
1700
|
//#region src/Plugin.ts
|
|
1538
1701
|
const valueInspectors = [];
|
|
1702
|
+
const validationErrorHooks = [];
|
|
1703
|
+
const validationSuccessHooks = [];
|
|
1539
1704
|
const api = {
|
|
1540
1705
|
registerRule: register,
|
|
1541
1706
|
registerImplicitRule: registerImplicit,
|
|
1542
1707
|
registerValueInspector,
|
|
1543
1708
|
extendTranslations: (translations) => {
|
|
1544
1709
|
Lang.extendTranslationObject(translations);
|
|
1545
|
-
}
|
|
1710
|
+
},
|
|
1711
|
+
onValidationError: registerValidationErrorHook,
|
|
1712
|
+
onValidationSuccess: registerValidationSuccessHook
|
|
1546
1713
|
};
|
|
1547
1714
|
function definePlugin(plugin) {
|
|
1548
1715
|
return plugin;
|
|
@@ -1558,6 +1725,18 @@ function registerValueInspector(inspector) {
|
|
|
1558
1725
|
}
|
|
1559
1726
|
valueInspectors.push(inspector);
|
|
1560
1727
|
}
|
|
1728
|
+
function registerValidationErrorHook(hook) {
|
|
1729
|
+
validationErrorHooks.push(hook);
|
|
1730
|
+
}
|
|
1731
|
+
function registerValidationSuccessHook(hook) {
|
|
1732
|
+
validationSuccessHooks.push(hook);
|
|
1733
|
+
}
|
|
1734
|
+
async function dispatchValidationErrorHooks(validator) {
|
|
1735
|
+
for (const hook of validationErrorHooks) await hook(validator);
|
|
1736
|
+
}
|
|
1737
|
+
async function dispatchValidationSuccessHooks(validator) {
|
|
1738
|
+
for (const hook of validationSuccessHooks) await hook(validator);
|
|
1739
|
+
}
|
|
1561
1740
|
function getValidationValueInspector(value) {
|
|
1562
1741
|
return valueInspectors.find((inspector) => inspector.matches(value));
|
|
1563
1742
|
}
|
|
@@ -1576,7 +1755,6 @@ function getValidationSize(value, hasNumericRule = false) {
|
|
|
1576
1755
|
if (typeof value === "object" && value !== null) return Object.keys(value).length;
|
|
1577
1756
|
return -1;
|
|
1578
1757
|
}
|
|
1579
|
-
|
|
1580
1758
|
//#endregion
|
|
1581
1759
|
//#region src/utilities/general.ts
|
|
1582
1760
|
const implicitRues = [
|
|
@@ -1710,7 +1888,6 @@ function convertValuesToNull(values) {
|
|
|
1710
1888
|
return value;
|
|
1711
1889
|
});
|
|
1712
1890
|
}
|
|
1713
|
-
|
|
1714
1891
|
//#endregion
|
|
1715
1892
|
//#region src/utilities/object.ts
|
|
1716
1893
|
/**
|
|
@@ -1787,7 +1964,6 @@ function deepEqual(firstParam, secondParam) {
|
|
|
1787
1964
|
if (Object.keys(first).length !== Object.keys(second).length) return false;
|
|
1788
1965
|
return Object.entries(first).every(([key, value]) => second[key] === value);
|
|
1789
1966
|
}
|
|
1790
|
-
|
|
1791
1967
|
//#endregion
|
|
1792
1968
|
//#region src/utilities/formatMessages.ts
|
|
1793
1969
|
/**
|
|
@@ -1873,7 +2049,6 @@ function getPrimaryKeyFromPath(path) {
|
|
|
1873
2049
|
if (isNaN(parseInt(key)) === false) return getPrimaryKeyFromPath(splittedPath.join("."));
|
|
1874
2050
|
return key;
|
|
1875
2051
|
}
|
|
1876
|
-
|
|
1877
2052
|
//#endregion
|
|
1878
2053
|
//#region src/validators/errorBag.ts
|
|
1879
2054
|
var ErrorBag = class ErrorBag {
|
|
@@ -1982,7 +2157,6 @@ var ErrorBag = class ErrorBag {
|
|
|
1982
2157
|
return new ErrorBag({ ...this.errors }, { ...this.messages }, this.firstMessage, this.withErrorTypes);
|
|
1983
2158
|
}
|
|
1984
2159
|
};
|
|
1985
|
-
|
|
1986
2160
|
//#endregion
|
|
1987
2161
|
//#region src/Rules/password.ts
|
|
1988
2162
|
var Password$1 = class Password$1 extends IRuleContract {
|
|
@@ -2173,14 +2347,12 @@ var Password$1 = class Password$1 extends IRuleContract {
|
|
|
2173
2347
|
return password instanceof IRuleContract ? password : Password$1.create().min(8);
|
|
2174
2348
|
}
|
|
2175
2349
|
};
|
|
2176
|
-
|
|
2177
2350
|
//#endregion
|
|
2178
2351
|
//#region src/utilities/build.ts
|
|
2179
2352
|
function buildValidationMethodName(rule) {
|
|
2180
2353
|
if (!rule) return rule;
|
|
2181
2354
|
return rule.split("_").map((rule) => `${rule[0].toUpperCase()}${rule.slice(1)}`).join("");
|
|
2182
2355
|
}
|
|
2183
|
-
|
|
2184
2356
|
//#endregion
|
|
2185
2357
|
//#region src/payloads/replaceAttributePayload.ts
|
|
2186
2358
|
var replaceAttributePayload = class {
|
|
@@ -2212,7 +2384,6 @@ var replaceAttributePayload = class {
|
|
|
2212
2384
|
this.getDisplayableAttribute = getDisplayableAttribute;
|
|
2213
2385
|
}
|
|
2214
2386
|
};
|
|
2215
|
-
|
|
2216
2387
|
//#endregion
|
|
2217
2388
|
//#region src/BaseValidator.ts
|
|
2218
2389
|
var BaseValidator = class BaseValidator {
|
|
@@ -2689,11 +2860,9 @@ var BaseValidator = class BaseValidator {
|
|
|
2689
2860
|
return [];
|
|
2690
2861
|
}
|
|
2691
2862
|
};
|
|
2692
|
-
|
|
2693
2863
|
//#endregion
|
|
2694
2864
|
//#region src/Contracts/IDatabaseDriver.ts
|
|
2695
2865
|
var IDatabaseDriver = class {};
|
|
2696
|
-
|
|
2697
2866
|
//#endregion
|
|
2698
2867
|
//#region src/Rules/in.ts
|
|
2699
2868
|
var In = class extends BaseRule {
|
|
@@ -2719,7 +2888,6 @@ var In = class extends BaseRule {
|
|
|
2719
2888
|
return `${this.rule}:${this.values.join(",")}`;
|
|
2720
2889
|
}
|
|
2721
2890
|
};
|
|
2722
|
-
|
|
2723
2891
|
//#endregion
|
|
2724
2892
|
//#region src/Rules/notIn.ts
|
|
2725
2893
|
var NotIn = class extends BaseRule {
|
|
@@ -2745,7 +2913,6 @@ var NotIn = class extends BaseRule {
|
|
|
2745
2913
|
return `${this.rule}:${this.values.join(",")}`;
|
|
2746
2914
|
}
|
|
2747
2915
|
};
|
|
2748
|
-
|
|
2749
2916
|
//#endregion
|
|
2750
2917
|
//#region src/Rules/regex.ts
|
|
2751
2918
|
var Regex = class extends IRuleContract {
|
|
@@ -2771,7 +2938,6 @@ var Regex = class extends IRuleContract {
|
|
|
2771
2938
|
return this.trans("not_regex");
|
|
2772
2939
|
}
|
|
2773
2940
|
};
|
|
2774
|
-
|
|
2775
2941
|
//#endregion
|
|
2776
2942
|
//#region src/Rules/requiredIf.ts
|
|
2777
2943
|
var RequiredIf = class extends BaseRule {
|
|
@@ -2794,7 +2960,6 @@ var RequiredIf = class extends BaseRule {
|
|
|
2794
2960
|
return this.condition ? "required" : "";
|
|
2795
2961
|
}
|
|
2796
2962
|
};
|
|
2797
|
-
|
|
2798
2963
|
//#endregion
|
|
2799
2964
|
//#region src/rule.ts
|
|
2800
2965
|
function requiredIf(callback) {
|
|
@@ -2812,32 +2977,29 @@ function regex(value) {
|
|
|
2812
2977
|
function notRegex(value) {
|
|
2813
2978
|
return new Regex(value, false);
|
|
2814
2979
|
}
|
|
2815
|
-
|
|
2816
2980
|
//#endregion
|
|
2817
2981
|
//#region src/Core.ts
|
|
2818
2982
|
var Password = class extends Password$1 {};
|
|
2819
2983
|
function make(data = {}, rules = {}, customMessages = {}, customAttributes = {}) {
|
|
2820
2984
|
return new BaseValidator(data, rules, customMessages, customAttributes);
|
|
2821
2985
|
}
|
|
2822
|
-
|
|
2823
2986
|
//#endregion
|
|
2824
2987
|
//#region src/Rules/IImplicitRule.ts
|
|
2825
2988
|
var IImplicitRule = class extends IRuleContract {
|
|
2826
2989
|
__isImplicitRule = true;
|
|
2827
2990
|
};
|
|
2828
|
-
|
|
2829
2991
|
//#endregion
|
|
2830
2992
|
//#region src/ImplicitRule.ts
|
|
2831
2993
|
var ImplicitRule = class extends IImplicitRule {
|
|
2832
2994
|
rules = [];
|
|
2833
2995
|
};
|
|
2834
|
-
|
|
2835
2996
|
//#endregion
|
|
2836
2997
|
//#region src/Providers/ValidationServiceProvider.ts
|
|
2837
2998
|
/**
|
|
2838
2999
|
* Service provider for Validation utilities
|
|
2839
3000
|
*/
|
|
2840
3001
|
var ValidationServiceProvider = class {
|
|
3002
|
+
app;
|
|
2841
3003
|
registeredCommands;
|
|
2842
3004
|
static priority = 895;
|
|
2843
3005
|
constructor(app) {
|
|
@@ -2852,7 +3014,6 @@ var ValidationServiceProvider = class {
|
|
|
2852
3014
|
*/
|
|
2853
3015
|
boot() {}
|
|
2854
3016
|
};
|
|
2855
|
-
|
|
2856
3017
|
//#endregion
|
|
2857
3018
|
//#region src/ValidationRule.ts
|
|
2858
3019
|
var ValidationRule = class extends IRuleContract {
|
|
@@ -2873,7 +3034,6 @@ var ValidationRule = class extends IRuleContract {
|
|
|
2873
3034
|
return this.passing;
|
|
2874
3035
|
}
|
|
2875
3036
|
};
|
|
2876
|
-
|
|
2877
3037
|
//#endregion
|
|
2878
3038
|
//#region src/Rules/ExtendedRules.ts
|
|
2879
3039
|
dayjs.default.extend(dayjs_plugin_customParseFormat_js.default);
|
|
@@ -2983,7 +3143,6 @@ var ExtendedRules = class extends ValidationRule {
|
|
|
2983
3143
|
];
|
|
2984
3144
|
validate() {}
|
|
2985
3145
|
};
|
|
2986
|
-
|
|
2987
3146
|
//#endregion
|
|
2988
3147
|
//#region src/utilities/MessageBag.ts
|
|
2989
3148
|
var MessageBag = class {
|
|
@@ -3197,7 +3356,6 @@ var MessageBag = class {
|
|
|
3197
3356
|
return this.toJson();
|
|
3198
3357
|
}
|
|
3199
3358
|
};
|
|
3200
|
-
|
|
3201
3359
|
//#endregion
|
|
3202
3360
|
//#region src/Validator.ts
|
|
3203
3361
|
var Validator = class Validator {
|
|
@@ -3275,6 +3433,8 @@ var Validator = class Validator {
|
|
|
3275
3433
|
if (this.executed) return this._errors.isEmpty();
|
|
3276
3434
|
const exec = await this.execute();
|
|
3277
3435
|
for (const after of this.#after) after();
|
|
3436
|
+
if (exec.passing) await dispatchValidationSuccessHooks(this);
|
|
3437
|
+
else await dispatchValidationErrorHooks(this);
|
|
3278
3438
|
return exec.passing;
|
|
3279
3439
|
}
|
|
3280
3440
|
/**
|
|
@@ -3480,7 +3640,6 @@ var Validator = class Validator {
|
|
|
3480
3640
|
return this;
|
|
3481
3641
|
}
|
|
3482
3642
|
};
|
|
3483
|
-
|
|
3484
3643
|
//#endregion
|
|
3485
3644
|
//#region src/ValidationException.ts
|
|
3486
3645
|
var ValidationException = class ValidationException extends Error {
|
|
@@ -3568,7 +3727,6 @@ var ValidationException = class ValidationException extends Error {
|
|
|
3568
3727
|
return this.response;
|
|
3569
3728
|
}
|
|
3570
3729
|
};
|
|
3571
|
-
|
|
3572
3730
|
//#endregion
|
|
3573
3731
|
exports.BaseRule = BaseRule;
|
|
3574
3732
|
exports.BaseValidator = BaseValidator;
|
|
@@ -3594,6 +3752,8 @@ exports.deepFind = deepFind;
|
|
|
3594
3752
|
exports.deepFindMessage = deepFindMessage;
|
|
3595
3753
|
exports.deepSet = deepSet;
|
|
3596
3754
|
exports.definePlugin = definePlugin;
|
|
3755
|
+
exports.dispatchValidationErrorHooks = dispatchValidationErrorHooks;
|
|
3756
|
+
exports.dispatchValidationSuccessHooks = dispatchValidationSuccessHooks;
|
|
3597
3757
|
exports.dotify = dotify;
|
|
3598
3758
|
exports.getFormattedAttribute = getFormattedAttribute;
|
|
3599
3759
|
exports.getKeyCombinations = getKeyCombinations;
|
|
@@ -3618,6 +3778,8 @@ exports.plural = plural;
|
|
|
3618
3778
|
exports.regex = regex;
|
|
3619
3779
|
exports.register = register;
|
|
3620
3780
|
exports.registerImplicit = registerImplicit;
|
|
3781
|
+
exports.registerValidationErrorHook = registerValidationErrorHook;
|
|
3782
|
+
exports.registerValidationSuccessHook = registerValidationSuccessHook;
|
|
3621
3783
|
exports.registerValueInspector = registerValueInspector;
|
|
3622
3784
|
exports.requiredIf = requiredIf;
|
|
3623
3785
|
exports.ruleIn = ruleIn;
|
|
@@ -3627,4 +3789,4 @@ exports.sameType = sameType;
|
|
|
3627
3789
|
exports.toDate = toDate;
|
|
3628
3790
|
exports.toSnakeCase = toSnakeCase;
|
|
3629
3791
|
exports.usePlugin = usePlugin;
|
|
3630
|
-
exports.useValidatorContext = useValidatorContext;
|
|
3792
|
+
exports.useValidatorContext = useValidatorContext;
|