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.js
CHANGED
|
@@ -3,7 +3,6 @@ import { domainToASCII } from "node:url";
|
|
|
3
3
|
import { isIP } from "node:net";
|
|
4
4
|
import customParseFormat from "dayjs/plugin/customParseFormat.js";
|
|
5
5
|
import dayjs from "dayjs";
|
|
6
|
-
|
|
7
6
|
//#region src/Context.ts
|
|
8
7
|
const validatorContextStorage = new AsyncLocalStorage();
|
|
9
8
|
/**
|
|
@@ -42,255 +41,244 @@ function runWithValidatorContext(context, callback) {
|
|
|
42
41
|
...context
|
|
43
42
|
}, callback);
|
|
44
43
|
}
|
|
45
|
-
|
|
46
44
|
//#endregion
|
|
47
45
|
//#region src/Rules/baseRule.ts
|
|
48
46
|
var BaseRule = class {};
|
|
49
|
-
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/locales/en.ts
|
|
52
|
-
var en_default = {
|
|
53
|
-
accepted: "The :attribute must be accepted.",
|
|
54
|
-
accepted_if: "The :attribute must be accepted when :other is :value.",
|
|
55
|
-
after: "The :attribute must be a date after :date.",
|
|
56
|
-
after_or_equal: "The :attribute must be a date after or equal to :date.",
|
|
57
|
-
alpha: "The :attribute must only contain letters.",
|
|
58
|
-
alpha_dash: "The :attribute must only contain at least one letter or one number, and optionally dashes and underscores.",
|
|
59
|
-
alpha_num: "The :attribute must only contain letters and numbers.",
|
|
60
|
-
array: "The :attribute must be an array.",
|
|
61
|
-
array_unique: "The :attribute must be an array with unique values.",
|
|
62
|
-
before: "The :attribute must be a date before :date.",
|
|
63
|
-
before_or_equal: "The :attribute must be a date before or equal to :date.",
|
|
64
|
-
between: {
|
|
65
|
-
number: "The :attribute must be between :min and :max.",
|
|
66
|
-
string: "The :attribute must be between :min and :max characters.",
|
|
67
|
-
array: "The :attribute must have between :min and :max items.",
|
|
68
|
-
object: "The :attribute must have between :min and :max items."
|
|
69
|
-
},
|
|
70
|
-
boolean: "The :attribute field must be true or false.",
|
|
71
|
-
confirmed: "The :attribute confirmation does not match.",
|
|
72
|
-
date: "The :attribute is not a valid date.",
|
|
73
|
-
datetime: "The :attribute must be a valid date matching the format :format.",
|
|
74
|
-
date_equals: "The :attribute must be a date equal to :date.",
|
|
75
|
-
declined: "The :attribute must be declined.",
|
|
76
|
-
declined_if: "The :attribute must be declined when :other is :value.",
|
|
77
|
-
different: "The :attribute and :other must be different.",
|
|
78
|
-
distinct: "The :attribute field has a duplicate value.",
|
|
79
|
-
digits: "The :attribute must be :digits digits.",
|
|
80
|
-
digits_between: "The :attribute must be between :min and :max digits.",
|
|
81
|
-
email: "The :attribute must be a valid email address.",
|
|
82
|
-
ends_with: "The :attribute must end with one of the following: :values.",
|
|
83
|
-
filled: "The :attribute field must have a value.",
|
|
84
|
-
exists: "The selected :attribute is invalid.",
|
|
85
|
-
gt: {
|
|
86
|
-
number: "The :attribute must be greater than :value.",
|
|
87
|
-
string: "The :attribute must be greater than :value characters.",
|
|
88
|
-
array: "The :attribute must have more than :value items.",
|
|
89
|
-
object: "The :attribute must have more than :value items."
|
|
90
|
-
},
|
|
91
|
-
gte: {
|
|
92
|
-
number: "The :attribute must be greater than or equal :value.",
|
|
93
|
-
string: "The :attribute must be greater than or equal :value characters.",
|
|
94
|
-
array: "The :attribute must have :value items or more.",
|
|
95
|
-
object: "The :attribute must have :value items or more."
|
|
96
|
-
},
|
|
97
|
-
hex: "The :attribute must be a valid hexadecimal color.",
|
|
98
|
-
in: "The :attribute must be one of the following :values.",
|
|
99
|
-
includes: "The :attribute must include one of the following values: :values.",
|
|
100
|
-
integer: "The :attribute must be an integer.",
|
|
101
|
-
ip: "The :attribute must be a valid IP address.",
|
|
102
|
-
ipv4: "The :attribute must be a valid IPv4 address.",
|
|
103
|
-
ipv6: "The :attribute must be a valid IPv6 address.",
|
|
104
|
-
json: "The :attribute must be a valid JSON string.",
|
|
105
|
-
lt: {
|
|
106
|
-
number: "The :attribute must be less than :value.",
|
|
107
|
-
string: "The :attribute must be less than :value characters.",
|
|
108
|
-
array: "The :attribute must have less than :value items.",
|
|
109
|
-
object: "The :attribute must have less than :value items."
|
|
110
|
-
},
|
|
111
|
-
lte: {
|
|
112
|
-
number: "The :attribute must be less than or equal :value.",
|
|
113
|
-
string: "The :attribute must be less than or equal :value characters.",
|
|
114
|
-
array: "The :attribute must have :value items or less.",
|
|
115
|
-
object: "The :attribute must have :value items or less."
|
|
116
|
-
},
|
|
117
|
-
max: {
|
|
118
|
-
number: "The :attribute must not be greater than :max.",
|
|
119
|
-
string: "The :attribute must not be greater than :max characters.",
|
|
120
|
-
array: "The :attribute must not have more than :max items.",
|
|
121
|
-
object: "The :attribute must not have more than :max items."
|
|
122
|
-
},
|
|
123
|
-
min: {
|
|
124
|
-
number: "The :attribute must be at least :min.",
|
|
125
|
-
string: "The :attribute must be at least :min characters.",
|
|
126
|
-
array: "The :attribute must have at least :min items.",
|
|
127
|
-
object: "The :attribute must have at least :min items."
|
|
128
|
-
},
|
|
129
|
-
mac_address: "The :attribute must be a valid MAC address.",
|
|
130
|
-
not_in: "The selected :attribute is invalid.",
|
|
131
|
-
not_regex: "The :attribute format is invalid.",
|
|
132
|
-
not_includes: "The :attribute must not include any of the following values: :values.",
|
|
133
|
-
numeric: "The :attribute must be a number.",
|
|
134
|
-
object: "The :attribute must be an object.",
|
|
135
|
-
password: {
|
|
136
|
-
letter: "The :attribute must contain at least one letter.",
|
|
137
|
-
letters: "The :attribute must contain at least :amount letters.",
|
|
138
|
-
lower_case: "The :attribute must contain at least one lowercase letter.",
|
|
139
|
-
lower_cases: "The :attribute must contain at least :amount lowercase letters.",
|
|
140
|
-
number: "The :attribute must contain at least one number.",
|
|
141
|
-
numbers: "The :attribute must contain at least :amount numbers.",
|
|
142
|
-
symbol: "The :attribute must contain at least one symbol.",
|
|
143
|
-
symbols: "The :attribute must contain at least :amount symbols.",
|
|
144
|
-
upper_case: "The :attribute must contain at least one uppercase letter.",
|
|
145
|
-
upper_cases: "The :attribute must contain at least :amount uppercase letters."
|
|
146
|
-
},
|
|
147
|
-
present: "The :attribute field must be present.",
|
|
148
|
-
presentsame: "The :attribute field must be present.",
|
|
149
|
-
prohibited: "The :attribute field is prohibited.",
|
|
150
|
-
prohibited_unless: "The :attribute field is prohibited unless :other is in :values.",
|
|
151
|
-
prohibits: "The :attribute field prohibits :values from being present.",
|
|
152
|
-
regex: "The :attribute format is invalid.",
|
|
153
|
-
required: "The :attribute field is required.",
|
|
154
|
-
required_if: "The :attribute field is required when :other is :value.",
|
|
155
|
-
required_unless: "The :attribute field is required unless :other is in :values.",
|
|
156
|
-
required_with: "The :attribute field is required when :values is present.",
|
|
157
|
-
required_with_all: "The :attribute field is required when :values are present.",
|
|
158
|
-
required_without: "The :attribute field is required when :values is not present.",
|
|
159
|
-
required_without_all: "The :attribute field is required when none of :values are present.",
|
|
160
|
-
starts_with: "The :attribute must start with one of the following: :values.",
|
|
161
|
-
same: "The :attribute and :other must match.",
|
|
162
|
-
size: {
|
|
163
|
-
number: "The :attribute must be :size.",
|
|
164
|
-
string: "The :attribute must be :size characters.",
|
|
165
|
-
array: "The :attribute must contain :size items.",
|
|
166
|
-
object: "The :attribute must contain :size items."
|
|
167
|
-
},
|
|
168
|
-
string: "The :attribute must be a string.",
|
|
169
|
-
timezone: "The :attribute must be a valid timezone.",
|
|
170
|
-
unique: "The :attribute has already been taken.",
|
|
171
|
-
url: "The :attribute must have a valid URL format.",
|
|
172
|
-
multiple_of: "The :attribute must be a multiple of :value."
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
//#endregion
|
|
176
|
-
//#region src/locales/ar.ts
|
|
177
|
-
var ar_default = {
|
|
178
|
-
accepted: "يجب قبول الحقل :attribute",
|
|
179
|
-
accepted_if: "الحقل :attribute مقبول في حال ما إذا كان :other يساوي :value.",
|
|
180
|
-
after: "يجب على الحقل :attribute أن يكون تاريخا لاحقا للتاريخ :date.",
|
|
181
|
-
after_or_equal: "الحقل :attribute يجب أن يكون تاريخاً لاحقاً أو مطابقاً للتاريخ :date.",
|
|
182
|
-
alpha: "يجب أن لا يحتوي الحقل :attribute سوى على حروف",
|
|
183
|
-
alpha_dash: "يجب أن يحتوي الحقل :attribute على حرف واحد أو رقم واحد على الأقل، بالإضافة إلى شرطات وشرطات سفلية بشكل اختياري",
|
|
184
|
-
alpha_num: "يجب أن يحتوي :attribute على حروف وأرقام فقط",
|
|
185
|
-
array: "يجب أن يكون الحقل :attribute ًمصفوفة",
|
|
186
|
-
before: "يجب على الحقل :attribute أن يكون تاريخا سابقا للتاريخ :date.",
|
|
187
|
-
before_or_equal: "الحقل :attribute يجب أن يكون تاريخا سابقا أو مطابقا للتاريخ :date",
|
|
188
|
-
between: {
|
|
189
|
-
number: "يجب أن تكون قيمة :attribute بين :min و :max.",
|
|
190
|
-
string: "يجب أن يكون عدد حروف النّص :attribute بين :min و :max",
|
|
191
|
-
array: "يجب أن يحتوي :attribute على عدد من العناصر بين :min و :max",
|
|
192
|
-
object: "يجب أن يحتوي :attribute على عدد من العناصر بين :min و :max"
|
|
193
|
-
},
|
|
194
|
-
boolean: "يجب أن تكون قيمة الحقل :attribute إما true أو false",
|
|
195
|
-
confirmed: "حقل التأكيد غير مُطابق للحقل :attribute",
|
|
196
|
-
date: "الحقل :attribute ليس تاريخًا صحيحًا",
|
|
197
|
-
datetime: "الحقل :attribute يجب أن يكون تاريخًا صالحًا يطابق الصيغة :format.",
|
|
198
|
-
date_equals: "لا يساوي الحقل :attribute مع :date.",
|
|
199
|
-
declined: "يجب رفض الحقل :attribute",
|
|
200
|
-
declined_if: "الحقل :attribute مرفوض في حال ما إذا كان :other يساوي :value.",
|
|
201
|
-
different: "يجب أن يكون الحقلان :attribute و :other مُختلفان",
|
|
202
|
-
digits: "يجب أن يحتوي الحقل :attribute على :digits رقمًا/أرقام",
|
|
203
|
-
digits_between: "يجب أن يحتوي الحقل :attribute بين :min و :max رقمًا/أرقام",
|
|
204
|
-
email: "يجب أن يكون :attribute عنوان بريد إلكتروني صحيح البُنية",
|
|
205
|
-
ends_with: "حقل :attribute يجب ان ينتهي بأحد القيم التالية :value.",
|
|
206
|
-
exists: "الحقل :attribute غير موجود",
|
|
207
|
-
gt: {
|
|
208
|
-
number: "حقل :attribute يجب ان يكون اكبر من :value.",
|
|
209
|
-
string: "حقل :attribute يجب ان يكون اكبر من :value حروفٍ/حرفًا.",
|
|
210
|
-
array: "حقل :attribute يجب ان يحتوي علي اكثر من :value عناصر/عنصر.",
|
|
211
|
-
object: "حقل :attribute يجب ان يحتوي علي اكثر من :value عناصر/عنصر."
|
|
212
|
-
},
|
|
213
|
-
gte: {
|
|
214
|
-
number: "حقل :attribute يجب ان يكون اكبر من او يساوي :value.",
|
|
215
|
-
string: "حقل :attribute يجب ان يكون اكبر من او يساوي :value حروفٍ/حرفًا.",
|
|
216
|
-
array: "حقل :attribute يجب ان يحتوي علي :value عناصر/عنصر او اكثر.",
|
|
217
|
-
object: "حقل :attribute يجب ان يحتوي علي :value عناصر/عنصر او اكثر."
|
|
218
|
-
},
|
|
219
|
-
hex: "الحقل :attribute يجب أن يكون لونًا سداسيًا صالحًا.",
|
|
220
|
-
in: "الحقل :attribute غير صالح",
|
|
221
|
-
includes: "الحقل :attribute يجب أن يحتوي على أحد القيم التالية: :values.",
|
|
222
|
-
integer: "يجب أن يكون الحقل :attribute عددًا صحيحًا",
|
|
223
|
-
json: "يجب أن يكون الحقل :attribute نصا من نوع JSON.",
|
|
224
|
-
lt: {
|
|
225
|
-
number: "حقل :attribute يجب ان يكون اقل من :value.",
|
|
226
|
-
string: "حقل :attribute يجب ان يكون اقل من :value حروفٍ/حرفًا.",
|
|
227
|
-
array: "حقل :attribute يجب ان يحتوي علي اقل من :value عناصر/عنصر.",
|
|
228
|
-
object: "حقل :attribute يجب ان يحتوي علي اقل من :value عناصر/عنصر."
|
|
229
|
-
},
|
|
230
|
-
lte: {
|
|
231
|
-
number: "حقل :attribute يجب ان يكون اقل من او يساوي :value.",
|
|
232
|
-
string: "حقل :attribute يجب ان يكون اقل من او يساوي :value حروفٍ/حرفًا.",
|
|
233
|
-
array: "حقل :attribute يجب ان يحتوي علي اكثر من :value عناصر/عنصر.",
|
|
234
|
-
object: "حقل :attribute يجب ان يحتوي علي اكثر من :value عناصر/عنصر."
|
|
235
|
-
},
|
|
236
|
-
max: {
|
|
237
|
-
number: "يجب أن تكون قيمة الحقل :attribute مساوية أو أصغر لـ :max.",
|
|
238
|
-
string: "يجب أن لا يتجاوز طول نص :attribute :max حروفٍ/حرفًا",
|
|
239
|
-
array: "يجب أن لا يحتوي الحقل :attribute على أكثر من :max عناصر/عنصر.",
|
|
240
|
-
object: "يجب أن لا يحتوي الحقل :attribute على أكثر من :max عناصر/عنصر."
|
|
241
|
-
},
|
|
242
|
-
min: {
|
|
243
|
-
number: "يجب أن تكون قيمة الحقل :attribute مساوية أو أكبر لـ :min.",
|
|
244
|
-
string: "يجب أن يكون طول نص :attribute على الأقل :min حروفٍ/حرفًا",
|
|
245
|
-
array: "يجب أن يحتوي الحقل :attribute على الأقل على :min عُنصرًا/عناصر",
|
|
246
|
-
object: "يجب أن يحتوي الحقل :attribute على الأقل على :min عُنصرًا/عناصر"
|
|
247
|
-
},
|
|
248
|
-
not_in: "الحقل :attribute غير صالح",
|
|
249
|
-
not_regex: "الحقل :attribute نوعه غير صالح",
|
|
250
|
-
not_includes: "الحقل :attribute يجب ألا يحتوي على أي من القيم التالية: :values.",
|
|
251
|
-
numeric: "يجب على الحقل :attribute أن يكون رقمًا",
|
|
252
|
-
object: "الحقل :attribute يجب ان يكون من نوع object.",
|
|
253
|
-
password: {
|
|
254
|
-
letter: "يجب ان يشمل حقل :attribute على حرف واحد على الاقل.",
|
|
255
|
-
letters: "يجب ان يشمل حقل :attribute على عدد :amount حروف على الاقل.",
|
|
256
|
-
lower_case: "يجب ان يشمل حقل :attribute على حرف واحد من صيغة صغيرة على الاقل.",
|
|
257
|
-
lower_cases: "يجب ان يشمل حقل :attribute على عدد :amount حروف صغيرة على الاقل.",
|
|
258
|
-
number: "يجب ان يشمل حقل :attribute على رقم واحد على الاقل.",
|
|
259
|
-
numbers: "يجب ان يشمل حقل :attribute على عدد :amount من الارقام على الاقل.",
|
|
260
|
-
symbol: "يجب ان يشمل حقل :attribute على رمز واحد على الاقل.",
|
|
261
|
-
symbols: "يجب ان يشمل حقل :attribute على عدد :amount رموز على الاقل.",
|
|
262
|
-
upper_case: "يجب ان يشمل حقل :attribute على حرف كبير واحد على الاقل.",
|
|
263
|
-
upper_cases: "يجب ان يشمل حقل :attribute على عدد :amount حروف كبيرة على الاقل."
|
|
264
|
-
},
|
|
265
|
-
present: "يجب تقديم الحقل :attribute",
|
|
266
|
-
regex: "صيغة الحقل :attribute .غير صحيحة",
|
|
267
|
-
required: "الحقل :attribute مطلوب.",
|
|
268
|
-
required_if: "الحقل :attribute مطلوب في حال ما إذا كان :other يساوي :value.",
|
|
269
|
-
required_unless: "الحقل :attribute مطلوب في حال ما لم يكن :other يساوي :values.",
|
|
270
|
-
required_with: "الحقل :attribute اجباري إذا توفّر :values.",
|
|
271
|
-
required_with_all: "الحقل :attribute اجباري إذا توفّر :values.",
|
|
272
|
-
required_without: "الحقل :attribute اجباري إذا لم يتوفّر :values.",
|
|
273
|
-
required_without_all: "الحقل :attribute اجباري إذا لم يتوفّر :values.",
|
|
274
|
-
starts_with: "الحقل :attribute يجب ان يبدأ بأحد القيم التالية: :values.",
|
|
275
|
-
same: "يجب أن يتطابق الحقل :attribute مع :other",
|
|
276
|
-
size: {
|
|
277
|
-
number: "يجب أن تكون قيمة الحقل :attribute مساوية لـ :size",
|
|
278
|
-
string: "يجب أن يحتوي النص :attribute على :size حروفٍ/حرفًا بالظبط",
|
|
279
|
-
array: "يجب أن يحتوي الحقل :attribute على :size عنصرٍ/عناصر بالظبط",
|
|
280
|
-
object: "يجب أن يحتوي الحقل :attribute على :size عنصرٍ/عناصر بالظبط"
|
|
281
|
-
},
|
|
282
|
-
string: "يجب أن يكون الحقل :attribute نصآ.",
|
|
283
|
-
unique: "الحقل :attribute مستخدم بالفعل.",
|
|
284
|
-
url: "صيغة الرابط :attribute غير صحيحة"
|
|
285
|
-
};
|
|
286
|
-
|
|
287
47
|
//#endregion
|
|
288
48
|
//#region src/locales/index.ts
|
|
289
49
|
var locales_default = {
|
|
290
|
-
en:
|
|
291
|
-
|
|
50
|
+
en: {
|
|
51
|
+
accepted: "The :attribute must be accepted.",
|
|
52
|
+
accepted_if: "The :attribute must be accepted when :other is :value.",
|
|
53
|
+
after: "The :attribute must be a date after :date.",
|
|
54
|
+
after_or_equal: "The :attribute must be a date after or equal to :date.",
|
|
55
|
+
alpha: "The :attribute must only contain letters.",
|
|
56
|
+
alpha_dash: "The :attribute must only contain at least one letter or one number, and optionally dashes and underscores.",
|
|
57
|
+
alpha_num: "The :attribute must only contain letters and numbers.",
|
|
58
|
+
array: "The :attribute must be an array.",
|
|
59
|
+
array_unique: "The :attribute must be an array with unique values.",
|
|
60
|
+
before: "The :attribute must be a date before :date.",
|
|
61
|
+
before_or_equal: "The :attribute must be a date before or equal to :date.",
|
|
62
|
+
between: {
|
|
63
|
+
number: "The :attribute must be between :min and :max.",
|
|
64
|
+
string: "The :attribute must be between :min and :max characters.",
|
|
65
|
+
array: "The :attribute must have between :min and :max items.",
|
|
66
|
+
object: "The :attribute must have between :min and :max items."
|
|
67
|
+
},
|
|
68
|
+
boolean: "The :attribute field must be true or false.",
|
|
69
|
+
confirmed: "The :attribute confirmation does not match.",
|
|
70
|
+
date: "The :attribute is not a valid date.",
|
|
71
|
+
datetime: "The :attribute must be a valid date matching the format :format.",
|
|
72
|
+
date_equals: "The :attribute must be a date equal to :date.",
|
|
73
|
+
declined: "The :attribute must be declined.",
|
|
74
|
+
declined_if: "The :attribute must be declined when :other is :value.",
|
|
75
|
+
different: "The :attribute and :other must be different.",
|
|
76
|
+
distinct: "The :attribute field has a duplicate value.",
|
|
77
|
+
digits: "The :attribute must be :digits digits.",
|
|
78
|
+
digits_between: "The :attribute must be between :min and :max digits.",
|
|
79
|
+
email: "The :attribute must be a valid email address.",
|
|
80
|
+
ends_with: "The :attribute must end with one of the following: :values.",
|
|
81
|
+
filled: "The :attribute field must have a value.",
|
|
82
|
+
exists: "The selected :attribute is invalid.",
|
|
83
|
+
gt: {
|
|
84
|
+
number: "The :attribute must be greater than :value.",
|
|
85
|
+
string: "The :attribute must be greater than :value characters.",
|
|
86
|
+
array: "The :attribute must have more than :value items.",
|
|
87
|
+
object: "The :attribute must have more than :value items."
|
|
88
|
+
},
|
|
89
|
+
gte: {
|
|
90
|
+
number: "The :attribute must be greater than or equal :value.",
|
|
91
|
+
string: "The :attribute must be greater than or equal :value characters.",
|
|
92
|
+
array: "The :attribute must have :value items or more.",
|
|
93
|
+
object: "The :attribute must have :value items or more."
|
|
94
|
+
},
|
|
95
|
+
hex: "The :attribute must be a valid hexadecimal color.",
|
|
96
|
+
in: "The :attribute must be one of the following :values.",
|
|
97
|
+
includes: "The :attribute must include one of the following values: :values.",
|
|
98
|
+
integer: "The :attribute must be an integer.",
|
|
99
|
+
ip: "The :attribute must be a valid IP address.",
|
|
100
|
+
ipv4: "The :attribute must be a valid IPv4 address.",
|
|
101
|
+
ipv6: "The :attribute must be a valid IPv6 address.",
|
|
102
|
+
json: "The :attribute must be a valid JSON string.",
|
|
103
|
+
lt: {
|
|
104
|
+
number: "The :attribute must be less than :value.",
|
|
105
|
+
string: "The :attribute must be less than :value characters.",
|
|
106
|
+
array: "The :attribute must have less than :value items.",
|
|
107
|
+
object: "The :attribute must have less than :value items."
|
|
108
|
+
},
|
|
109
|
+
lte: {
|
|
110
|
+
number: "The :attribute must be less than or equal :value.",
|
|
111
|
+
string: "The :attribute must be less than or equal :value characters.",
|
|
112
|
+
array: "The :attribute must have :value items or less.",
|
|
113
|
+
object: "The :attribute must have :value items or less."
|
|
114
|
+
},
|
|
115
|
+
max: {
|
|
116
|
+
number: "The :attribute must not be greater than :max.",
|
|
117
|
+
string: "The :attribute must not be greater than :max characters.",
|
|
118
|
+
array: "The :attribute must not have more than :max items.",
|
|
119
|
+
object: "The :attribute must not have more than :max items."
|
|
120
|
+
},
|
|
121
|
+
min: {
|
|
122
|
+
number: "The :attribute must be at least :min.",
|
|
123
|
+
string: "The :attribute must be at least :min characters.",
|
|
124
|
+
array: "The :attribute must have at least :min items.",
|
|
125
|
+
object: "The :attribute must have at least :min items."
|
|
126
|
+
},
|
|
127
|
+
mac_address: "The :attribute must be a valid MAC address.",
|
|
128
|
+
not_in: "The selected :attribute is invalid.",
|
|
129
|
+
not_regex: "The :attribute format is invalid.",
|
|
130
|
+
not_includes: "The :attribute must not include any of the following values: :values.",
|
|
131
|
+
numeric: "The :attribute must be a number.",
|
|
132
|
+
object: "The :attribute must be an object.",
|
|
133
|
+
password: {
|
|
134
|
+
letter: "The :attribute must contain at least one letter.",
|
|
135
|
+
letters: "The :attribute must contain at least :amount letters.",
|
|
136
|
+
lower_case: "The :attribute must contain at least one lowercase letter.",
|
|
137
|
+
lower_cases: "The :attribute must contain at least :amount lowercase letters.",
|
|
138
|
+
number: "The :attribute must contain at least one number.",
|
|
139
|
+
numbers: "The :attribute must contain at least :amount numbers.",
|
|
140
|
+
symbol: "The :attribute must contain at least one symbol.",
|
|
141
|
+
symbols: "The :attribute must contain at least :amount symbols.",
|
|
142
|
+
upper_case: "The :attribute must contain at least one uppercase letter.",
|
|
143
|
+
upper_cases: "The :attribute must contain at least :amount uppercase letters."
|
|
144
|
+
},
|
|
145
|
+
present: "The :attribute field must be present.",
|
|
146
|
+
presentsame: "The :attribute field must be present.",
|
|
147
|
+
prohibited: "The :attribute field is prohibited.",
|
|
148
|
+
prohibited_unless: "The :attribute field is prohibited unless :other is in :values.",
|
|
149
|
+
prohibits: "The :attribute field prohibits :values from being present.",
|
|
150
|
+
regex: "The :attribute format is invalid.",
|
|
151
|
+
required: "The :attribute field is required.",
|
|
152
|
+
required_if: "The :attribute field is required when :other is :value.",
|
|
153
|
+
required_unless: "The :attribute field is required unless :other is in :values.",
|
|
154
|
+
required_with: "The :attribute field is required when :values is present.",
|
|
155
|
+
required_with_all: "The :attribute field is required when :values are present.",
|
|
156
|
+
required_without: "The :attribute field is required when :values is not present.",
|
|
157
|
+
required_without_all: "The :attribute field is required when none of :values are present.",
|
|
158
|
+
starts_with: "The :attribute must start with one of the following: :values.",
|
|
159
|
+
same: "The :attribute and :other must match.",
|
|
160
|
+
size: {
|
|
161
|
+
number: "The :attribute must be :size.",
|
|
162
|
+
string: "The :attribute must be :size characters.",
|
|
163
|
+
array: "The :attribute must contain :size items.",
|
|
164
|
+
object: "The :attribute must contain :size items."
|
|
165
|
+
},
|
|
166
|
+
string: "The :attribute must be a string.",
|
|
167
|
+
timezone: "The :attribute must be a valid timezone.",
|
|
168
|
+
unique: "The :attribute has already been taken.",
|
|
169
|
+
url: "The :attribute must have a valid URL format.",
|
|
170
|
+
multiple_of: "The :attribute must be a multiple of :value."
|
|
171
|
+
},
|
|
172
|
+
ar: {
|
|
173
|
+
accepted: "يجب قبول الحقل :attribute",
|
|
174
|
+
accepted_if: "الحقل :attribute مقبول في حال ما إذا كان :other يساوي :value.",
|
|
175
|
+
after: "يجب على الحقل :attribute أن يكون تاريخا لاحقا للتاريخ :date.",
|
|
176
|
+
after_or_equal: "الحقل :attribute يجب أن يكون تاريخاً لاحقاً أو مطابقاً للتاريخ :date.",
|
|
177
|
+
alpha: "يجب أن لا يحتوي الحقل :attribute سوى على حروف",
|
|
178
|
+
alpha_dash: "يجب أن يحتوي الحقل :attribute على حرف واحد أو رقم واحد على الأقل، بالإضافة إلى شرطات وشرطات سفلية بشكل اختياري",
|
|
179
|
+
alpha_num: "يجب أن يحتوي :attribute على حروف وأرقام فقط",
|
|
180
|
+
array: "يجب أن يكون الحقل :attribute ًمصفوفة",
|
|
181
|
+
before: "يجب على الحقل :attribute أن يكون تاريخا سابقا للتاريخ :date.",
|
|
182
|
+
before_or_equal: "الحقل :attribute يجب أن يكون تاريخا سابقا أو مطابقا للتاريخ :date",
|
|
183
|
+
between: {
|
|
184
|
+
number: "يجب أن تكون قيمة :attribute بين :min و :max.",
|
|
185
|
+
string: "يجب أن يكون عدد حروف النّص :attribute بين :min و :max",
|
|
186
|
+
array: "يجب أن يحتوي :attribute على عدد من العناصر بين :min و :max",
|
|
187
|
+
object: "يجب أن يحتوي :attribute على عدد من العناصر بين :min و :max"
|
|
188
|
+
},
|
|
189
|
+
boolean: "يجب أن تكون قيمة الحقل :attribute إما true أو false",
|
|
190
|
+
confirmed: "حقل التأكيد غير مُطابق للحقل :attribute",
|
|
191
|
+
date: "الحقل :attribute ليس تاريخًا صحيحًا",
|
|
192
|
+
datetime: "الحقل :attribute يجب أن يكون تاريخًا صالحًا يطابق الصيغة :format.",
|
|
193
|
+
date_equals: "لا يساوي الحقل :attribute مع :date.",
|
|
194
|
+
declined: "يجب رفض الحقل :attribute",
|
|
195
|
+
declined_if: "الحقل :attribute مرفوض في حال ما إذا كان :other يساوي :value.",
|
|
196
|
+
different: "يجب أن يكون الحقلان :attribute و :other مُختلفان",
|
|
197
|
+
digits: "يجب أن يحتوي الحقل :attribute على :digits رقمًا/أرقام",
|
|
198
|
+
digits_between: "يجب أن يحتوي الحقل :attribute بين :min و :max رقمًا/أرقام",
|
|
199
|
+
email: "يجب أن يكون :attribute عنوان بريد إلكتروني صحيح البُنية",
|
|
200
|
+
ends_with: "حقل :attribute يجب ان ينتهي بأحد القيم التالية :value.",
|
|
201
|
+
exists: "الحقل :attribute غير موجود",
|
|
202
|
+
gt: {
|
|
203
|
+
number: "حقل :attribute يجب ان يكون اكبر من :value.",
|
|
204
|
+
string: "حقل :attribute يجب ان يكون اكبر من :value حروفٍ/حرفًا.",
|
|
205
|
+
array: "حقل :attribute يجب ان يحتوي علي اكثر من :value عناصر/عنصر.",
|
|
206
|
+
object: "حقل :attribute يجب ان يحتوي علي اكثر من :value عناصر/عنصر."
|
|
207
|
+
},
|
|
208
|
+
gte: {
|
|
209
|
+
number: "حقل :attribute يجب ان يكون اكبر من او يساوي :value.",
|
|
210
|
+
string: "حقل :attribute يجب ان يكون اكبر من او يساوي :value حروفٍ/حرفًا.",
|
|
211
|
+
array: "حقل :attribute يجب ان يحتوي علي :value عناصر/عنصر او اكثر.",
|
|
212
|
+
object: "حقل :attribute يجب ان يحتوي علي :value عناصر/عنصر او اكثر."
|
|
213
|
+
},
|
|
214
|
+
hex: "الحقل :attribute يجب أن يكون لونًا سداسيًا صالحًا.",
|
|
215
|
+
in: "الحقل :attribute غير صالح",
|
|
216
|
+
includes: "الحقل :attribute يجب أن يحتوي على أحد القيم التالية: :values.",
|
|
217
|
+
integer: "يجب أن يكون الحقل :attribute عددًا صحيحًا",
|
|
218
|
+
json: "يجب أن يكون الحقل :attribute نصا من نوع JSON.",
|
|
219
|
+
lt: {
|
|
220
|
+
number: "حقل :attribute يجب ان يكون اقل من :value.",
|
|
221
|
+
string: "حقل :attribute يجب ان يكون اقل من :value حروفٍ/حرفًا.",
|
|
222
|
+
array: "حقل :attribute يجب ان يحتوي علي اقل من :value عناصر/عنصر.",
|
|
223
|
+
object: "حقل :attribute يجب ان يحتوي علي اقل من :value عناصر/عنصر."
|
|
224
|
+
},
|
|
225
|
+
lte: {
|
|
226
|
+
number: "حقل :attribute يجب ان يكون اقل من او يساوي :value.",
|
|
227
|
+
string: "حقل :attribute يجب ان يكون اقل من او يساوي :value حروفٍ/حرفًا.",
|
|
228
|
+
array: "حقل :attribute يجب ان يحتوي علي اكثر من :value عناصر/عنصر.",
|
|
229
|
+
object: "حقل :attribute يجب ان يحتوي علي اكثر من :value عناصر/عنصر."
|
|
230
|
+
},
|
|
231
|
+
max: {
|
|
232
|
+
number: "يجب أن تكون قيمة الحقل :attribute مساوية أو أصغر لـ :max.",
|
|
233
|
+
string: "يجب أن لا يتجاوز طول نص :attribute :max حروفٍ/حرفًا",
|
|
234
|
+
array: "يجب أن لا يحتوي الحقل :attribute على أكثر من :max عناصر/عنصر.",
|
|
235
|
+
object: "يجب أن لا يحتوي الحقل :attribute على أكثر من :max عناصر/عنصر."
|
|
236
|
+
},
|
|
237
|
+
min: {
|
|
238
|
+
number: "يجب أن تكون قيمة الحقل :attribute مساوية أو أكبر لـ :min.",
|
|
239
|
+
string: "يجب أن يكون طول نص :attribute على الأقل :min حروفٍ/حرفًا",
|
|
240
|
+
array: "يجب أن يحتوي الحقل :attribute على الأقل على :min عُنصرًا/عناصر",
|
|
241
|
+
object: "يجب أن يحتوي الحقل :attribute على الأقل على :min عُنصرًا/عناصر"
|
|
242
|
+
},
|
|
243
|
+
not_in: "الحقل :attribute غير صالح",
|
|
244
|
+
not_regex: "الحقل :attribute نوعه غير صالح",
|
|
245
|
+
not_includes: "الحقل :attribute يجب ألا يحتوي على أي من القيم التالية: :values.",
|
|
246
|
+
numeric: "يجب على الحقل :attribute أن يكون رقمًا",
|
|
247
|
+
object: "الحقل :attribute يجب ان يكون من نوع object.",
|
|
248
|
+
password: {
|
|
249
|
+
letter: "يجب ان يشمل حقل :attribute على حرف واحد على الاقل.",
|
|
250
|
+
letters: "يجب ان يشمل حقل :attribute على عدد :amount حروف على الاقل.",
|
|
251
|
+
lower_case: "يجب ان يشمل حقل :attribute على حرف واحد من صيغة صغيرة على الاقل.",
|
|
252
|
+
lower_cases: "يجب ان يشمل حقل :attribute على عدد :amount حروف صغيرة على الاقل.",
|
|
253
|
+
number: "يجب ان يشمل حقل :attribute على رقم واحد على الاقل.",
|
|
254
|
+
numbers: "يجب ان يشمل حقل :attribute على عدد :amount من الارقام على الاقل.",
|
|
255
|
+
symbol: "يجب ان يشمل حقل :attribute على رمز واحد على الاقل.",
|
|
256
|
+
symbols: "يجب ان يشمل حقل :attribute على عدد :amount رموز على الاقل.",
|
|
257
|
+
upper_case: "يجب ان يشمل حقل :attribute على حرف كبير واحد على الاقل.",
|
|
258
|
+
upper_cases: "يجب ان يشمل حقل :attribute على عدد :amount حروف كبيرة على الاقل."
|
|
259
|
+
},
|
|
260
|
+
present: "يجب تقديم الحقل :attribute",
|
|
261
|
+
regex: "صيغة الحقل :attribute .غير صحيحة",
|
|
262
|
+
required: "الحقل :attribute مطلوب.",
|
|
263
|
+
required_if: "الحقل :attribute مطلوب في حال ما إذا كان :other يساوي :value.",
|
|
264
|
+
required_unless: "الحقل :attribute مطلوب في حال ما لم يكن :other يساوي :values.",
|
|
265
|
+
required_with: "الحقل :attribute اجباري إذا توفّر :values.",
|
|
266
|
+
required_with_all: "الحقل :attribute اجباري إذا توفّر :values.",
|
|
267
|
+
required_without: "الحقل :attribute اجباري إذا لم يتوفّر :values.",
|
|
268
|
+
required_without_all: "الحقل :attribute اجباري إذا لم يتوفّر :values.",
|
|
269
|
+
starts_with: "الحقل :attribute يجب ان يبدأ بأحد القيم التالية: :values.",
|
|
270
|
+
same: "يجب أن يتطابق الحقل :attribute مع :other",
|
|
271
|
+
size: {
|
|
272
|
+
number: "يجب أن تكون قيمة الحقل :attribute مساوية لـ :size",
|
|
273
|
+
string: "يجب أن يحتوي النص :attribute على :size حروفٍ/حرفًا بالظبط",
|
|
274
|
+
array: "يجب أن يحتوي الحقل :attribute على :size عنصرٍ/عناصر بالظبط",
|
|
275
|
+
object: "يجب أن يحتوي الحقل :attribute على :size عنصرٍ/عناصر بالظبط"
|
|
276
|
+
},
|
|
277
|
+
string: "يجب أن يكون الحقل :attribute نصآ.",
|
|
278
|
+
unique: "الحقل :attribute مستخدم بالفعل.",
|
|
279
|
+
url: "صيغة الرابط :attribute غير صحيحة"
|
|
280
|
+
}
|
|
292
281
|
};
|
|
293
|
-
|
|
294
282
|
//#endregion
|
|
295
283
|
//#region src/utilities/helpers.ts
|
|
296
284
|
/**
|
|
@@ -345,7 +333,6 @@ function deepFindMessage(obj, path) {
|
|
|
345
333
|
}
|
|
346
334
|
return obj;
|
|
347
335
|
}
|
|
348
|
-
|
|
349
336
|
//#endregion
|
|
350
337
|
//#region src/Lang.ts
|
|
351
338
|
var Lang = class {
|
|
@@ -459,7 +446,6 @@ var Lang = class {
|
|
|
459
446
|
this.fallbackMessages = locales_default.en;
|
|
460
447
|
}
|
|
461
448
|
};
|
|
462
|
-
|
|
463
449
|
//#endregion
|
|
464
450
|
//#region src/Rules/IRuleContract.ts
|
|
465
451
|
var IRuleContract = class {
|
|
@@ -511,7 +497,6 @@ var IRuleContract = class {
|
|
|
511
497
|
return message;
|
|
512
498
|
}
|
|
513
499
|
};
|
|
514
|
-
|
|
515
500
|
//#endregion
|
|
516
501
|
//#region src/utilities/date.ts
|
|
517
502
|
/**
|
|
@@ -521,10 +506,12 @@ function toDate(value) {
|
|
|
521
506
|
const date = Date.parse(value);
|
|
522
507
|
return !isNaN(date) ? new Date(date) : null;
|
|
523
508
|
}
|
|
524
|
-
|
|
525
509
|
//#endregion
|
|
526
510
|
//#region src/validators/replaceAttributes.ts
|
|
527
511
|
const replaceAttributes = {
|
|
512
|
+
/**
|
|
513
|
+
* Replace all place-holders for the accepted_if rule.
|
|
514
|
+
*/
|
|
528
515
|
replaceAcceptedIf: function({ data, message, parameters, getDisplayableAttribute }) {
|
|
529
516
|
const [other] = parameters;
|
|
530
517
|
const result = deepFind(data, other);
|
|
@@ -534,19 +521,34 @@ const replaceAttributes = {
|
|
|
534
521
|
};
|
|
535
522
|
return message.replace(/:other|:value/gi, (matched) => values[matched]);
|
|
536
523
|
},
|
|
524
|
+
/**
|
|
525
|
+
* Replace all place-holders for the after rule.
|
|
526
|
+
*/
|
|
537
527
|
replaceAfter: function(payload) {
|
|
538
528
|
return this.replaceBefore(payload);
|
|
539
529
|
},
|
|
530
|
+
/**
|
|
531
|
+
* Replace all place-holders for the after_or_equal rule.
|
|
532
|
+
*/
|
|
540
533
|
replaceAfterOrEqual: function(payload) {
|
|
541
534
|
return this.replaceBefore(payload);
|
|
542
535
|
},
|
|
536
|
+
/**
|
|
537
|
+
* Replace all place-holders for the before rule.
|
|
538
|
+
*/
|
|
543
539
|
replaceBefore: function({ message, parameters, getDisplayableAttribute }) {
|
|
544
540
|
if (!toDate(parameters[0])) return message.replace(":date", getDisplayableAttribute(parameters[0]));
|
|
545
541
|
return message.replace(":date", parameters[0]);
|
|
546
542
|
},
|
|
543
|
+
/**
|
|
544
|
+
* Replace all place-holders for the before_or_equal rule.
|
|
545
|
+
*/
|
|
547
546
|
replaceBeforeOrEqual: function(payload) {
|
|
548
547
|
return this.replaceBefore(payload);
|
|
549
548
|
},
|
|
549
|
+
/**
|
|
550
|
+
* Replace all the place-holders for the between rule.
|
|
551
|
+
*/
|
|
550
552
|
replaceBetween: function({ message, parameters }) {
|
|
551
553
|
const values = {
|
|
552
554
|
":min": parameters[0],
|
|
@@ -554,12 +556,21 @@ const replaceAttributes = {
|
|
|
554
556
|
};
|
|
555
557
|
return message.replace(/:min|:max/gi, (matched) => values[matched]);
|
|
556
558
|
},
|
|
559
|
+
/**
|
|
560
|
+
* Replace all place-holders for the before_or_equal rule.
|
|
561
|
+
*/
|
|
557
562
|
replaceDateEquals: function(payload) {
|
|
558
563
|
return this.replaceBefore(payload);
|
|
559
564
|
},
|
|
565
|
+
/**
|
|
566
|
+
* Replace all place-holders for the datetime rule.
|
|
567
|
+
*/
|
|
560
568
|
replaceDatetime: function({ message, parameters }) {
|
|
561
569
|
return message.replace(":format", parameters[0]);
|
|
562
570
|
},
|
|
571
|
+
/**
|
|
572
|
+
* Replace all place-holders for the declined_if rule.
|
|
573
|
+
*/
|
|
563
574
|
replaceDeclinedIf: function({ message, parameters, data, getDisplayableAttribute }) {
|
|
564
575
|
const [other] = parameters;
|
|
565
576
|
const result = deepFind(data, other);
|
|
@@ -569,66 +580,126 @@ const replaceAttributes = {
|
|
|
569
580
|
};
|
|
570
581
|
return message.replace(/:other|:value/gi, (matched) => values[matched]);
|
|
571
582
|
},
|
|
583
|
+
/**
|
|
584
|
+
* Replace all place-holders for the different rule.
|
|
585
|
+
*/
|
|
572
586
|
replaceDifferent: function(payload) {
|
|
573
587
|
return this.replaceSame(payload);
|
|
574
588
|
},
|
|
589
|
+
/**
|
|
590
|
+
* Replace all place-holders for the digits rule.
|
|
591
|
+
*/
|
|
575
592
|
replaceDigits: function({ message, parameters }) {
|
|
576
593
|
return message.replace(":digits", parameters[0]);
|
|
577
594
|
},
|
|
595
|
+
/**
|
|
596
|
+
* Replace all place-holders for the digits (between) rule.
|
|
597
|
+
*/
|
|
578
598
|
replaceDigitsBetween: function(payload) {
|
|
579
599
|
return this.replaceBetween(payload);
|
|
580
600
|
},
|
|
601
|
+
/**
|
|
602
|
+
* Replace all place-holders for the ends_with rule.
|
|
603
|
+
*/
|
|
581
604
|
replaceEndsWith: function({ message, parameters }) {
|
|
582
605
|
return message.replace(":values", parameters.join(", "));
|
|
583
606
|
},
|
|
607
|
+
/**
|
|
608
|
+
* Replace all place-holders for the exists rule.
|
|
609
|
+
*/
|
|
584
610
|
replaceExists: function({ message, parameters, data }) {
|
|
585
611
|
return message.replace(":value", data[parameters[1]]);
|
|
586
612
|
},
|
|
613
|
+
/**
|
|
614
|
+
* Replace all place-holders for the in rule.
|
|
615
|
+
*/
|
|
587
616
|
replaceIn: function({ message, parameters }) {
|
|
588
617
|
return message.replace(":values", parameters.join(", "));
|
|
589
618
|
},
|
|
619
|
+
/**
|
|
620
|
+
* Replace all place-holders for the not_includes rule.
|
|
621
|
+
*/
|
|
590
622
|
replaceIncludes: function({ message, parameters }) {
|
|
591
623
|
return message.replace(":values", parameters.join(", "));
|
|
592
624
|
},
|
|
625
|
+
/**
|
|
626
|
+
* Replace all place-holders for the starts_with rule.
|
|
627
|
+
*/
|
|
593
628
|
replaceStartsWith: function({ message, parameters }) {
|
|
594
629
|
return message.replace(":values", parameters.join(", "));
|
|
595
630
|
},
|
|
631
|
+
/**
|
|
632
|
+
* Replace all place-holders for the min rule.
|
|
633
|
+
*/
|
|
596
634
|
replaceMin: function({ message, parameters }) {
|
|
597
635
|
return message.replace(":min", parameters[0]);
|
|
598
636
|
},
|
|
637
|
+
/**
|
|
638
|
+
* Replace all place-holders for the max rule.
|
|
639
|
+
*/
|
|
599
640
|
replaceMax: function({ message, parameters }) {
|
|
600
641
|
return message.replace(":max", parameters[0]);
|
|
601
642
|
},
|
|
643
|
+
/**
|
|
644
|
+
* Replace all place-holders for the not_includes rule.
|
|
645
|
+
*/
|
|
602
646
|
replaceNotIncludes: function({ message, parameters }) {
|
|
603
647
|
return message.replace(":values", parameters.join(", "));
|
|
604
648
|
},
|
|
649
|
+
/**
|
|
650
|
+
* Replace all place-holders for the required_with rule.
|
|
651
|
+
*/
|
|
605
652
|
replaceRequiredWith: function({ message, parameters, getDisplayableAttribute }) {
|
|
606
653
|
return message.replace(":values", parameters.map((attribute) => getDisplayableAttribute(attribute)).join(", "));
|
|
607
654
|
},
|
|
655
|
+
/**
|
|
656
|
+
* Replace all place-holders for the required_with_all rule.
|
|
657
|
+
*/
|
|
608
658
|
replaceRequiredWithAll: function(payload) {
|
|
609
659
|
return this.replaceRequiredWith(payload);
|
|
610
660
|
},
|
|
661
|
+
/**
|
|
662
|
+
* Replace all place-holders for the required_without rule.
|
|
663
|
+
*/
|
|
611
664
|
replaceRequiredWithout: function(payload) {
|
|
612
665
|
return this.replaceRequiredWith(payload);
|
|
613
666
|
},
|
|
667
|
+
/**
|
|
668
|
+
* Replace all place-holders for the required_without_all rule.
|
|
669
|
+
*/
|
|
614
670
|
replaceRequiredWithoutAll: function(payload) {
|
|
615
671
|
return this.replaceRequiredWith(payload);
|
|
616
672
|
},
|
|
673
|
+
/**
|
|
674
|
+
* Replace all place-holders for the gt rule.
|
|
675
|
+
*/
|
|
617
676
|
replaceGt: function({ message, parameters, data, hasNumericRule }) {
|
|
618
677
|
const [value] = parameters;
|
|
619
678
|
const result = deepFind(data, value);
|
|
620
679
|
if (typeof result === "undefined") return message.replace(":value", value);
|
|
621
680
|
return message.replace(":value", getSize(result, hasNumericRule).toString());
|
|
622
681
|
},
|
|
682
|
+
/**
|
|
683
|
+
* Replace all place-holders for the lt rule.
|
|
684
|
+
*/
|
|
623
685
|
replaceLt: function(payload) {
|
|
624
686
|
return this.replaceGt(payload);
|
|
625
687
|
},
|
|
688
|
+
/**
|
|
689
|
+
* Replace all place-holders for the gte rule.
|
|
690
|
+
*/
|
|
626
691
|
replaceGte: function(payload) {
|
|
627
692
|
return this.replaceGt(payload);
|
|
628
693
|
},
|
|
694
|
+
/**
|
|
695
|
+
* Replace all place-holders for the lte rule.
|
|
696
|
+
*/
|
|
629
697
|
replaceLte: function(payload) {
|
|
630
698
|
return this.replaceGt(payload);
|
|
631
699
|
},
|
|
700
|
+
/**
|
|
701
|
+
* Replace all place-holders for the required_if rule.
|
|
702
|
+
*/
|
|
632
703
|
replaceRequiredIf: function({ message, parameters, data, getDisplayableAttribute }) {
|
|
633
704
|
const [other] = parameters;
|
|
634
705
|
const result = deepFind(data, other);
|
|
@@ -638,12 +709,21 @@ const replaceAttributes = {
|
|
|
638
709
|
};
|
|
639
710
|
return message.replace(/:other|:value/gi, (matched) => values[matched]);
|
|
640
711
|
},
|
|
712
|
+
/**
|
|
713
|
+
* Replace all place-holders for the prohibited_unless rule.
|
|
714
|
+
*/
|
|
641
715
|
replaceProhibitedUnless: function(payload) {
|
|
642
716
|
return this.replaceRequiredUnless(payload);
|
|
643
717
|
},
|
|
718
|
+
/**
|
|
719
|
+
* Replace all place-holders for the prohibits rule.
|
|
720
|
+
*/
|
|
644
721
|
replaceProhibits: function({ message, parameters, getDisplayableAttribute }) {
|
|
645
722
|
return message.replace(":values", parameters.map((attribute) => getDisplayableAttribute(attribute)).join(", "));
|
|
646
723
|
},
|
|
724
|
+
/**
|
|
725
|
+
* Replace all the place-holders for the required_unless rule.
|
|
726
|
+
*/
|
|
647
727
|
replaceRequiredUnless: function({ message, parameters, getDisplayableAttribute }) {
|
|
648
728
|
const [other] = parameters;
|
|
649
729
|
const values = {
|
|
@@ -652,23 +732,41 @@ const replaceAttributes = {
|
|
|
652
732
|
};
|
|
653
733
|
return message.replace(/:other|:values/gi, (matched) => values[matched]);
|
|
654
734
|
},
|
|
735
|
+
/**
|
|
736
|
+
* Replace all place-holders for the same rule.
|
|
737
|
+
*/
|
|
655
738
|
replaceSame: function({ message, parameters, getDisplayableAttribute }) {
|
|
656
739
|
return message.replace(":other", getDisplayableAttribute(parameters[0]));
|
|
657
740
|
},
|
|
741
|
+
/**
|
|
742
|
+
* Replace all place-holders for the size rule.
|
|
743
|
+
*/
|
|
658
744
|
replaceSize: function({ message, parameters }) {
|
|
659
745
|
return message.replace(":size", parameters[0]);
|
|
660
746
|
},
|
|
747
|
+
/**
|
|
748
|
+
* Replace all place-holders for the multiple_of rule.
|
|
749
|
+
*/
|
|
661
750
|
replaceMultipleOf: function({ message, parameters }) {
|
|
662
751
|
return message.replace(":value", parameters[0]);
|
|
663
752
|
},
|
|
753
|
+
/**
|
|
754
|
+
* Replace all place-holders for the unique rule.
|
|
755
|
+
*/
|
|
664
756
|
replaceUnique: function({ message, parameters, data }) {
|
|
665
757
|
return message.replace(":value", data[parameters[1]]);
|
|
666
758
|
}
|
|
667
759
|
};
|
|
668
|
-
|
|
669
760
|
//#endregion
|
|
670
761
|
//#region src/validators/validationData.ts
|
|
671
762
|
const validationData = {
|
|
763
|
+
/**
|
|
764
|
+
* initialize and gather data for the given attribute.
|
|
765
|
+
*
|
|
766
|
+
* @param attribute
|
|
767
|
+
* @param masterData
|
|
768
|
+
* @returns
|
|
769
|
+
*/
|
|
672
770
|
initializeAndGatherData: function(attribute, masterData) {
|
|
673
771
|
const data = dotify(this.initializeAttributeOnData(attribute, masterData));
|
|
674
772
|
return {
|
|
@@ -676,6 +774,13 @@ const validationData = {
|
|
|
676
774
|
...this.extractValuesFromWildCards(masterData, data, attribute)
|
|
677
775
|
};
|
|
678
776
|
},
|
|
777
|
+
/**
|
|
778
|
+
* Gather a copy of the attribute data filled with any missing attributes.
|
|
779
|
+
*
|
|
780
|
+
* @param attribute
|
|
781
|
+
* @param masterData
|
|
782
|
+
* @returns
|
|
783
|
+
*/
|
|
679
784
|
initializeAttributeOnData: function(attribute, masterData) {
|
|
680
785
|
const explicitPath = this.getLeadingExplicitAttributePath(attribute);
|
|
681
786
|
const data = this.extractDataFromPath(explicitPath, JSON.parse(JSON.stringify(masterData)));
|
|
@@ -683,6 +788,14 @@ const validationData = {
|
|
|
683
788
|
deepSet(data, attribute, null);
|
|
684
789
|
return data;
|
|
685
790
|
},
|
|
791
|
+
/**
|
|
792
|
+
* Get all of the exact attribute values for a given wildcard attribute.
|
|
793
|
+
*
|
|
794
|
+
* @param masterData
|
|
795
|
+
* @param data
|
|
796
|
+
* @param attribute
|
|
797
|
+
* @returns
|
|
798
|
+
*/
|
|
686
799
|
extractValuesFromWildCards(masterData, data, attribute) {
|
|
687
800
|
const keys = [];
|
|
688
801
|
const pattern = new RegExp("^" + attribute.replace(/\*/g, "[^\\.]*"));
|
|
@@ -695,9 +808,22 @@ const validationData = {
|
|
|
695
808
|
keys.forEach((key) => data[key] = deepFind(masterData, key));
|
|
696
809
|
return data;
|
|
697
810
|
},
|
|
811
|
+
/**
|
|
812
|
+
* Get the explicit part of the attribute name - ex: 'foo.bar.*.baz' -> 'foo.bar'
|
|
813
|
+
*
|
|
814
|
+
* @param attribute
|
|
815
|
+
* @returns
|
|
816
|
+
*/
|
|
698
817
|
getLeadingExplicitAttributePath: function(attribute) {
|
|
699
818
|
return attribute.split("*")[0].replace(/\.$/, "");
|
|
700
819
|
},
|
|
820
|
+
/**
|
|
821
|
+
* Extract data based on the given dot-notated path.
|
|
822
|
+
*
|
|
823
|
+
* @param path
|
|
824
|
+
* @param masterData
|
|
825
|
+
* @returns
|
|
826
|
+
*/
|
|
701
827
|
extractDataFromPath(path, masterData) {
|
|
702
828
|
const results = {};
|
|
703
829
|
const value = deepFind(masterData, path);
|
|
@@ -705,7 +831,6 @@ const validationData = {
|
|
|
705
831
|
return results;
|
|
706
832
|
}
|
|
707
833
|
};
|
|
708
|
-
|
|
709
834
|
//#endregion
|
|
710
835
|
//#region src/Rules/closureValidationRule.ts
|
|
711
836
|
var ClosureValidationRule = class extends IRuleContract {
|
|
@@ -734,10 +859,16 @@ var ClosureValidationRule = class extends IRuleContract {
|
|
|
734
859
|
return !this.failed;
|
|
735
860
|
}
|
|
736
861
|
};
|
|
737
|
-
|
|
738
862
|
//#endregion
|
|
739
863
|
//#region src/validators/validationRuleParser.ts
|
|
740
864
|
const validationRuleParser = {
|
|
865
|
+
/**
|
|
866
|
+
* Convert rules to array
|
|
867
|
+
*
|
|
868
|
+
* @param rules
|
|
869
|
+
* @param data
|
|
870
|
+
* @returns
|
|
871
|
+
*/
|
|
741
872
|
explodeRules: function(rules, data = {}) {
|
|
742
873
|
const implicitAttributes = {};
|
|
743
874
|
for (const key in rules) if (key.indexOf("*") !== -1) {
|
|
@@ -750,6 +881,15 @@ const validationRuleParser = {
|
|
|
750
881
|
implicitAttributes
|
|
751
882
|
};
|
|
752
883
|
},
|
|
884
|
+
/**
|
|
885
|
+
* Define a set of rules that apply to each element in an array attribute.
|
|
886
|
+
*
|
|
887
|
+
* @param results
|
|
888
|
+
* @param attribute
|
|
889
|
+
* @param masterData
|
|
890
|
+
* @param implicitAttributes
|
|
891
|
+
* @returns
|
|
892
|
+
*/
|
|
753
893
|
explodeWildCardRules: function(results, attribute, masterData, implicitAttributes) {
|
|
754
894
|
const pattern = new RegExp("^" + attribute.replace(/\*/g, "[^.]*") + "$");
|
|
755
895
|
const data = validationData.initializeAndGatherData(attribute, masterData);
|
|
@@ -761,25 +901,45 @@ const validationRuleParser = {
|
|
|
761
901
|
}
|
|
762
902
|
return results;
|
|
763
903
|
},
|
|
904
|
+
/**
|
|
905
|
+
* Merge additional rules into a given attribute.
|
|
906
|
+
*
|
|
907
|
+
* @param results
|
|
908
|
+
* @param attribute
|
|
909
|
+
* @param rules
|
|
910
|
+
* @returns
|
|
911
|
+
*/
|
|
764
912
|
mergeRulesForAttribute(results, attribute, rules) {
|
|
765
913
|
const merge = this.explodeRules([rules]).rules[0];
|
|
766
914
|
results[attribute] = [...results[attribute] ? this.explodeExplicitRules(results[attribute]) : [], ...merge];
|
|
767
915
|
return results;
|
|
768
916
|
},
|
|
917
|
+
/**
|
|
918
|
+
* In case the rules specified by the user are a string seperated with '|' - convert them to an array
|
|
919
|
+
*/
|
|
769
920
|
explodeExplicitRules: function(rules) {
|
|
770
921
|
if (typeof rules === "string") return rules.split("|");
|
|
771
922
|
if (!Array.isArray(rules)) return [this.prepareRule(rules)];
|
|
772
923
|
return rules.map((rule) => this.prepareRule(rule));
|
|
773
924
|
},
|
|
925
|
+
/**
|
|
926
|
+
* Prepare the given rule for the Validator.
|
|
927
|
+
*/
|
|
774
928
|
prepareRule(rule) {
|
|
775
929
|
if (rule instanceof IRuleContract) return rule;
|
|
776
930
|
if (typeof rule === "function") return new ClosureValidationRule(rule);
|
|
777
931
|
return rule.toString();
|
|
778
932
|
},
|
|
933
|
+
/**
|
|
934
|
+
* Extract the rule name and parameters from a rule.
|
|
935
|
+
*/
|
|
779
936
|
parse(rule) {
|
|
780
937
|
if (rule instanceof IRuleContract) return [rule, []];
|
|
781
938
|
return this.parseStringRule(rule);
|
|
782
939
|
},
|
|
940
|
+
/**
|
|
941
|
+
* Parse the parameters associated with a rule
|
|
942
|
+
*/
|
|
783
943
|
parseStringRule: function(rule) {
|
|
784
944
|
let parameters = [];
|
|
785
945
|
let parameter;
|
|
@@ -789,6 +949,14 @@ const validationRuleParser = {
|
|
|
789
949
|
}
|
|
790
950
|
return [rule, parameters];
|
|
791
951
|
},
|
|
952
|
+
/**
|
|
953
|
+
* Get a rule and its parameters for a given attribute.
|
|
954
|
+
*
|
|
955
|
+
* @param attribute
|
|
956
|
+
* @param searchRules
|
|
957
|
+
* @param availableRules
|
|
958
|
+
* @returns
|
|
959
|
+
*/
|
|
792
960
|
getRule: function(attribute, searchRules, availableRules) {
|
|
793
961
|
if (!availableRules[attribute]) return [];
|
|
794
962
|
searchRules = Array.isArray(searchRules) ? searchRules : [searchRules];
|
|
@@ -798,11 +966,13 @@ const validationRuleParser = {
|
|
|
798
966
|
}
|
|
799
967
|
return [];
|
|
800
968
|
},
|
|
969
|
+
/**
|
|
970
|
+
* Determine if the given attribute has a rule in the given set of available rules.
|
|
971
|
+
*/
|
|
801
972
|
hasRule: function(attribute, searchRules, availableRules) {
|
|
802
973
|
return this.getRule(attribute, searchRules, availableRules).length > 0;
|
|
803
974
|
}
|
|
804
975
|
};
|
|
805
|
-
|
|
806
976
|
//#endregion
|
|
807
977
|
//#region src/validators/validateAttributes.ts
|
|
808
978
|
var validateAttributes = class {
|
|
@@ -1406,7 +1576,7 @@ var validateAttributes = class {
|
|
|
1406
1576
|
*/
|
|
1407
1577
|
validateUrl(value) {
|
|
1408
1578
|
if (typeof value !== "string") return false;
|
|
1409
|
-
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);
|
|
1579
|
+
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);
|
|
1410
1580
|
}
|
|
1411
1581
|
/**
|
|
1412
1582
|
* Determine if a comparison passes between the given values.
|
|
@@ -1489,7 +1659,6 @@ var validateAttributes = class {
|
|
|
1489
1659
|
return stringValue.split(".")[1]?.length ?? 0;
|
|
1490
1660
|
}
|
|
1491
1661
|
};
|
|
1492
|
-
|
|
1493
1662
|
//#endregion
|
|
1494
1663
|
//#region src/Rules/registerRule.ts
|
|
1495
1664
|
function register(rule, validate, replaceMessage) {
|
|
@@ -1502,17 +1671,20 @@ function register(rule, validate, replaceMessage) {
|
|
|
1502
1671
|
function registerImplicit(rule, validate, replaceMessage) {
|
|
1503
1672
|
if (register(rule, validate, replaceMessage) === true) addImplicitRule(rule);
|
|
1504
1673
|
}
|
|
1505
|
-
|
|
1506
1674
|
//#endregion
|
|
1507
1675
|
//#region src/Plugin.ts
|
|
1508
1676
|
const valueInspectors = [];
|
|
1677
|
+
const validationErrorHooks = [];
|
|
1678
|
+
const validationSuccessHooks = [];
|
|
1509
1679
|
const api = {
|
|
1510
1680
|
registerRule: register,
|
|
1511
1681
|
registerImplicitRule: registerImplicit,
|
|
1512
1682
|
registerValueInspector,
|
|
1513
1683
|
extendTranslations: (translations) => {
|
|
1514
1684
|
Lang.extendTranslationObject(translations);
|
|
1515
|
-
}
|
|
1685
|
+
},
|
|
1686
|
+
onValidationError: registerValidationErrorHook,
|
|
1687
|
+
onValidationSuccess: registerValidationSuccessHook
|
|
1516
1688
|
};
|
|
1517
1689
|
function definePlugin(plugin) {
|
|
1518
1690
|
return plugin;
|
|
@@ -1528,6 +1700,18 @@ function registerValueInspector(inspector) {
|
|
|
1528
1700
|
}
|
|
1529
1701
|
valueInspectors.push(inspector);
|
|
1530
1702
|
}
|
|
1703
|
+
function registerValidationErrorHook(hook) {
|
|
1704
|
+
validationErrorHooks.push(hook);
|
|
1705
|
+
}
|
|
1706
|
+
function registerValidationSuccessHook(hook) {
|
|
1707
|
+
validationSuccessHooks.push(hook);
|
|
1708
|
+
}
|
|
1709
|
+
async function dispatchValidationErrorHooks(validator) {
|
|
1710
|
+
for (const hook of validationErrorHooks) await hook(validator);
|
|
1711
|
+
}
|
|
1712
|
+
async function dispatchValidationSuccessHooks(validator) {
|
|
1713
|
+
for (const hook of validationSuccessHooks) await hook(validator);
|
|
1714
|
+
}
|
|
1531
1715
|
function getValidationValueInspector(value) {
|
|
1532
1716
|
return valueInspectors.find((inspector) => inspector.matches(value));
|
|
1533
1717
|
}
|
|
@@ -1546,7 +1730,6 @@ function getValidationSize(value, hasNumericRule = false) {
|
|
|
1546
1730
|
if (typeof value === "object" && value !== null) return Object.keys(value).length;
|
|
1547
1731
|
return -1;
|
|
1548
1732
|
}
|
|
1549
|
-
|
|
1550
1733
|
//#endregion
|
|
1551
1734
|
//#region src/utilities/general.ts
|
|
1552
1735
|
const implicitRues = [
|
|
@@ -1680,7 +1863,6 @@ function convertValuesToNull(values) {
|
|
|
1680
1863
|
return value;
|
|
1681
1864
|
});
|
|
1682
1865
|
}
|
|
1683
|
-
|
|
1684
1866
|
//#endregion
|
|
1685
1867
|
//#region src/utilities/object.ts
|
|
1686
1868
|
/**
|
|
@@ -1757,7 +1939,6 @@ function deepEqual(firstParam, secondParam) {
|
|
|
1757
1939
|
if (Object.keys(first).length !== Object.keys(second).length) return false;
|
|
1758
1940
|
return Object.entries(first).every(([key, value]) => second[key] === value);
|
|
1759
1941
|
}
|
|
1760
|
-
|
|
1761
1942
|
//#endregion
|
|
1762
1943
|
//#region src/utilities/formatMessages.ts
|
|
1763
1944
|
/**
|
|
@@ -1843,7 +2024,6 @@ function getPrimaryKeyFromPath(path) {
|
|
|
1843
2024
|
if (isNaN(parseInt(key)) === false) return getPrimaryKeyFromPath(splittedPath.join("."));
|
|
1844
2025
|
return key;
|
|
1845
2026
|
}
|
|
1846
|
-
|
|
1847
2027
|
//#endregion
|
|
1848
2028
|
//#region src/validators/errorBag.ts
|
|
1849
2029
|
var ErrorBag = class ErrorBag {
|
|
@@ -1952,7 +2132,6 @@ var ErrorBag = class ErrorBag {
|
|
|
1952
2132
|
return new ErrorBag({ ...this.errors }, { ...this.messages }, this.firstMessage, this.withErrorTypes);
|
|
1953
2133
|
}
|
|
1954
2134
|
};
|
|
1955
|
-
|
|
1956
2135
|
//#endregion
|
|
1957
2136
|
//#region src/Rules/password.ts
|
|
1958
2137
|
var Password$1 = class Password$1 extends IRuleContract {
|
|
@@ -2143,14 +2322,12 @@ var Password$1 = class Password$1 extends IRuleContract {
|
|
|
2143
2322
|
return password instanceof IRuleContract ? password : Password$1.create().min(8);
|
|
2144
2323
|
}
|
|
2145
2324
|
};
|
|
2146
|
-
|
|
2147
2325
|
//#endregion
|
|
2148
2326
|
//#region src/utilities/build.ts
|
|
2149
2327
|
function buildValidationMethodName(rule) {
|
|
2150
2328
|
if (!rule) return rule;
|
|
2151
2329
|
return rule.split("_").map((rule) => `${rule[0].toUpperCase()}${rule.slice(1)}`).join("");
|
|
2152
2330
|
}
|
|
2153
|
-
|
|
2154
2331
|
//#endregion
|
|
2155
2332
|
//#region src/payloads/replaceAttributePayload.ts
|
|
2156
2333
|
var replaceAttributePayload = class {
|
|
@@ -2182,7 +2359,6 @@ var replaceAttributePayload = class {
|
|
|
2182
2359
|
this.getDisplayableAttribute = getDisplayableAttribute;
|
|
2183
2360
|
}
|
|
2184
2361
|
};
|
|
2185
|
-
|
|
2186
2362
|
//#endregion
|
|
2187
2363
|
//#region src/BaseValidator.ts
|
|
2188
2364
|
var BaseValidator = class BaseValidator {
|
|
@@ -2659,11 +2835,9 @@ var BaseValidator = class BaseValidator {
|
|
|
2659
2835
|
return [];
|
|
2660
2836
|
}
|
|
2661
2837
|
};
|
|
2662
|
-
|
|
2663
2838
|
//#endregion
|
|
2664
2839
|
//#region src/Contracts/IDatabaseDriver.ts
|
|
2665
2840
|
var IDatabaseDriver = class {};
|
|
2666
|
-
|
|
2667
2841
|
//#endregion
|
|
2668
2842
|
//#region src/Rules/in.ts
|
|
2669
2843
|
var In = class extends BaseRule {
|
|
@@ -2689,7 +2863,6 @@ var In = class extends BaseRule {
|
|
|
2689
2863
|
return `${this.rule}:${this.values.join(",")}`;
|
|
2690
2864
|
}
|
|
2691
2865
|
};
|
|
2692
|
-
|
|
2693
2866
|
//#endregion
|
|
2694
2867
|
//#region src/Rules/notIn.ts
|
|
2695
2868
|
var NotIn = class extends BaseRule {
|
|
@@ -2715,7 +2888,6 @@ var NotIn = class extends BaseRule {
|
|
|
2715
2888
|
return `${this.rule}:${this.values.join(",")}`;
|
|
2716
2889
|
}
|
|
2717
2890
|
};
|
|
2718
|
-
|
|
2719
2891
|
//#endregion
|
|
2720
2892
|
//#region src/Rules/regex.ts
|
|
2721
2893
|
var Regex = class extends IRuleContract {
|
|
@@ -2741,7 +2913,6 @@ var Regex = class extends IRuleContract {
|
|
|
2741
2913
|
return this.trans("not_regex");
|
|
2742
2914
|
}
|
|
2743
2915
|
};
|
|
2744
|
-
|
|
2745
2916
|
//#endregion
|
|
2746
2917
|
//#region src/Rules/requiredIf.ts
|
|
2747
2918
|
var RequiredIf = class extends BaseRule {
|
|
@@ -2764,7 +2935,6 @@ var RequiredIf = class extends BaseRule {
|
|
|
2764
2935
|
return this.condition ? "required" : "";
|
|
2765
2936
|
}
|
|
2766
2937
|
};
|
|
2767
|
-
|
|
2768
2938
|
//#endregion
|
|
2769
2939
|
//#region src/rule.ts
|
|
2770
2940
|
function requiredIf(callback) {
|
|
@@ -2782,32 +2952,29 @@ function regex(value) {
|
|
|
2782
2952
|
function notRegex(value) {
|
|
2783
2953
|
return new Regex(value, false);
|
|
2784
2954
|
}
|
|
2785
|
-
|
|
2786
2955
|
//#endregion
|
|
2787
2956
|
//#region src/Core.ts
|
|
2788
2957
|
var Password = class extends Password$1 {};
|
|
2789
2958
|
function make(data = {}, rules = {}, customMessages = {}, customAttributes = {}) {
|
|
2790
2959
|
return new BaseValidator(data, rules, customMessages, customAttributes);
|
|
2791
2960
|
}
|
|
2792
|
-
|
|
2793
2961
|
//#endregion
|
|
2794
2962
|
//#region src/Rules/IImplicitRule.ts
|
|
2795
2963
|
var IImplicitRule = class extends IRuleContract {
|
|
2796
2964
|
__isImplicitRule = true;
|
|
2797
2965
|
};
|
|
2798
|
-
|
|
2799
2966
|
//#endregion
|
|
2800
2967
|
//#region src/ImplicitRule.ts
|
|
2801
2968
|
var ImplicitRule = class extends IImplicitRule {
|
|
2802
2969
|
rules = [];
|
|
2803
2970
|
};
|
|
2804
|
-
|
|
2805
2971
|
//#endregion
|
|
2806
2972
|
//#region src/Providers/ValidationServiceProvider.ts
|
|
2807
2973
|
/**
|
|
2808
2974
|
* Service provider for Validation utilities
|
|
2809
2975
|
*/
|
|
2810
2976
|
var ValidationServiceProvider = class {
|
|
2977
|
+
app;
|
|
2811
2978
|
registeredCommands;
|
|
2812
2979
|
static priority = 895;
|
|
2813
2980
|
constructor(app) {
|
|
@@ -2822,7 +2989,6 @@ var ValidationServiceProvider = class {
|
|
|
2822
2989
|
*/
|
|
2823
2990
|
boot() {}
|
|
2824
2991
|
};
|
|
2825
|
-
|
|
2826
2992
|
//#endregion
|
|
2827
2993
|
//#region src/ValidationRule.ts
|
|
2828
2994
|
var ValidationRule = class extends IRuleContract {
|
|
@@ -2843,7 +3009,6 @@ var ValidationRule = class extends IRuleContract {
|
|
|
2843
3009
|
return this.passing;
|
|
2844
3010
|
}
|
|
2845
3011
|
};
|
|
2846
|
-
|
|
2847
3012
|
//#endregion
|
|
2848
3013
|
//#region src/Rules/ExtendedRules.ts
|
|
2849
3014
|
dayjs.extend(customParseFormat);
|
|
@@ -2953,7 +3118,6 @@ var ExtendedRules = class extends ValidationRule {
|
|
|
2953
3118
|
];
|
|
2954
3119
|
validate() {}
|
|
2955
3120
|
};
|
|
2956
|
-
|
|
2957
3121
|
//#endregion
|
|
2958
3122
|
//#region src/utilities/MessageBag.ts
|
|
2959
3123
|
var MessageBag = class {
|
|
@@ -3167,7 +3331,6 @@ var MessageBag = class {
|
|
|
3167
3331
|
return this.toJson();
|
|
3168
3332
|
}
|
|
3169
3333
|
};
|
|
3170
|
-
|
|
3171
3334
|
//#endregion
|
|
3172
3335
|
//#region src/Validator.ts
|
|
3173
3336
|
var Validator = class Validator {
|
|
@@ -3245,6 +3408,8 @@ var Validator = class Validator {
|
|
|
3245
3408
|
if (this.executed) return this._errors.isEmpty();
|
|
3246
3409
|
const exec = await this.execute();
|
|
3247
3410
|
for (const after of this.#after) after();
|
|
3411
|
+
if (exec.passing) await dispatchValidationSuccessHooks(this);
|
|
3412
|
+
else await dispatchValidationErrorHooks(this);
|
|
3248
3413
|
return exec.passing;
|
|
3249
3414
|
}
|
|
3250
3415
|
/**
|
|
@@ -3450,7 +3615,6 @@ var Validator = class Validator {
|
|
|
3450
3615
|
return this;
|
|
3451
3616
|
}
|
|
3452
3617
|
};
|
|
3453
|
-
|
|
3454
3618
|
//#endregion
|
|
3455
3619
|
//#region src/ValidationException.ts
|
|
3456
3620
|
var ValidationException = class ValidationException extends Error {
|
|
@@ -3538,6 +3702,5 @@ var ValidationException = class ValidationException extends Error {
|
|
|
3538
3702
|
return this.response;
|
|
3539
3703
|
}
|
|
3540
3704
|
};
|
|
3541
|
-
|
|
3542
3705
|
//#endregion
|
|
3543
|
-
export { BaseRule, BaseValidator, ErrorBag, ExtendedRules, IDatabaseDriver, ImplicitRule, Lang, MessageBag, Password, ValidationException, ValidationRule, ValidationServiceProvider, Validator, addImplicitRule, buildValidationMethodName, compare, convertValuesToBoolean, convertValuesToNull, convertValuesToNumber, deepEqual, deepFind, deepFindMessage, deepSet, definePlugin, dotify, getFormattedAttribute, getKeyCombinations, getMessage, getNumericRules, getSize, getValidationMessageType, getValidationSize, getValidationValueInspector, getValidatorContext, isArrayOfRules, isImplicitRule, isInteger, isNumericRule, isObject, isRule, isSizeRule, make, mergeDeep, notRegex, plural, regex, register, registerImplicit, registerValueInspector, requiredIf, ruleIn, ruleNotIn, runWithValidatorContext, sameType, toDate, toSnakeCase, usePlugin, useValidatorContext };
|
|
3706
|
+
export { BaseRule, BaseValidator, ErrorBag, ExtendedRules, IDatabaseDriver, ImplicitRule, Lang, MessageBag, Password, ValidationException, ValidationRule, ValidationServiceProvider, Validator, addImplicitRule, buildValidationMethodName, compare, convertValuesToBoolean, convertValuesToNull, convertValuesToNumber, deepEqual, deepFind, deepFindMessage, deepSet, definePlugin, dispatchValidationErrorHooks, dispatchValidationSuccessHooks, dotify, getFormattedAttribute, getKeyCombinations, getMessage, getNumericRules, getSize, getValidationMessageType, getValidationSize, getValidationValueInspector, getValidatorContext, isArrayOfRules, isImplicitRule, isInteger, isNumericRule, isObject, isRule, isSizeRule, make, mergeDeep, notRegex, plural, regex, register, registerImplicit, registerValidationErrorHook, registerValidationSuccessHook, registerValueInspector, requiredIf, ruleIn, ruleNotIn, runWithValidatorContext, sameType, toDate, toSnakeCase, usePlugin, useValidatorContext };
|