@kklab/fortress-validator 1.0.17 → 1.0.19
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 +4 -0
- package/dist/FieldValidator.d.ts +16 -0
- package/dist/index.js +177 -113
- package/dist/index.umd.js +1 -1
- package/dist/rules/contains.d.ts +6 -0
- package/dist/rules/notContains.d.ts +6 -0
- package/dist/rules/stringContains.d.ts +6 -0
- package/dist/rules/stringNotContains.d.ts +6 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -82,6 +82,7 @@ const result = validator
|
|
|
82
82
|
| `before` | Passes if the field's value is a date that occurs before the specified date. |
|
|
83
83
|
| `between` | Passes if the field's value is between the specified minimum and maximum values. |
|
|
84
84
|
| `boolean` | Passes if the field's value is a boolean. |
|
|
85
|
+
| `contains` | Passes if the field's value contains the specified value. |
|
|
85
86
|
| `containsAll` | Passes if the field's value contains all of the specified values. |
|
|
86
87
|
| `containsAny` | Passes if the field's value contains at least one of the specified values. |
|
|
87
88
|
| `date` | Passes if the field's value matches the specified date format. |
|
|
@@ -114,6 +115,7 @@ const result = validator
|
|
|
114
115
|
| `lowercase` | Passes if the field's value contains only lowercase characters. |
|
|
115
116
|
| `lt` | Passes if the field's value is less than the specified value. |
|
|
116
117
|
| `lte` | Passes if the field's value is less than or equal to the specified value. |
|
|
118
|
+
| `notContains` | Passes if the field's value does not contain the specified value. |
|
|
117
119
|
| `notContainsAll` | Passes if the field's value does not contain all of the specified values together. |
|
|
118
120
|
| `notContainsAny` | Passes if the field's value does not contain any of the specified values. |
|
|
119
121
|
| `notEndsWith` | Passes if the field's value does not end with the specified value. |
|
|
@@ -135,6 +137,7 @@ const result = validator
|
|
|
135
137
|
| `startsWith` | Passes if the field's value starts with the specified value. |
|
|
136
138
|
| `startsWithNumber` | Passes if the field's value starts with a number. |
|
|
137
139
|
| `string` | Passes if the field's value is a string. |
|
|
140
|
+
| `stringContains` | Passes if the field's value contains the specified text. |
|
|
138
141
|
| `stringContainsAll` | Passes if the field's value contains all of the specified text. |
|
|
139
142
|
| `stringContainsAny` | Passes if the field's value contains at least one of the specified text. |
|
|
140
143
|
| `stringLength` | Passes if the field's string length matches the specified string length. |
|
|
@@ -143,6 +146,7 @@ const result = validator
|
|
|
143
146
|
| `stringLengthGte` | Passes if the field's string length is greater than or equal to the specified string length. |
|
|
144
147
|
| `stringLengthLt` | Passes if the field's string length is less than the specified string length. |
|
|
145
148
|
| `stringLengthLte` | Passes if the field's string length is less than or equal to the specified string length. |
|
|
149
|
+
| `stringNotContains` | Passes if the field's value does not contain the specified text. |
|
|
146
150
|
| `stringNotContainsAll` | Passes if the field's value does not contain all of the specified text together. |
|
|
147
151
|
| `stringNotContainsAny` | Passes if the field's value does not contain any of the specified text. |
|
|
148
152
|
| `subsetOf` | Passes if the field's value is a subset of the specified values. |
|
package/dist/FieldValidator.d.ts
CHANGED
|
@@ -101,6 +101,10 @@ declare class FieldValidator {
|
|
|
101
101
|
* Passes if the field's value is a boolean.
|
|
102
102
|
*/
|
|
103
103
|
boolean(): this;
|
|
104
|
+
/**
|
|
105
|
+
* Passes if the field's value contains the specified value.
|
|
106
|
+
*/
|
|
107
|
+
contains(value: unknown): this;
|
|
104
108
|
/**
|
|
105
109
|
* Passes if the field's value contains all of the specified values.
|
|
106
110
|
*/
|
|
@@ -229,6 +233,10 @@ declare class FieldValidator {
|
|
|
229
233
|
* Passes if the field's value is less than or equal to the specified value.
|
|
230
234
|
*/
|
|
231
235
|
lte(value: number): this;
|
|
236
|
+
/**
|
|
237
|
+
* Passes if the field's value does not contain the specified value.
|
|
238
|
+
*/
|
|
239
|
+
notContains(value: unknown): this;
|
|
232
240
|
/**
|
|
233
241
|
* Passes if the field's value does not contain all of the specified values together.
|
|
234
242
|
*/
|
|
@@ -313,6 +321,10 @@ declare class FieldValidator {
|
|
|
313
321
|
* Passes if the field's value is a string.
|
|
314
322
|
*/
|
|
315
323
|
string(): this;
|
|
324
|
+
/**
|
|
325
|
+
* Passes if the field's value contains the specified text.
|
|
326
|
+
*/
|
|
327
|
+
stringContains(value: string): this;
|
|
316
328
|
/**
|
|
317
329
|
* Passes if the field's value contains all of the specified text.
|
|
318
330
|
*/
|
|
@@ -345,6 +357,10 @@ declare class FieldValidator {
|
|
|
345
357
|
* Passes if the field's string length is less than or equal to the specified string length.
|
|
346
358
|
*/
|
|
347
359
|
stringLengthLte(length: number): this;
|
|
360
|
+
/**
|
|
361
|
+
* Passes if the field's value does not contain the specified text.
|
|
362
|
+
*/
|
|
363
|
+
stringNotContains(value: string): this;
|
|
348
364
|
/**
|
|
349
365
|
* Passes if the field's value does not contain all of the specified text together.
|
|
350
366
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var o = (t, e, r) => (
|
|
1
|
+
var P = Object.defineProperty;
|
|
2
|
+
var I = (t, e, r) => e in t ? P(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var o = (t, e, r) => (I(t, typeof e != "symbol" ? e + "" : e, r), r);
|
|
4
4
|
const L = (t) => {
|
|
5
|
-
const e = ",、;:!?。()《》「」『』【】〔〕", r = "\\x20-\\x7E", a = new RegExp(`\\s*([${e}])`, "gu"), l = new RegExp(`([${e}])\\s*([${r}])`, "gu"), u = new RegExp(`([^${r}${e}])([${r}])`, "gu"),
|
|
6
|
-
return t.replace(a, "$1").replace(l, "$1$2").replace(u, "$1 $2").replace(
|
|
7
|
-
}, n = (t, e
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const e = ",、;:!?。()《》「」『』【】〔〕", r = "\\x20-\\x7E", a = new RegExp(`\\s*([${e}])`, "gu"), l = new RegExp(`([${e}])\\s*([${r}])`, "gu"), u = new RegExp(`([^${r}${e}])([${r}])`, "gu"), D = new RegExp(`([${r}])([^${r}${e}])`, "gu");
|
|
6
|
+
return t.replace(a, "$1").replace(l, "$1$2").replace(u, "$1 $2").replace(D, "$1 $2").replace(/ +/g, " ");
|
|
7
|
+
}, n = (t, e) => {
|
|
8
|
+
var r;
|
|
9
|
+
const a = e ?? ((r = t.toString().split(".").at(1)) == null ? void 0 : r.length) ?? 0;
|
|
10
|
+
return new Intl.NumberFormat(void 0, {
|
|
11
|
+
minimumFractionDigits: a,
|
|
12
|
+
maximumFractionDigits: a
|
|
13
|
+
}).format(t);
|
|
14
|
+
}, K = (t) => Object.prototype.toString.call(t).toLowerCase().slice(8, -1), s = (t) => t == null || t === "" || Array.isArray(t) && t.length < 1, i = (t) => `"${t}"`;
|
|
15
|
+
class Z {
|
|
12
16
|
constructor({
|
|
13
17
|
name: e,
|
|
14
18
|
locale: r,
|
|
@@ -64,7 +68,7 @@ class K {
|
|
|
64
68
|
buildRuleFunctionMessage(e, r, a) {
|
|
65
69
|
const l = this.getMessage(e)(this.formattedName, r);
|
|
66
70
|
if (typeof l == "object") {
|
|
67
|
-
const u =
|
|
71
|
+
const u = K(a);
|
|
68
72
|
if (!(u in l))
|
|
69
73
|
throw new Error(`The message for the "${e}" rule of the "${u}" type is missing.`);
|
|
70
74
|
return L(l[u]);
|
|
@@ -208,6 +212,12 @@ class K {
|
|
|
208
212
|
boolean() {
|
|
209
213
|
return this.apply(this.boolean.name);
|
|
210
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Passes if the field's value contains the specified value.
|
|
217
|
+
*/
|
|
218
|
+
contains(e) {
|
|
219
|
+
return this.apply(this.contains.name, { value: e });
|
|
220
|
+
}
|
|
211
221
|
/**
|
|
212
222
|
* Passes if the field's value contains all of the specified values.
|
|
213
223
|
*/
|
|
@@ -403,6 +413,12 @@ class K {
|
|
|
403
413
|
lte(e) {
|
|
404
414
|
return this.apply(this.lte.name, { value: e });
|
|
405
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
* Passes if the field's value does not contain the specified value.
|
|
418
|
+
*/
|
|
419
|
+
notContains(e) {
|
|
420
|
+
return this.apply(this.notContains.name, { value: e });
|
|
421
|
+
}
|
|
406
422
|
/**
|
|
407
423
|
* Passes if the field's value does not contain all of the specified values together.
|
|
408
424
|
*/
|
|
@@ -530,6 +546,12 @@ class K {
|
|
|
530
546
|
string() {
|
|
531
547
|
return this.apply(this.string.name);
|
|
532
548
|
}
|
|
549
|
+
/**
|
|
550
|
+
* Passes if the field's value contains the specified text.
|
|
551
|
+
*/
|
|
552
|
+
stringContains(e) {
|
|
553
|
+
return this.apply(this.stringContains.name, { value: e });
|
|
554
|
+
}
|
|
533
555
|
/**
|
|
534
556
|
* Passes if the field's value contains all of the specified text.
|
|
535
557
|
*/
|
|
@@ -578,6 +600,12 @@ class K {
|
|
|
578
600
|
stringLengthLte(e) {
|
|
579
601
|
return this.apply(this.stringLengthLte.name, { length: e });
|
|
580
602
|
}
|
|
603
|
+
/**
|
|
604
|
+
* Passes if the field's value does not contain the specified text.
|
|
605
|
+
*/
|
|
606
|
+
stringNotContains(e) {
|
|
607
|
+
return this.apply(this.stringNotContains.name, { value: e });
|
|
608
|
+
}
|
|
581
609
|
/**
|
|
582
610
|
* Passes if the field's value does not contain all of the specified text together.
|
|
583
611
|
*/
|
|
@@ -621,7 +649,7 @@ class K {
|
|
|
621
649
|
return typeof e == "object" ? (this.conditions = e, this) : (e || (this.shouldSkip = !0), this);
|
|
622
650
|
}
|
|
623
651
|
}
|
|
624
|
-
const
|
|
652
|
+
const H = {
|
|
625
653
|
accepted: (t) => `The ${t} field must be accepted.`,
|
|
626
654
|
alpha: (t) => `The ${t} field must only contain letters.`,
|
|
627
655
|
alphaDash: (t) => `The ${t} field must only contain letters, numbers, dashes and underscores.`,
|
|
@@ -644,14 +672,14 @@ const Z = {
|
|
|
644
672
|
const { length: r } = e;
|
|
645
673
|
return `The ${t} field must be greater than or equal to ${n(r)} items.`;
|
|
646
674
|
},
|
|
647
|
-
arrayLengthLte: (t, e) => {
|
|
648
|
-
const { length: r } = e;
|
|
649
|
-
return `The ${t} field must be less than or equal to ${n(r)} items.`;
|
|
650
|
-
},
|
|
651
675
|
arrayLengthLt: (t, e) => {
|
|
652
676
|
const { length: r } = e;
|
|
653
677
|
return `The ${t} field must be less than ${n(r)} items.`;
|
|
654
678
|
},
|
|
679
|
+
arrayLengthLte: (t, e) => {
|
|
680
|
+
const { length: r } = e;
|
|
681
|
+
return `The ${t} field must be less than or equal to ${n(r)} items.`;
|
|
682
|
+
},
|
|
655
683
|
ascii: (t) => `The ${t} field must only contain ASCII characters and symbols.`,
|
|
656
684
|
between: (t, e) => {
|
|
657
685
|
const { min: r, max: a } = e;
|
|
@@ -661,6 +689,10 @@ const Z = {
|
|
|
661
689
|
};
|
|
662
690
|
},
|
|
663
691
|
boolean: (t) => `The ${t} field must be a boolean value.`,
|
|
692
|
+
contains: (t, e) => {
|
|
693
|
+
const { value: r } = e;
|
|
694
|
+
return `The ${t} field must contain ${i(r)}.`;
|
|
695
|
+
},
|
|
664
696
|
containsAll: (t, e) => {
|
|
665
697
|
const { values: r } = e;
|
|
666
698
|
return `The ${t} field must contain all of the following values: ${r.map(i).join(", ")}.`;
|
|
@@ -686,6 +718,13 @@ const Z = {
|
|
|
686
718
|
return `The ${t} field must be equal to ${r}.`;
|
|
687
719
|
},
|
|
688
720
|
file: (t) => `The ${t} field must be a file.`,
|
|
721
|
+
fileSize: (t, e) => {
|
|
722
|
+
const { size: r } = e;
|
|
723
|
+
return {
|
|
724
|
+
file: `The ${t} field must be ${n(r)} kilobytes.`,
|
|
725
|
+
array: `The ${t} field must contain items where each item is ${n(r)} kilobytes.`
|
|
726
|
+
};
|
|
727
|
+
},
|
|
689
728
|
fileSizeBetween: (t, e) => {
|
|
690
729
|
const { min: r, max: a } = e;
|
|
691
730
|
return {
|
|
@@ -721,11 +760,18 @@ const Z = {
|
|
|
721
760
|
array: `The ${t} field must contain items where each item is less than or equal to ${n(r)} kilobytes.`
|
|
722
761
|
};
|
|
723
762
|
},
|
|
724
|
-
|
|
725
|
-
const {
|
|
763
|
+
gt: (t, e) => {
|
|
764
|
+
const { value: r } = e;
|
|
726
765
|
return {
|
|
727
|
-
|
|
728
|
-
array: `The ${t} field must contain items where each item is ${n(r)}
|
|
766
|
+
number: `The ${t} field must be greater than ${n(r)}.`,
|
|
767
|
+
array: `The ${t} field must contain items where each item is greater than ${n(r)}.`
|
|
768
|
+
};
|
|
769
|
+
},
|
|
770
|
+
gte: (t, e) => {
|
|
771
|
+
const { value: r } = e;
|
|
772
|
+
return {
|
|
773
|
+
number: `The ${t} field must be greater than or equal to ${n(r)}.`,
|
|
774
|
+
array: `The ${t} field must contain items where each item is greater than or equal to ${n(r)}.`
|
|
729
775
|
};
|
|
730
776
|
},
|
|
731
777
|
http: (t) => `The ${t} field must start with the "http://" protocol.`,
|
|
@@ -751,32 +797,22 @@ const Z = {
|
|
|
751
797
|
array: `The ${t} field must contain items where each item is less than or equal to ${n(r)}.`
|
|
752
798
|
};
|
|
753
799
|
},
|
|
754
|
-
|
|
800
|
+
notContains: (t, e) => {
|
|
755
801
|
const { value: r } = e;
|
|
756
|
-
return {
|
|
757
|
-
number: `The ${t} field must be greater than ${n(r)}.`,
|
|
758
|
-
array: `The ${t} field must contain items where each item is greater than ${n(r)}.`
|
|
759
|
-
};
|
|
760
|
-
},
|
|
761
|
-
gte: (t, e) => {
|
|
762
|
-
const { value: r } = e;
|
|
763
|
-
return {
|
|
764
|
-
number: `The ${t} field must be greater than or equal to ${n(r)}.`,
|
|
765
|
-
array: `The ${t} field must contain items where each item is greater than or equal to ${n(r)}.`
|
|
766
|
-
};
|
|
802
|
+
return `The ${t} field must not contain ${i(r)}.`;
|
|
767
803
|
},
|
|
768
804
|
notContainsAll: (t, e) => {
|
|
769
805
|
const { values: r } = e;
|
|
770
806
|
return `The ${t} field must not contain all of the following values together: ${r.map(i).join(", ")}.`;
|
|
771
807
|
},
|
|
772
|
-
notEndsWith: (t, e) => {
|
|
773
|
-
const { value: r } = e;
|
|
774
|
-
return `The ${t} field must not end with ${i(r)}.`;
|
|
775
|
-
},
|
|
776
808
|
notContainsAny: (t, e) => {
|
|
777
809
|
const { values: r } = e;
|
|
778
810
|
return `The ${t} field must not contain any of the following values: ${r.map(i).join(", ")}.`;
|
|
779
811
|
},
|
|
812
|
+
notEndsWith: (t, e) => {
|
|
813
|
+
const { value: r } = e;
|
|
814
|
+
return `The ${t} field must not end with ${i(r)}.`;
|
|
815
|
+
},
|
|
780
816
|
notEquals: (t, e) => {
|
|
781
817
|
const { value: r } = e;
|
|
782
818
|
return `The ${t} field must not be equal to ${r}.`;
|
|
@@ -828,6 +864,10 @@ const Z = {
|
|
|
828
864
|
},
|
|
829
865
|
startsWithNumber: (t) => `The ${t} field must start with a number.`,
|
|
830
866
|
string: (t) => `The ${t} field must be a string.`,
|
|
867
|
+
stringContains: (t, e) => {
|
|
868
|
+
const { value: r } = e;
|
|
869
|
+
return `The ${t} field must contain ${i(r)}.`;
|
|
870
|
+
},
|
|
831
871
|
stringContainsAll: (t, e) => {
|
|
832
872
|
const { values: r } = e;
|
|
833
873
|
return `The ${t} field must contain all of the following text: ${r.map(i).join(", ")}.`;
|
|
@@ -878,6 +918,10 @@ const Z = {
|
|
|
878
918
|
array: `The ${t} field must contain items where each item is less than or equal to ${n(r)} characters.`
|
|
879
919
|
};
|
|
880
920
|
},
|
|
921
|
+
stringNotContains: (t, e) => {
|
|
922
|
+
const { value: r } = e;
|
|
923
|
+
return `The ${t} field must not contain ${i(r)}.`;
|
|
924
|
+
},
|
|
881
925
|
stringNotContainsAll: (t, e) => {
|
|
882
926
|
const { values: r } = e;
|
|
883
927
|
return `The ${t} field must not contain all of the following text together: ${r.map(i).join(", ")}.`;
|
|
@@ -893,7 +937,7 @@ const Z = {
|
|
|
893
937
|
unique: (t) => `The ${t} field has already been taken.`,
|
|
894
938
|
uppercase: (t) => `The ${t} field must be uppercase.`,
|
|
895
939
|
url: (t) => `The ${t} field must be a valid URL.`
|
|
896
|
-
},
|
|
940
|
+
}, M = {
|
|
897
941
|
accepted: () => "此欄位必須被同意",
|
|
898
942
|
alpha: () => "此欄位只能包含字母",
|
|
899
943
|
alphaDash: () => "此欄位只能包含字母、數字、連接號和底線",
|
|
@@ -933,6 +977,10 @@ const Z = {
|
|
|
933
977
|
};
|
|
934
978
|
},
|
|
935
979
|
boolean: () => "此欄位必須是一個布林值",
|
|
980
|
+
contains: (t, e) => {
|
|
981
|
+
const { value: r } = e;
|
|
982
|
+
return `此欄位必須包含${i(r)}`;
|
|
983
|
+
},
|
|
936
984
|
containsAll: (t, e) => {
|
|
937
985
|
const { values: r } = e;
|
|
938
986
|
return `此欄位必須包含以下所有項目:${r.map(i).join(", ")}`;
|
|
@@ -1037,18 +1085,22 @@ const Z = {
|
|
|
1037
1085
|
array: `此欄位中的每個項目都必須小於或等於${n(r)}`
|
|
1038
1086
|
};
|
|
1039
1087
|
},
|
|
1088
|
+
notContains: (t, e) => {
|
|
1089
|
+
const { values: r } = e;
|
|
1090
|
+
return `此欄位不能包含${i(r)}`;
|
|
1091
|
+
},
|
|
1040
1092
|
notContainsAll: (t, e) => {
|
|
1041
1093
|
const { values: r } = e;
|
|
1042
1094
|
return `此欄位不能同時包含以下所有值:${r.map(i).join(", ")}`;
|
|
1043
1095
|
},
|
|
1044
|
-
notEndsWith: (t, e) => {
|
|
1045
|
-
const { value: r } = e;
|
|
1046
|
-
return `此欄位不能以${i(r)}結尾`;
|
|
1047
|
-
},
|
|
1048
1096
|
notContainsAny: (t, e) => {
|
|
1049
1097
|
const { values: r } = e;
|
|
1050
1098
|
return `此欄位不能包含以下任何值:${r.map(i).join(", ")}`;
|
|
1051
1099
|
},
|
|
1100
|
+
notEndsWith: (t, e) => {
|
|
1101
|
+
const { value: r } = e;
|
|
1102
|
+
return `此欄位不能以${i(r)}結尾`;
|
|
1103
|
+
},
|
|
1052
1104
|
notEquals: (t, e) => {
|
|
1053
1105
|
const { value: r } = e;
|
|
1054
1106
|
return `此欄位不能是${r}`;
|
|
@@ -1100,6 +1152,10 @@ const Z = {
|
|
|
1100
1152
|
},
|
|
1101
1153
|
startsWithNumber: () => "此欄位必須以數字開頭",
|
|
1102
1154
|
string: () => "此欄位必須是字串",
|
|
1155
|
+
stringContains: (t, e) => {
|
|
1156
|
+
const { value: r } = e;
|
|
1157
|
+
return `此欄位必須包含${i(r)}`;
|
|
1158
|
+
},
|
|
1103
1159
|
stringContainsAll: (t, e) => {
|
|
1104
1160
|
const { values: r } = e;
|
|
1105
1161
|
return `此欄位必須包含以下所有文字:${r.map(i).join(", ")}`;
|
|
@@ -1150,6 +1206,10 @@ const Z = {
|
|
|
1150
1206
|
array: `此欄位中的每個項目都必須小於或等於${n(r)}個字元`
|
|
1151
1207
|
};
|
|
1152
1208
|
},
|
|
1209
|
+
stringNotContains: (t, e) => {
|
|
1210
|
+
const { value: r } = e;
|
|
1211
|
+
return `此欄位不能包含${i(r)}`;
|
|
1212
|
+
},
|
|
1153
1213
|
stringNotContainsAll: (t, e) => {
|
|
1154
1214
|
const { values: r } = e;
|
|
1155
1215
|
return `此欄位不能同時包含以下所有文字:${r.map(i).join(", ")}`;
|
|
@@ -1165,10 +1225,10 @@ const Z = {
|
|
|
1165
1225
|
unique: () => "此欄位已經存在",
|
|
1166
1226
|
uppercase: () => "此欄位必須是大寫",
|
|
1167
1227
|
url: () => "此欄位必須是有效的 URL"
|
|
1168
|
-
},
|
|
1169
|
-
en:
|
|
1170
|
-
"zh-TW":
|
|
1171
|
-
},
|
|
1228
|
+
}, U = {
|
|
1229
|
+
en: H,
|
|
1230
|
+
"zh-TW": M
|
|
1231
|
+
}, J = () => (t) => s(t) ? !1 : ["y", "yes", "on", "1", "true"].includes(String(t).toLowerCase()), V = () => (t) => s(t) ? !1 : /^[a-zA-Z]+$/.test(String(t)), Q = () => (t) => s(t) ? !1 : /^[a-zA-Z0-9-_]+$/.test(String(t)), X = () => (t) => s(t) ? !1 : /^[a-zA-Z0-9-_.]+$/.test(String(t)), Y = () => (t) => s(t) ? !1 : /^[a-zA-Z0-9]+$/.test(String(t)), ee = () => (t) => Array.isArray(t), te = ({ length: t }) => (e) => s(e) ? !1 : Array.isArray(e) ? e.length === t : !1, v = ({ length: t }) => (e) => s(e) ? !1 : Array.isArray(e) ? e.length >= t : !1, w = ({ length: t }) => (e) => s(e) ? !1 : Array.isArray(e) ? e.length <= t : !1, re = ({ min: t, max: e }) => (r) => s(r) ? !1 : v({ length: t })(r) && w({ length: e })(r), ne = ({ length: t }) => (e) => s(e) ? !1 : Array.isArray(e) ? e.length > t : !1, se = ({ length: t }) => (e) => s(e) ? !1 : Array.isArray(e) ? e.length < t : !1, ae = () => (t) => s(t) ? !1 : /^[\x20-\x7E]+$/.test(String(t)), h = ({ value: t }) => (e) => s(e) ? !1 : typeof e == "number" ? e >= t : Array.isArray(e) ? e.every((r) => h({ value: t })(r)) : !1, f = ({ value: t }) => (e) => s(e) ? !1 : typeof e == "number" ? e <= t : Array.isArray(e) ? e.every((r) => f({ value: t })(r)) : !1, ie = ({ min: t, max: e }) => (r) => s(r) ? !1 : h({ value: t })(r) && f({ value: e })(r), le = () => (t) => s(t) ? !1 : typeof t == "boolean", oe = ({ value: t }) => (e) => s(e) ? !1 : Array.isArray(e) ? e.includes(t) : !1, ue = ({ values: t }) => (e) => s(e) ? !1 : Array.isArray(e) ? t.every((r) => e.includes(r)) : !1, he = ({ values: t }) => (e) => s(e) ? !1 : Array.isArray(e) ? t.some((r) => e.includes(r)) : !1, fe = () => (t) => s(t) ? !1 : ["n", "no", "off", "0", "false"].includes(String(t).toLowerCase()), ce = ({ value: t }) => (e) => s(e) ? !1 : e !== t, me = () => (t) => s(t) ? !1 : Array.isArray(t) ? new Set(t).size === t.length : !0, ye = () => (t) => s(t) ? !1 : /^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(String(t)), ge = () => (t) => s(t) ? !1 : /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(String(t)), T = ({ value: t }) => (e) => s(e) ? !1 : String(e).toLowerCase().endsWith(t.toLowerCase()), $e = ({ value: t }) => (e) => e === t, de = () => (t) => t instanceof File, R = ({ size: t }) => (e) => {
|
|
1172
1232
|
if (s(e))
|
|
1173
1233
|
return !1;
|
|
1174
1234
|
if (e instanceof File) {
|
|
@@ -1176,7 +1236,7 @@ const Z = {
|
|
|
1176
1236
|
return e.size >= r && e.size < a;
|
|
1177
1237
|
}
|
|
1178
1238
|
return Array.isArray(e) ? e.every((r) => R({ size: t })(r)) : !1;
|
|
1179
|
-
}, c = ({ size: t }) => (e) => s(e) ? !1 : e instanceof File ? e.size >= t * 1024 : Array.isArray(e) ? e.every((r) => c({ size: t })(r)) : !1, m = ({ size: t }) => (e) => s(e) ? !1 : e instanceof File ? e.size <= t * 1024 : Array.isArray(e) ? e.every((r) => m({ size: t })(r)) : !1,
|
|
1239
|
+
}, c = ({ size: t }) => (e) => s(e) ? !1 : e instanceof File ? e.size >= t * 1024 : Array.isArray(e) ? e.every((r) => c({ size: t })(r)) : !1, m = ({ size: t }) => (e) => s(e) ? !1 : e instanceof File ? e.size <= t * 1024 : Array.isArray(e) ? e.every((r) => m({ size: t })(r)) : !1, pe = ({ min: t, max: e }) => (r) => s(r) ? !1 : c({ size: t })(r) && m({ size: e })(r), S = ({ size: t }) => (e) => s(e) ? !1 : e instanceof File ? e.size > t * 1024 : Array.isArray(e) ? e.every((r) => S({ size: t })(r)) : !1, z = ({ size: t }) => (e) => s(e) ? !1 : e instanceof File ? e.size < t * 1024 : Array.isArray(e) ? e.every((r) => z({ size: t })(r)) : !1, C = ({ value: t }) => (e) => s(e) ? !1 : typeof e == "number" ? e > t : Array.isArray(e) ? e.every((r) => C({ value: t })(r)) : !1, y = ({ value: t }) => (e) => s(e) ? !1 : String(e).toLowerCase().startsWith(t.toLowerCase()), g = ({ values: t }) => (e) => s(e) ? !1 : t.map((r) => `${r}://`).some((r) => y({ value: r })(e)), _ = () => (t) => s(t) ? !1 : g({ values: ["http"] })(t), j = () => (t) => s(t) ? !1 : g({ values: ["https"] })(t), be = () => (t) => s(t) ? !1 : _()(t) || j()(t), $ = () => (t) => s(t) ? !1 : typeof t == "number", Ae = () => (t) => s(t) ? !1 : $()(t) && Number.isInteger(t), d = ({ includeProtocol: t } = {}) => (e) => {
|
|
1180
1240
|
if (s(e))
|
|
1181
1241
|
return !1;
|
|
1182
1242
|
if (t)
|
|
@@ -1198,7 +1258,7 @@ const Z = {
|
|
|
1198
1258
|
return !1;
|
|
1199
1259
|
}
|
|
1200
1260
|
return /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/.test(String(e));
|
|
1201
|
-
},
|
|
1261
|
+
}, Le = ({ includeProtocol: t } = {}) => (e) => s(e) ? !1 : d({ includeProtocol: t })(e) || p({ includeProtocol: t })(e), ve = () => (t) => {
|
|
1202
1262
|
if (s(t))
|
|
1203
1263
|
return !1;
|
|
1204
1264
|
try {
|
|
@@ -1206,13 +1266,13 @@ const Z = {
|
|
|
1206
1266
|
} catch {
|
|
1207
1267
|
return !1;
|
|
1208
1268
|
}
|
|
1209
|
-
},
|
|
1269
|
+
}, we = () => (t) => s(t) ? !1 : String(t) === String(t).toLowerCase(), F = ({ value: t }) => (e) => s(e) ? !1 : typeof e == "number" ? e < t : Array.isArray(e) ? e.every((r) => F({ value: t })(r)) : !1, Te = ({ value: t }) => (e) => s(e) ? !1 : Array.isArray(e) ? !e.includes(t) : !1, Re = ({ values: t }) => (e) => s(e) ? !1 : Array.isArray(e) ? !t.every((r) => e.includes(r)) : !1, Se = ({ values: t }) => (e) => s(e) ? !1 : Array.isArray(e) ? !t.some((r) => e.includes(r)) : !1, ze = ({ value: t }) => (e) => s(e) ? !1 : !T({ value: t })(e), Ce = ({ value: t }) => (e) => e !== t, q = ({ values: t }) => (e) => s(e) ? !1 : !t.includes(e), _e = ({ value: t }) => (e) => s(e) ? !1 : !y({ value: t })(e), O = () => (t) => s(t) ? !1 : /^\d/.test(String(t)), je = () => (t) => s(t) ? !1 : !O()(t), Fe = ({ values: t }) => (e) => s(e) ? !1 : Array.isArray(e) ? e.some((r) => !t.includes(r)) : q({ values: t })(e), W = () => (t) => typeof t == "string", qe = () => (t) => s(t) ? !1 : W()(t) ? /^-?\d+(\.\d+)?$/.test(String(t)) : $()(t), Oe = () => (t) => typeof t == "object" && t !== null && !Array.isArray(t), G = ({ values: t }) => (e) => s(e) ? !1 : t.includes(e), We = ({ expression: t }) => (e) => {
|
|
1210
1270
|
if (s(e))
|
|
1211
1271
|
return !1;
|
|
1212
1272
|
if (!(t instanceof RegExp))
|
|
1213
1273
|
throw new TypeError("The expression provided is not a valid RegExp.");
|
|
1214
1274
|
return t.test(String(e));
|
|
1215
|
-
},
|
|
1275
|
+
}, Ge = () => (t) => !s(t), Ne = ({ value: t }) => (e) => s(e) ? !1 : Array.isArray(e) ? e.every((r) => r === t) : e === t, N = ({ size: t }) => (e) => s(e) ? !1 : typeof e == "number" ? e === t : Array.isArray(e) ? e.every((r) => N({ size: t })(r)) : !1, k = ({ value: t }) => (e) => s(e) ? !1 : typeof e == "string" ? e.includes(t) : !1, ke = ({ values: t }) => (e) => s(e) ? !1 : typeof e == "string" ? t.every((r) => k({ value: r })(e)) : !1, xe = ({ values: t }) => (e) => s(e) ? !1 : typeof e == "string" ? t.some((r) => e.includes(r)) : !1, x = ({ length: t }) => (e) => s(e) ? !1 : typeof e == "string" ? e.length === t : Array.isArray(e) ? e.every((r) => x({ length: t })(r)) : !1, b = ({ length: t }) => (e) => s(e) ? !1 : typeof e == "string" ? e.length >= t : Array.isArray(e) ? e.every((r) => b({ length: t })(r)) : !1, A = ({ length: t }) => (e) => s(e) ? !1 : typeof e == "string" ? e.length <= t : Array.isArray(e) ? e.every((r) => A({ length: t })(r)) : !1, Be = ({ min: t, max: e }) => (r) => s(r) ? !1 : b({ length: t })(r) && A({ length: e })(r), B = ({ length: t }) => (e) => s(e) ? !1 : typeof e == "string" ? e.length > t : Array.isArray(e) ? e.every((r) => B({ length: t })(r)) : !1, E = ({ length: t }) => (e) => s(e) ? !1 : typeof e == "string" ? e.length < t : Array.isArray(e) ? e.every((r) => E({ length: t })(r)) : !1, Ee = ({ value: t }) => (e) => s(e) ? !1 : typeof e == "string" ? !e.includes(t) : !1, De = ({ values: t }) => (e) => s(e) ? !1 : typeof e == "string" ? !t.every((r) => e.includes(r)) : !1, Pe = ({ values: t }) => (e) => s(e) ? !1 : typeof e == "string" ? !t.some((r) => e.includes(r)) : !1, Ie = ({ values: t }) => (e) => s(e) ? !1 : Array.isArray(e) ? e.every((r) => t.includes(r)) : G({ values: t })(e), Ke = ({ values: t, ignored: e = [] }) => (r) => s(r) ? !1 : (Array.isArray(e) ? e : [e]).some((a) => a === r) ? !0 : !t.some((a) => a === r), Ze = () => (t) => s(t) ? !1 : String(t) === String(t).toUpperCase(), He = () => (t) => {
|
|
1216
1276
|
if (s(t))
|
|
1217
1277
|
return !1;
|
|
1218
1278
|
try {
|
|
@@ -1220,87 +1280,91 @@ const Z = {
|
|
|
1220
1280
|
} catch {
|
|
1221
1281
|
return !1;
|
|
1222
1282
|
}
|
|
1223
|
-
},
|
|
1224
|
-
accepted:
|
|
1225
|
-
alpha:
|
|
1226
|
-
alphaDash:
|
|
1227
|
-
alphaDashDot:
|
|
1228
|
-
alphaNum:
|
|
1229
|
-
array:
|
|
1230
|
-
arrayLength:
|
|
1231
|
-
arrayLengthBetween:
|
|
1232
|
-
arrayLengthGt:
|
|
1233
|
-
arrayLengthGte:
|
|
1234
|
-
arrayLengthLt:
|
|
1235
|
-
arrayLengthLte:
|
|
1236
|
-
ascii:
|
|
1237
|
-
between:
|
|
1238
|
-
boolean:
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1283
|
+
}, Me = {
|
|
1284
|
+
accepted: J,
|
|
1285
|
+
alpha: V,
|
|
1286
|
+
alphaDash: Q,
|
|
1287
|
+
alphaDashDot: X,
|
|
1288
|
+
alphaNum: Y,
|
|
1289
|
+
array: ee,
|
|
1290
|
+
arrayLength: te,
|
|
1291
|
+
arrayLengthBetween: re,
|
|
1292
|
+
arrayLengthGt: ne,
|
|
1293
|
+
arrayLengthGte: v,
|
|
1294
|
+
arrayLengthLt: se,
|
|
1295
|
+
arrayLengthLte: w,
|
|
1296
|
+
ascii: ae,
|
|
1297
|
+
between: ie,
|
|
1298
|
+
boolean: le,
|
|
1299
|
+
contains: oe,
|
|
1300
|
+
containsAll: ue,
|
|
1301
|
+
containsAny: he,
|
|
1302
|
+
declined: fe,
|
|
1303
|
+
different: ce,
|
|
1304
|
+
distinct: me,
|
|
1305
|
+
domain: ye,
|
|
1306
|
+
email: ge,
|
|
1307
|
+
endsWith: T,
|
|
1308
|
+
equals: $e,
|
|
1309
|
+
file: de,
|
|
1249
1310
|
fileSize: R,
|
|
1250
|
-
fileSizeBetween:
|
|
1311
|
+
fileSizeBetween: pe,
|
|
1251
1312
|
fileSizeGt: S,
|
|
1252
1313
|
fileSizeGte: c,
|
|
1253
1314
|
fileSizeLt: z,
|
|
1254
1315
|
fileSizeLte: m,
|
|
1255
|
-
gt:
|
|
1316
|
+
gt: C,
|
|
1256
1317
|
gte: h,
|
|
1257
|
-
http:
|
|
1258
|
-
httpOrHttps:
|
|
1259
|
-
https:
|
|
1260
|
-
integer:
|
|
1261
|
-
ip:
|
|
1318
|
+
http: _,
|
|
1319
|
+
httpOrHttps: be,
|
|
1320
|
+
https: j,
|
|
1321
|
+
integer: Ae,
|
|
1322
|
+
ip: Le,
|
|
1262
1323
|
ipv4: d,
|
|
1263
1324
|
ipv6: p,
|
|
1264
|
-
json:
|
|
1265
|
-
lowercase:
|
|
1266
|
-
lt:
|
|
1325
|
+
json: ve,
|
|
1326
|
+
lowercase: we,
|
|
1327
|
+
lt: F,
|
|
1267
1328
|
lte: f,
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1329
|
+
notContains: Te,
|
|
1330
|
+
notContainsAll: Re,
|
|
1331
|
+
notContainsAny: Se,
|
|
1332
|
+
notEndsWith: ze,
|
|
1333
|
+
notEquals: Ce,
|
|
1272
1334
|
notOneOf: q,
|
|
1273
|
-
notStartsWith:
|
|
1274
|
-
notStartsWithNumber:
|
|
1275
|
-
notSubsetOf:
|
|
1335
|
+
notStartsWith: _e,
|
|
1336
|
+
notStartsWithNumber: je,
|
|
1337
|
+
notSubsetOf: Fe,
|
|
1276
1338
|
number: $,
|
|
1277
|
-
numeric:
|
|
1278
|
-
object:
|
|
1339
|
+
numeric: qe,
|
|
1340
|
+
object: Oe,
|
|
1279
1341
|
oneOf: G,
|
|
1280
1342
|
protocol: g,
|
|
1281
|
-
regex:
|
|
1282
|
-
required:
|
|
1283
|
-
same:
|
|
1284
|
-
size:
|
|
1343
|
+
regex: We,
|
|
1344
|
+
required: Ge,
|
|
1345
|
+
same: Ne,
|
|
1346
|
+
size: N,
|
|
1285
1347
|
startsWith: y,
|
|
1286
1348
|
startsWithNumber: O,
|
|
1287
1349
|
string: W,
|
|
1288
|
-
|
|
1289
|
-
|
|
1350
|
+
stringContains: k,
|
|
1351
|
+
stringContainsAll: ke,
|
|
1352
|
+
stringContainsAny: xe,
|
|
1290
1353
|
stringLength: x,
|
|
1291
|
-
stringLengthBetween:
|
|
1354
|
+
stringLengthBetween: Be,
|
|
1292
1355
|
stringLengthGt: B,
|
|
1293
1356
|
stringLengthGte: b,
|
|
1294
|
-
stringLengthLt:
|
|
1357
|
+
stringLengthLt: E,
|
|
1295
1358
|
stringLengthLte: A,
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1359
|
+
stringNotContains: Ee,
|
|
1360
|
+
stringNotContainsAll: De,
|
|
1361
|
+
stringNotContainsAny: Pe,
|
|
1362
|
+
subsetOf: Ie,
|
|
1363
|
+
unique: Ke,
|
|
1364
|
+
uppercase: Ze,
|
|
1365
|
+
url: He
|
|
1302
1366
|
};
|
|
1303
|
-
class
|
|
1367
|
+
class Je {
|
|
1304
1368
|
constructor({
|
|
1305
1369
|
fallbackLocale: e,
|
|
1306
1370
|
locale: r,
|
|
@@ -1310,7 +1374,7 @@ class Ze {
|
|
|
1310
1374
|
o(this, "fallbackLocale", "en");
|
|
1311
1375
|
o(this, "locales", {});
|
|
1312
1376
|
o(this, "rules", {});
|
|
1313
|
-
this.registerLocales(
|
|
1377
|
+
this.registerLocales(U), this.registerRules(Me), e && this.setFallbackLocale(e), r && this.setLocale(r), a && a.forEach((l) => this.registerPlugin(l));
|
|
1314
1378
|
}
|
|
1315
1379
|
getLocale() {
|
|
1316
1380
|
return this.locale;
|
|
@@ -1329,7 +1393,7 @@ class Ze {
|
|
|
1329
1393
|
return this.fallbackLocale = e, this;
|
|
1330
1394
|
}
|
|
1331
1395
|
defineField(e) {
|
|
1332
|
-
return new
|
|
1396
|
+
return new Z({
|
|
1333
1397
|
name: e,
|
|
1334
1398
|
locale: this.locale,
|
|
1335
1399
|
fallbackLocale: this.fallbackLocale,
|
|
@@ -1353,6 +1417,6 @@ class Ze {
|
|
|
1353
1417
|
}
|
|
1354
1418
|
}
|
|
1355
1419
|
export {
|
|
1356
|
-
|
|
1357
|
-
|
|
1420
|
+
Z as FieldValidator,
|
|
1421
|
+
Je as FormValidator
|
|
1358
1422
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(h,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(h=typeof globalThis<"u"?globalThis:h||self,o(h.Fortress={}))})(this,function(h){"use strict";var ke=Object.defineProperty;var Ne=(h,o,n)=>o in h?ke(h,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):h[o]=n;var u=(h,o,n)=>(Ne(h,typeof o!="symbol"?o+"":o,n),n);const o=t=>{const e=",、;:!?。()《》「」『』【】〔〕",r="\\x20-\\x7E",a=new RegExp(`\\s*([${e}])`,"gu"),l=new RegExp(`([${e}])\\s*([${r}])`,"gu"),f=new RegExp(`([^${r}${e}])([${r}])`,"gu"),Ge=new RegExp(`([${r}])([^${r}${e}])`,"gu");return t.replace(a,"$1").replace(l,"$1$2").replace(f,"$1 $2").replace(Ge,"$1 $2").replace(/ +/g," ")},n=(t,e=0)=>new Intl.NumberFormat(void 0,{minimumFractionDigits:e,maximumFractionDigits:e}).format(t),P=t=>Object.prototype.toString.call(t).toLowerCase().slice(8,-1),s=t=>t==null||t===""||Array.isArray(t)&&t.length<1,i=t=>`"${t}"`;class T{constructor({name:e,locale:r,fallbackLocale:a,locales:l,rules:f}){u(this,"name");u(this,"locale");u(this,"fallbackLocale");u(this,"locales");u(this,"rules");u(this,"ruleFunctions",{});u(this,"conditions",{});u(this,"shouldSkip",!1);u(this,"appliedProtocols",{});this.name=e,this.locale=r,this.fallbackLocale=a,this.locales=l,this.rules=f}get formattedName(){return this.name.toLowerCase()}get messages(){return this.locales[this.locale]||{}}get fallbackMessages(){return this.locales[this.fallbackLocale]||{}}get mandatoryRules(){return[this.required.name,this.string.name,this.array.name,this.equals.name,this.notEquals.name]}getMessage(e){return this.messages[e]||this.fallbackMessages[e]||(r=>`The ${r} field is invalid.`)}getRule(e){if(!(e in this.rules))throw new Error(`The "${e}" rule is not registered.`);return this.rules[e]}buildRuleFunction(e,r){return a=>{if(s(a)&&!this.mandatoryRules.includes(e))return!0;const l=this.getRule(e)(r)(a);return typeof l=="string"?l:l===!0?!0:this.buildRuleFunctionMessage(e,r,a)}}buildRuleFunctionMessage(e,r,a){const l=this.getMessage(e)(this.formattedName,r);if(typeof l=="object"){const f=P(a);if(!(f in l))throw new Error(`The message for the "${e}" rule of the "${f}" type is missing.`);return o(l[f])}return o(l)}pushRuleFunction(e,r){if(e in this.conditions&&!this.conditions[e])return this;const a=this.buildRuleFunction(e,r);return this.ruleFunctions[e]=a,this}getRuleFunctions(){return Object.values(this.ruleFunctions)}collect(){return this.shouldSkip?[]:this.getRuleFunctions()}validate(e){if(this.shouldSkip)return!0;const r=this.getRuleFunctions();for(const a of r){const l=a(e);if(typeof l=="string")return l}return!0}apply(e,r={}){return this.pushRuleFunction(e,r)}accepted(){return this.apply(this.accepted.name)}after(e,r,a,l=!0){return this.apply(this.after.name,{date:e,format:r,displayFormat:a,strict:l})}alpha(){return this.apply(this.alpha.name)}alphaDash(){return this.apply(this.alphaDash.name)}alphaDashDot(){return this.apply(this.alphaDashDot.name)}alphaNum(){return this.apply(this.alphaNum.name)}array(){return this.apply(this.array.name)}arrayLength(e){return this.apply(this.arrayLength.name,{length:e})}arrayLengthBetween(e,r){return this.apply(this.arrayLengthBetween.name,{min:e,max:r})}arrayLengthGt(e){return this.apply(this.arrayLengthGt.name,{length:e})}arrayLengthGte(e){return this.apply(this.arrayLengthGte.name,{length:e})}arrayLengthLt(e){return this.apply(this.arrayLengthLt.name,{length:e})}arrayLengthLte(e){return this.apply(this.arrayLengthLte.name,{length:e})}ascii(){return this.apply(this.ascii.name)}before(e,r,a,l=!0){return this.apply(this.before.name,{date:e,format:r,displayFormat:a,strict:l})}between(e,r){return this.apply(this.between.name,{min:e,max:r})}boolean(){return this.apply(this.boolean.name)}containsAll(e){return this.apply(this.containsAll.name,{values:e})}containsAny(e){return this.apply(this.containsAny.name,{values:e})}date(e,r=!0){return this.apply(this.date.name,{format:e,strict:r})}declined(){return this.apply(this.declined.name)}different(e,r){return this.apply(this.different.name,{field:e,value:r})}distinct(){return this.apply(this.distinct.name)}domain(){return this.apply(this.domain.name)}email(){return this.apply(this.email.name)}endsWith(e){return this.apply(this.endsWith.name,{value:e})}equals(e){return this.apply(this.equals.name,{value:e})}file(){return this.apply(this.file.name)}fileSize(e){return this.apply(this.fileSize.name,{size:e})}fileSizeBetween(e,r){return this.apply(this.fileSizeBetween.name,{min:e,max:r})}fileSizeGt(e){return this.apply(this.fileSizeGt.name,{size:e})}fileSizeGte(e){return this.apply(this.fileSizeGte.name,{size:e})}fileSizeLt(e){return this.apply(this.fileSizeLt.name,{size:e})}fileSizeLte(e){return this.apply(this.fileSizeLte.name,{size:e})}gt(e){return this.apply(this.gt.name,{value:e})}gte(e){return this.apply(this.gte.name,{value:e})}http(){return this.appliedProtocols[this.http.name]=!0,this.apply(this.http.name)}httpOrHttps(){return this.appliedProtocols[this.http.name]=!0,this.appliedProtocols[this.https.name]=!0,this.apply(this.httpOrHttps.name)}https(){return this.appliedProtocols[this.https.name]=!0,this.apply(this.https.name)}integer(){return this.apply(this.integer.name)}ip(){const e=Object.keys(this.appliedProtocols).length>0;return this.apply(this.ip.name,{includeProtocol:e})}ipv4(){const e=Object.keys(this.appliedProtocols).length>0;return this.apply(this.ipv4.name,{includeProtocol:e})}ipv6(){const e=Object.keys(this.appliedProtocols).length>0;return this.apply(this.ipv6.name,{includeProtocol:e})}iso8601(){return this.apply(this.iso8601.name)}json(){return this.apply(this.json.name)}jsonSchema(e){return this.apply(this.jsonSchema.name,{schema:e,locale:this.locale,field:this.name})}lowercase(){return this.apply(this.lowercase.name)}lt(e){return this.apply(this.lt.name,{value:e})}lte(e){return this.apply(this.lte.name,{value:e})}notContainsAll(e){return this.apply(this.notContainsAll.name,{values:e})}notContainsAny(e){return this.apply(this.notContainsAny.name,{values:e})}notEndsWith(e){return this.apply(this.notEndsWith.name,{value:e})}notEquals(e){return this.apply(this.notEquals.name,{value:e})}notOneOf(e){return this.apply(this.notOneOf.name,{values:e})}notStartsWith(e){return this.apply(this.notStartsWith.name,{value:e})}notStartsWithNumber(){return this.apply(this.notStartsWithNumber.name)}notSubsetOf(e){return this.apply(this.notSubsetOf.name,{values:e})}number(){return this.apply(this.number.name)}numeric(){return this.apply(this.numeric.name)}object(){return this.apply(this.object.name)}oneOf(e){return this.apply(this.oneOf.name,{values:e})}protocol(e){const r=Array.isArray(e)?e:[e];return r.forEach(a=>this.appliedProtocols[a]=!0),this.apply(this.protocol.name,{values:r})}regex(e){return this.apply(this.regex.name,{expression:e})}required(){return this.apply(this.required.name)}requiredWhen(e){return this.when({required:e}).required()}same(e,r){return this.apply(this.same.name,{field:e,value:r})}size(e){return this.apply(this.size.name,{size:e})}startsWith(e){return this.apply(this.startsWith.name,{value:e})}startsWithNumber(){return this.apply(this.startsWithNumber.name)}string(){return this.apply(this.string.name)}stringContainsAll(e){return this.apply(this.stringContainsAll.name,{values:e})}stringContainsAny(e){return this.apply(this.stringContainsAny.name,{values:e})}stringLength(e){return this.apply(this.stringLength.name,{length:e})}stringLengthBetween(e,r){return this.apply(this.stringLengthBetween.name,{min:e,max:r})}stringLengthGt(e){return this.apply(this.stringLengthGt.name,{length:e})}stringLengthGte(e){return this.apply(this.stringLengthGte.name,{length:e})}stringLengthLt(e){return this.apply(this.stringLengthLt.name,{length:e})}stringLengthLte(e){return this.apply(this.stringLengthLte.name,{length:e})}stringNotContainsAll(e){return this.apply(this.stringNotContainsAll.name,{values:e})}stringNotContainsAny(e){return this.apply(this.stringNotContainsAny.name,{values:e})}subsetOf(e){return this.apply(this.subsetOf.name,{values:e})}unique(e,r=[]){return this.apply(this.unique.name,{values:e,ignored:r})}uppercase(){return this.apply(this.uppercase.name)}url(){return this.apply(this.url.name)}when(e){return typeof e=="object"?(this.conditions=e,this):(e||(this.shouldSkip=!0),this)}}const I={en:{accepted:t=>`The ${t} field must be accepted.`,alpha:t=>`The ${t} field must only contain letters.`,alphaDash:t=>`The ${t} field must only contain letters, numbers, dashes and underscores.`,alphaDashDot:t=>`The ${t} field must only contain letters, numbers, dashes, underscores and dots.`,alphaNum:t=>`The ${t} field must only contain letters and numbers.`,array:t=>`The ${t} field must be an array.`,arrayLength:(t,e)=>{const{length:r}=e;return`The ${t} field must be ${n(r)} items.`},arrayLengthBetween:(t,e)=>{const{min:r,max:a}=e;return`The ${t} field must be between ${n(r)} and ${n(a)} items.`},arrayLengthGt:(t,e)=>{const{length:r}=e;return`The ${t} field must be greater than ${n(r)} items.`},arrayLengthGte:(t,e)=>{const{length:r}=e;return`The ${t} field must be greater than or equal to ${n(r)} items.`},arrayLengthLte:(t,e)=>{const{length:r}=e;return`The ${t} field must be less than or equal to ${n(r)} items.`},arrayLengthLt:(t,e)=>{const{length:r}=e;return`The ${t} field must be less than ${n(r)} items.`},ascii:t=>`The ${t} field must only contain ASCII characters and symbols.`,between:(t,e)=>{const{min:r,max:a}=e;return{number:`The ${t} field must be between ${n(r)} and ${n(a)}.`,array:`The ${t} field must contain items where each item is between ${n(r)} and ${n(a)}.`}},boolean:t=>`The ${t} field must be a boolean value.`,containsAll:(t,e)=>{const{values:r}=e;return`The ${t} field must contain all of the following values: ${r.map(i).join(", ")}.`},containsAny:(t,e)=>{const{values:r}=e;return`The ${t} field must contain at least one of the following values: ${r.map(i).join(", ")}.`},declined:t=>`The ${t} field must be declined.`,different:(t,e)=>{const{field:r}=e;return`The ${t} and ${r} fields must be different.`},distinct:t=>`The ${t} field must not contain duplicate values.`,domain:t=>`The ${t} field must be a valid domain.`,email:t=>`The ${t} field must be a valid email address.`,endsWith:(t,e)=>{const{value:r}=e;return`The ${t} field must end with ${i(r)}.`},equals:(t,e)=>{const{value:r}=e;return`The ${t} field must be equal to ${r}.`},file:t=>`The ${t} field must be a file.`,fileSizeBetween:(t,e)=>{const{min:r,max:a}=e;return{file:`The ${t} field must be between ${n(r)} and ${n(a)} kilobytes.`,array:`The ${t} field must contain items where each item is between ${n(r)} and ${n(a)} kilobytes.`}},fileSizeGt:(t,e)=>{const{size:r}=e;return{file:`The ${t} field must be greater than ${n(r)} kilobytes.`,array:`The ${t} field must contain items where each item is greater than ${n(r)} kilobytes.`}},fileSizeGte:(t,e)=>{const{size:r}=e;return{file:`The ${t} field must be greater than or equal to ${n(r)} kilobytes.`,array:`The ${t} field must contain items where each item is greater than or equal to ${n(r)} kilobytes.`}},fileSizeLt:(t,e)=>{const{size:r}=e;return{file:`The ${t} field must be less than ${n(r)} kilobytes.`,array:`The ${t} field must contain items where each item is less than ${n(r)} kilobytes.`}},fileSizeLte:(t,e)=>{const{size:r}=e;return{file:`The ${t} field must be less than or equal to ${n(r)} kilobytes.`,array:`The ${t} field must contain items where each item is less than or equal to ${n(r)} kilobytes.`}},fileSize:(t,e)=>{const{size:r}=e;return{file:`The ${t} field must be ${n(r)} kilobytes.`,array:`The ${t} field must contain items where each item is ${n(r)} kilobytes.`}},http:t=>`The ${t} field must start with the "http://" protocol.`,httpOrHttps:t=>`The ${t} field must start with the "http://" or "https://" protocols.`,https:t=>`The ${t} field must start with the "https://" protocol.`,integer:t=>`The ${t} field must be an integer.`,ip:t=>`The ${t} field must be a valid IP address.`,ipv4:t=>`The ${t} field must be a valid IPv4 address.`,ipv6:t=>`The ${t} field must be a valid IPv6 address.`,json:t=>`The ${t} field must be a valid JSON string.`,lowercase:t=>`The ${t} field must be lowercase.`,lt:(t,e)=>{const{value:r}=e;return{number:`The ${t} field must be less than ${n(r)}.`,array:`The ${t} field must contain items where each item is less than ${n(r)}.`}},lte:(t,e)=>{const{value:r}=e;return{number:`The ${t} field must be less than or equal to ${n(r)}.`,array:`The ${t} field must contain items where each item is less than or equal to ${n(r)}.`}},gt:(t,e)=>{const{value:r}=e;return{number:`The ${t} field must be greater than ${n(r)}.`,array:`The ${t} field must contain items where each item is greater than ${n(r)}.`}},gte:(t,e)=>{const{value:r}=e;return{number:`The ${t} field must be greater than or equal to ${n(r)}.`,array:`The ${t} field must contain items where each item is greater than or equal to ${n(r)}.`}},notContainsAll:(t,e)=>{const{values:r}=e;return`The ${t} field must not contain all of the following values together: ${r.map(i).join(", ")}.`},notEndsWith:(t,e)=>{const{value:r}=e;return`The ${t} field must not end with ${i(r)}.`},notContainsAny:(t,e)=>{const{values:r}=e;return`The ${t} field must not contain any of the following values: ${r.map(i).join(", ")}.`},notEquals:(t,e)=>{const{value:r}=e;return`The ${t} field must not be equal to ${r}.`},notOneOf:(t,e)=>{const{values:r}=e;return`The ${t} field must not be one of the following values: ${r.map(i).join(", ")}.`},notStartsWith:(t,e)=>{const{value:r}=e;return`The ${t} field must not start with ${i(r)}.`},notStartsWithNumber:t=>`The ${t} field must not start with a number.`,notSubsetOf:(t,e)=>{const{values:r}=e;return`The ${t} field must not be a subset of the following values: ${r.map(i).join(", ")}.`},number:t=>`The ${t} field must be a number.`,numeric:t=>`The ${t} field must be a number.`,object:t=>`The ${t} field must be an object.`,oneOf:(t,e)=>{const{values:r}=e;return`The ${t} field must be one of the following values: ${r.map(i).join(", ")}.`},protocol:(t,e)=>{const{values:r}=e;if(r.length===1){const[a]=r;return`The ${t} field must start with the "${a}://" protocol.`}return`The ${t} field must start with one of the following protocols: ${r.map(a=>`${a}://`).map(i).join(", ")}.`},regex:t=>`The ${t} field must match the required format.`,required:t=>`The ${t} field is required.`,same:(t,e)=>{const{field:r}=e;return`The ${t} and ${r} fields must match.`},size:(t,e)=>{const{size:r}=e;return{number:`The ${t} field must be ${n(r)}.`,array:`The ${t} field must contain items where each item is ${n(r)}.`}},startsWith:(t,e)=>{const{value:r}=e;return`The ${t} field must start with ${i(r)}.`},startsWithNumber:t=>`The ${t} field must start with a number.`,string:t=>`The ${t} field must be a string.`,stringContainsAll:(t,e)=>{const{values:r}=e;return`The ${t} field must contain all of the following text: ${r.map(i).join(", ")}.`},stringContainsAny:(t,e)=>{const{values:r}=e;return`The ${t} field must contain at least one of the following text: ${r.map(i).join(", ")}.`},stringLength:(t,e)=>{const{length:r}=e;return{string:`The ${t} field must be ${n(r)} characters.`,array:`The ${t} field must contain items where each item is ${n(r)} characters.`}},stringLengthBetween:(t,e)=>{const{min:r,max:a}=e;return{string:`The ${t} field must be between ${n(r)} and ${n(a)} characters.`,array:`The ${t} field must contain items where each item is between ${n(r)} and ${n(a)} characters.`}},stringLengthGt:(t,e)=>{const{length:r}=e;return{string:`The ${t} field must be greater than ${n(r)} characters.`,array:`The ${t} field must contain items where each item is greater than ${n(r)} characters.`}},stringLengthGte:(t,e)=>{const{length:r}=e;return{string:`The ${t} field must be greater than or equal to ${n(r)} characters.`,array:`The ${t} field must contain items where each item is greater than or equal to ${n(r)} characters.`}},stringLengthLt:(t,e)=>{const{length:r}=e;return{string:`The ${t} field must be less than ${n(r)} characters.`,array:`The ${t} field must contain items where each item is less than ${n(r)} characters.`}},stringLengthLte:(t,e)=>{const{length:r}=e;return{string:`The ${t} field must be less than or equal to ${n(r)} characters.`,array:`The ${t} field must contain items where each item is less than or equal to ${n(r)} characters.`}},stringNotContainsAll:(t,e)=>{const{values:r}=e;return`The ${t} field must not contain all of the following text together: ${r.map(i).join(", ")}.`},stringNotContainsAny:(t,e)=>{const{values:r}=e;return`The ${t} field must not contain any of the following text: ${r.map(i).join(", ")}.`},subsetOf:(t,e)=>{const{values:r}=e;return`The ${t} field must be a subset of the following values: ${r.map(i).join(", ")}.`},unique:t=>`The ${t} field has already been taken.`,uppercase:t=>`The ${t} field must be uppercase.`,url:t=>`The ${t} field must be a valid URL.`},"zh-TW":{accepted:()=>"此欄位必須被同意",alpha:()=>"此欄位只能包含字母",alphaDash:()=>"此欄位只能包含字母、數字、連接號和底線",alphaDashDot:()=>"此欄位只能包含字母、數字、連接號、底線和點",alphaNum:()=>"此欄位只能包含字母和數字",array:()=>"此欄位必須是一個陣列",arrayLength:(t,e)=>{const{length:r}=e;return`此欄位必須是${n(r)}個項目`},arrayLengthBetween:(t,e)=>{const{min:r,max:a}=e;return`此欄位必須介於${n(r)}到${n(a)}個項目之間`},arrayLengthGt:(t,e)=>{const{length:r}=e;return`此欄位必須大於${n(r)}個項目`},arrayLengthGte:(t,e)=>{const{length:r}=e;return`此欄位必須大於或等於${n(r)}個項目`},arrayLengthLt:(t,e)=>{const{length:r}=e;return`此欄位必須小於${n(r)}個項目`},arrayLengthLte:(t,e)=>{const{length:r}=e;return`此欄位必須小於或等於${n(r)}個項目`},ascii:()=>"此欄位只能包含 ASCII 字元和符號",between:(t,e)=>{const{min:r,max:a}=e;return{number:`此欄位必須介於${n(r)}到${n(a)}`,array:`此欄位中的每個項目都必須介於${n(r)}到${n(a)}`}},boolean:()=>"此欄位必須是一個布林值",containsAll:(t,e)=>{const{values:r}=e;return`此欄位必須包含以下所有項目:${r.map(i).join(", ")}`},containsAny:(t,e)=>{const{values:r}=e;return`此欄位必須包含以下其中一個項目:${r.map(i).join(", ")}`},declined:()=>"此欄位必須被拒絕",different:(t,e)=>{const{field:r}=e;return`此欄位必須和${r}欄位不同`},distinct:()=>"此欄位不能包含重複的值",domain:()=>"此欄位必須是有效的網域",email:()=>"此欄位必須是有效的電子郵件地址",endsWith:(t,e)=>{const{value:r}=e;return`此欄位必須以${i(r)}結尾`},equals:(t,e)=>{const{value:r}=e;return`此欄位必須是${r}`},file:()=>"此欄位必須是檔案",fileSize:(t,e)=>{const{size:r}=e;return{file:`此欄位必須是${n(r)} KB`,array:`此欄位中的每個項目都必須是${n(r)} KB`}},fileSizeBetween:(t,e)=>{const{min:r,max:a}=e;return{file:`此欄位必須介於${n(r)}到${n(a)} KB 之間`,array:`此欄位中的每個項目都必須介於${n(r)}到${n(a)} KB 之間`}},fileSizeGt:(t,e)=>{const{size:r}=e;return{file:`此欄位必須大於${n(r)} KB`,array:`此欄位中的每個項目都必須大於${n(r)} KB`}},fileSizeGte:(t,e)=>{const{size:r}=e;return{file:`此欄位必須大於或等於${n(r)} KB`,array:`此欄位中的每個項目都必須大於或等於${n(r)} KB`}},fileSizeLt:(t,e)=>{const{size:r}=e;return{file:`此欄位必須小於${n(r)} KB`,array:`此欄位中的每個項目都必須小於${n(r)} KB`}},fileSizeLte:(t,e)=>{const{size:r}=e;return{file:`此欄位必須小於或等於${n(r)} KB`,array:`此欄位中的每個項目都必須小於或等於${n(r)} KB`}},gt:(t,e)=>{const{value:r}=e;return{number:`此欄位必須大於${n(r)}`,array:`此欄位中的每個項目都必須大於${n(r)}`}},gte:(t,e)=>{const{value:r}=e;return{number:`此欄位必須大於或等於${n(r)}`,array:`此欄位中的每個項目都必須大於或等於${n(r)}`}},http:()=>'此欄位必須以 "http://" 協議開頭',httpOrHttps:()=>'此欄位必須以 "http://" 或 "https://" 協議開頭',https:()=>'此欄位必須以 "https://" 協議開頭',integer:()=>"此欄位必須是整數",ip:()=>"此欄位必須是有效的 IP 位址",ipv4:()=>"此欄位必須是有效的 IPv4 位址",ipv6:()=>"此欄位必須是有效的 IPv6 位址",json:()=>"此欄位必須是有效的 JSON 字串",lowercase:()=>"此欄位必須是小寫",lt:(t,e)=>{const{value:r}=e;return{number:`此欄位必須小於${n(r)}`,array:`此欄位中的每個項目都必須小於${n(r)}`}},lte:(t,e)=>{const{value:r}=e;return{number:`此欄位必須小於或等於${n(r)}`,array:`此欄位中的每個項目都必須小於或等於${n(r)}`}},notContainsAll:(t,e)=>{const{values:r}=e;return`此欄位不能同時包含以下所有值:${r.map(i).join(", ")}`},notEndsWith:(t,e)=>{const{value:r}=e;return`此欄位不能以${i(r)}結尾`},notContainsAny:(t,e)=>{const{values:r}=e;return`此欄位不能包含以下任何值:${r.map(i).join(", ")}`},notEquals:(t,e)=>{const{value:r}=e;return`此欄位不能是${r}`},notOneOf:(t,e)=>{const{values:r}=e;return`此欄位不能是以下任何值:${r.map(i).join(", ")}`},notStartsWith:(t,e)=>{const{value:r}=e;return`此欄位不能以${i(r)}開頭`},notStartsWithNumber:()=>"此欄位不能以數字開頭",notSubsetOf:(t,e)=>{const{values:r}=e;return`此欄位不能是以下項目的子集:${r.map(i).join(", ")}`},number:()=>"此欄位必須是數字",numeric:()=>"此欄位必須是數字",object:()=>"此欄位必須是物件",oneOf:(t,e)=>{const{values:r}=e;return`此欄位必須是以下其中一個值:${r.map(i).join(", ")}`},protocol:(t,e)=>{const{values:r}=e;if(r.length===1){const[a]=r;return`此欄位必須以 "${a}://" 協議開頭`}return`此欄位必須以以下其中一個協議開頭:${r.map(a=>`${a}://`).map(i).join(", ")}`},regex:()=>"此欄位必須符合所需的格式",required:()=>"此欄位為必填",same:(t,e)=>{const{field:r}=e;return`此欄位必須與${r}欄位相同`},size:(t,e)=>{const{size:r}=e;return{number:`此欄位必須是${n(r)}`,array:`此欄位中的每個項目都必須是${n(r)}`}},startsWith:(t,e)=>{const{value:r}=e;return`此欄位必須以${i(r)}開頭`},startsWithNumber:()=>"此欄位必須以數字開頭",string:()=>"此欄位必須是字串",stringContainsAll:(t,e)=>{const{values:r}=e;return`此欄位必須包含以下所有文字:${r.map(i).join(", ")}`},stringContainsAny:(t,e)=>{const{values:r}=e;return`此欄位必須包含以下其中一個文字:${r.map(i).join(", ")}`},stringLength:(t,e)=>{const{length:r}=e;return{string:`此欄位必須是${n(r)}個字元`,array:`此欄位中的每個項目都必須是${n(r)}個字元`}},stringLengthBetween:(t,e)=>{const{min:r,max:a}=e;return{string:`此欄位必須介於${n(r)}到${n(a)}個字元之間`,array:`此欄位中的每個項目都必須介於${n(r)}到${n(a)}個字元之間`}},stringLengthGt:(t,e)=>{const{length:r}=e;return{string:`此欄位必須大於${n(r)}個字元`,array:`此欄位中的每個項目都必須大於${n(r)}個字元`}},stringLengthGte:(t,e)=>{const{length:r}=e;return{string:`此欄位必須大於或等於${n(r)}個字元`,array:`此欄位中的每個項目都必須大於或等於${n(r)}個字元`}},stringLengthLt:(t,e)=>{const{length:r}=e;return{string:`此欄位必須小於${n(r)}個字元`,array:`此欄位中的每個項目都必須小於${n(r)}個字元`}},stringLengthLte:(t,e)=>{const{length:r}=e;return{string:`此欄位必須小於或等於${n(r)}個字元`,array:`此欄位中的每個項目都必須小於或等於${n(r)}個字元`}},stringNotContainsAll:(t,e)=>{const{values:r}=e;return`此欄位不能同時包含以下所有文字:${r.map(i).join(", ")}`},stringNotContainsAny:(t,e)=>{const{values:r}=e;return`此欄位不能包含以下任何文字:${r.map(i).join(", ")}`},subsetOf:(t,e)=>{const{values:r}=e;return`此欄位必須是以下項目的子集:${r.map(i).join(", ")}`},unique:()=>"此欄位已經存在",uppercase:()=>"此欄位必須是大寫",url:()=>"此欄位必須是有效的 URL"}},K=()=>t=>s(t)?!1:["y","yes","on","1","true"].includes(String(t).toLowerCase()),Z=()=>t=>s(t)?!1:/^[a-zA-Z]+$/.test(String(t)),M=()=>t=>s(t)?!1:/^[a-zA-Z0-9-_]+$/.test(String(t)),H=()=>t=>s(t)?!1:/^[a-zA-Z0-9-_.]+$/.test(String(t)),U=()=>t=>s(t)?!1:/^[a-zA-Z0-9]+$/.test(String(t)),V=()=>t=>Array.isArray(t),J=({length:t})=>e=>s(e)?!1:Array.isArray(e)?e.length===t:!1,v=({length:t})=>e=>s(e)?!1:Array.isArray(e)?e.length>=t:!1,R=({length:t})=>e=>s(e)?!1:Array.isArray(e)?e.length<=t:!1,Q=({min:t,max:e})=>r=>s(r)?!1:v({length:t})(r)&&R({length:e})(r),X=({length:t})=>e=>s(e)?!1:Array.isArray(e)?e.length>t:!1,Y=({length:t})=>e=>s(e)?!1:Array.isArray(e)?e.length<t:!1,ee=()=>t=>s(t)?!1:/^[\x20-\x7E]+$/.test(String(t)),c=({value:t})=>e=>s(e)?!1:typeof e=="number"?e>=t:Array.isArray(e)?e.every(r=>c({value:t})(r)):!1,m=({value:t})=>e=>s(e)?!1:typeof e=="number"?e<=t:Array.isArray(e)?e.every(r=>m({value:t})(r)):!1,te=({min:t,max:e})=>r=>s(r)?!1:c({value:t})(r)&&m({value:e})(r),re=()=>t=>s(t)?!1:typeof t=="boolean",ne=({values:t})=>e=>s(e)?!1:Array.isArray(e)?t.every(r=>e.includes(r)):!1,se=({values:t})=>e=>s(e)?!1:Array.isArray(e)?t.some(r=>e.includes(r)):!1,ae=()=>t=>s(t)?!1:["n","no","off","0","false"].includes(String(t).toLowerCase()),ie=({value:t})=>e=>s(e)?!1:e!==t,le=()=>t=>s(t)?!1:Array.isArray(t)?new Set(t).size===t.length:!0,oe=()=>t=>s(t)?!1:/^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(String(t)),ue=()=>t=>s(t)?!1:/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(String(t)),S=({value:t})=>e=>s(e)?!1:String(e).toLowerCase().endsWith(t.toLowerCase()),he=({value:t})=>e=>e===t,fe=()=>t=>t instanceof File,z=({size:t})=>e=>{if(s(e))return!1;if(e instanceof File){const r=t*1024,a=(t+1)*1024;return e.size>=r&&e.size<a}return Array.isArray(e)?e.every(r=>z({size:t})(r)):!1},y=({size:t})=>e=>s(e)?!1:e instanceof File?e.size>=t*1024:Array.isArray(e)?e.every(r=>y({size:t})(r)):!1,g=({size:t})=>e=>s(e)?!1:e instanceof File?e.size<=t*1024:Array.isArray(e)?e.every(r=>g({size:t})(r)):!1,ce=({min:t,max:e})=>r=>s(r)?!1:y({size:t})(r)&&g({size:e})(r),j=({size:t})=>e=>s(e)?!1:e instanceof File?e.size>t*1024:Array.isArray(e)?e.every(r=>j({size:t})(r)):!1,F=({size:t})=>e=>s(e)?!1:e instanceof File?e.size<t*1024:Array.isArray(e)?e.every(r=>F({size:t})(r)):!1,C=({value:t})=>e=>s(e)?!1:typeof e=="number"?e>t:Array.isArray(e)?e.every(r=>C({value:t})(r)):!1,$=({value:t})=>e=>s(e)?!1:String(e).toLowerCase().startsWith(t.toLowerCase()),d=({values:t})=>e=>s(e)?!1:t.map(r=>`${r}://`).some(r=>$({value:r})(e)),q=()=>t=>s(t)?!1:d({values:["http"]})(t),_=()=>t=>s(t)?!1:d({values:["https"]})(t),me=()=>t=>s(t)?!1:q()(t)||_()(t),p=()=>t=>s(t)?!1:typeof t=="number",ye=()=>t=>s(t)?!1:p()(t)&&Number.isInteger(t),b=({includeProtocol:t}={})=>e=>{if(s(e))return!1;if(t)try{const{host:r}=new URL(String(e));return b({})(r)}catch{return!1}return/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:\d+)?$/.test(String(e))},A=({includeProtocol:t}={})=>e=>{if(s(e))return!1;if(t)try{const{host:r}=new URL(String(e));return A({})(r)}catch{return!1}return/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/.test(String(e))},ge=({includeProtocol:t}={})=>e=>s(e)?!1:b({includeProtocol:t})(e)||A({includeProtocol:t})(e),$e=()=>t=>{if(s(t))return!1;try{return JSON.parse(String(t)),!0}catch{return!1}},de=()=>t=>s(t)?!1:String(t)===String(t).toLowerCase(),O=({value:t})=>e=>s(e)?!1:typeof e=="number"?e<t:Array.isArray(e)?e.every(r=>O({value:t})(r)):!1,pe=({values:t})=>e=>s(e)?!1:Array.isArray(e)?!t.every(r=>e.includes(r)):!1,be=({values:t})=>e=>s(e)?!1:Array.isArray(e)?!t.some(r=>e.includes(r)):!1,Ae=({value:t})=>e=>s(e)?!1:!S({value:t})(e),Le=({value:t})=>e=>e!==t,W=({values:t})=>e=>s(e)?!1:!t.includes(e),we=({value:t})=>e=>s(e)?!1:!$({value:t})(e),G=()=>t=>s(t)?!1:/^\d/.test(String(t)),Te=()=>t=>s(t)?!1:!G()(t),ve=({values:t})=>e=>s(e)?!1:Array.isArray(e)?e.some(r=>!t.includes(r)):W({values:t})(e),k=()=>t=>typeof t=="string",Re=()=>t=>s(t)?!1:k()(t)?/^-?\d+(\.\d+)?$/.test(String(t)):p()(t),Se=()=>t=>typeof t=="object"&&t!==null&&!Array.isArray(t),N=({values:t})=>e=>s(e)?!1:t.includes(e),ze=({expression:t})=>e=>{if(s(e))return!1;if(!(t instanceof RegExp))throw new TypeError("The expression provided is not a valid RegExp.");return t.test(String(e))},je=()=>t=>!s(t),Fe=({value:t})=>e=>s(e)?!1:Array.isArray(e)?e.every(r=>r===t):e===t,x=({size:t})=>e=>s(e)?!1:typeof e=="number"?e===t:Array.isArray(e)?e.every(r=>x({size:t})(r)):!1,Ce=({values:t})=>e=>s(e)?!1:typeof e=="string"?t.every(r=>e.includes(r)):!1,qe=({values:t})=>e=>s(e)?!1:typeof e=="string"?t.some(r=>e.includes(r)):!1,B=({length:t})=>e=>s(e)?!1:typeof e=="string"?e.length===t:Array.isArray(e)?e.every(r=>B({length:t})(r)):!1,L=({length:t})=>e=>s(e)?!1:typeof e=="string"?e.length>=t:Array.isArray(e)?e.every(r=>L({length:t})(r)):!1,w=({length:t})=>e=>s(e)?!1:typeof e=="string"?e.length<=t:Array.isArray(e)?e.every(r=>w({length:t})(r)):!1,_e=({min:t,max:e})=>r=>s(r)?!1:L({length:t})(r)&&w({length:e})(r),E=({length:t})=>e=>s(e)?!1:typeof e=="string"?e.length>t:Array.isArray(e)?e.every(r=>E({length:t})(r)):!1,D=({length:t})=>e=>s(e)?!1:typeof e=="string"?e.length<t:Array.isArray(e)?e.every(r=>D({length:t})(r)):!1,Oe={accepted:K,alpha:Z,alphaDash:M,alphaDashDot:H,alphaNum:U,array:V,arrayLength:J,arrayLengthBetween:Q,arrayLengthGt:X,arrayLengthGte:v,arrayLengthLt:Y,arrayLengthLte:R,ascii:ee,between:te,boolean:re,containsAll:ne,containsAny:se,declined:ae,different:ie,distinct:le,domain:oe,email:ue,endsWith:S,equals:he,file:fe,fileSize:z,fileSizeBetween:ce,fileSizeGt:j,fileSizeGte:y,fileSizeLt:F,fileSizeLte:g,gt:C,gte:c,http:q,httpOrHttps:me,https:_,integer:ye,ip:ge,ipv4:b,ipv6:A,json:$e,lowercase:de,lt:O,lte:m,notContainsAll:pe,notContainsAny:be,notEndsWith:Ae,notEquals:Le,notOneOf:W,notStartsWith:we,notStartsWithNumber:Te,notSubsetOf:ve,number:p,numeric:Re,object:Se,oneOf:N,protocol:d,regex:ze,required:je,same:Fe,size:x,startsWith:$,startsWithNumber:G,string:k,stringContainsAll:Ce,stringContainsAny:qe,stringLength:B,stringLengthBetween:_e,stringLengthGt:E,stringLengthGte:L,stringLengthLt:D,stringLengthLte:w,stringNotContainsAll:({values:t})=>e=>s(e)?!1:typeof e=="string"?!t.every(r=>e.includes(r)):!1,stringNotContainsAny:({values:t})=>e=>s(e)?!1:typeof e=="string"?!t.some(r=>e.includes(r)):!1,subsetOf:({values:t})=>e=>s(e)?!1:Array.isArray(e)?e.every(r=>t.includes(r)):N({values:t})(e),unique:({values:t,ignored:e=[]})=>r=>s(r)?!1:(Array.isArray(e)?e:[e]).some(a=>a===r)?!0:!t.some(a=>a===r),uppercase:()=>t=>s(t)?!1:String(t)===String(t).toUpperCase(),url:()=>t=>{if(s(t))return!1;try{return new URL(String(t)),!0}catch{return!1}}};class We{constructor({fallbackLocale:e,locale:r,plugins:a}={}){u(this,"locale","en");u(this,"fallbackLocale","en");u(this,"locales",{});u(this,"rules",{});this.registerLocales(I),this.registerRules(Oe),e&&this.setFallbackLocale(e),r&&this.setLocale(r),a&&a.forEach(l=>this.registerPlugin(l))}getLocale(){return this.locale}getFallbackLocale(){return this.fallbackLocale}setLocale(e){if(!(e in this.locales))throw new Error(`The "${e}" locale is not registered.`);return this.locale=e,this}setFallbackLocale(e){if(!(e in this.locales))throw new Error(`The "${e}" fallback locale is not registered.`);return this.fallbackLocale=e,this}defineField(e){return new T({name:e,locale:this.locale,fallbackLocale:this.fallbackLocale,locales:this.locales,rules:this.rules})}registerLocales(e){return this.locales=Object.keys(e).reduce((r,a)=>(r[a]={...this.locales[a],...e[a]},r),{...this.locales}),this}registerRules(e){return this.rules={...this.rules,...e},this}registerPlugin(e){if(!e||!e.locales||!e.rules)throw new Error('The plugin must have "locales" and "rules" properties.');return this.registerLocales(e.locales).registerRules(e.rules)}}h.FieldValidator=T,h.FormValidator=We,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(h,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(h=typeof globalThis<"u"?globalThis:h||self,o(h.Fortress={}))})(this,function(h){"use strict";var Be=Object.defineProperty;var Ee=(h,o,n)=>o in h?Be(h,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):h[o]=n;var u=(h,o,n)=>(Ee(h,typeof o!="symbol"?o+"":o,n),n);const o=t=>{const e=",、;:!?。()《》「」『』【】〔〕",r="\\x20-\\x7E",a=new RegExp(`\\s*([${e}])`,"gu"),l=new RegExp(`([${e}])\\s*([${r}])`,"gu"),f=new RegExp(`([^${r}${e}])([${r}])`,"gu"),xe=new RegExp(`([${r}])([^${r}${e}])`,"gu");return t.replace(a,"$1").replace(l,"$1$2").replace(f,"$1 $2").replace(xe,"$1 $2").replace(/ +/g," ")},n=(t,e)=>{var r;const a=e??((r=t.toString().split(".").at(1))==null?void 0:r.length)??0;return new Intl.NumberFormat(void 0,{minimumFractionDigits:a,maximumFractionDigits:a}).format(t)},I=t=>Object.prototype.toString.call(t).toLowerCase().slice(8,-1),s=t=>t==null||t===""||Array.isArray(t)&&t.length<1,i=t=>`"${t}"`;class T{constructor({name:e,locale:r,fallbackLocale:a,locales:l,rules:f}){u(this,"name");u(this,"locale");u(this,"fallbackLocale");u(this,"locales");u(this,"rules");u(this,"ruleFunctions",{});u(this,"conditions",{});u(this,"shouldSkip",!1);u(this,"appliedProtocols",{});this.name=e,this.locale=r,this.fallbackLocale=a,this.locales=l,this.rules=f}get formattedName(){return this.name.toLowerCase()}get messages(){return this.locales[this.locale]||{}}get fallbackMessages(){return this.locales[this.fallbackLocale]||{}}get mandatoryRules(){return[this.required.name,this.string.name,this.array.name,this.equals.name,this.notEquals.name]}getMessage(e){return this.messages[e]||this.fallbackMessages[e]||(r=>`The ${r} field is invalid.`)}getRule(e){if(!(e in this.rules))throw new Error(`The "${e}" rule is not registered.`);return this.rules[e]}buildRuleFunction(e,r){return a=>{if(s(a)&&!this.mandatoryRules.includes(e))return!0;const l=this.getRule(e)(r)(a);return typeof l=="string"?l:l===!0?!0:this.buildRuleFunctionMessage(e,r,a)}}buildRuleFunctionMessage(e,r,a){const l=this.getMessage(e)(this.formattedName,r);if(typeof l=="object"){const f=I(a);if(!(f in l))throw new Error(`The message for the "${e}" rule of the "${f}" type is missing.`);return o(l[f])}return o(l)}pushRuleFunction(e,r){if(e in this.conditions&&!this.conditions[e])return this;const a=this.buildRuleFunction(e,r);return this.ruleFunctions[e]=a,this}getRuleFunctions(){return Object.values(this.ruleFunctions)}collect(){return this.shouldSkip?[]:this.getRuleFunctions()}validate(e){if(this.shouldSkip)return!0;const r=this.getRuleFunctions();for(const a of r){const l=a(e);if(typeof l=="string")return l}return!0}apply(e,r={}){return this.pushRuleFunction(e,r)}accepted(){return this.apply(this.accepted.name)}after(e,r,a,l=!0){return this.apply(this.after.name,{date:e,format:r,displayFormat:a,strict:l})}alpha(){return this.apply(this.alpha.name)}alphaDash(){return this.apply(this.alphaDash.name)}alphaDashDot(){return this.apply(this.alphaDashDot.name)}alphaNum(){return this.apply(this.alphaNum.name)}array(){return this.apply(this.array.name)}arrayLength(e){return this.apply(this.arrayLength.name,{length:e})}arrayLengthBetween(e,r){return this.apply(this.arrayLengthBetween.name,{min:e,max:r})}arrayLengthGt(e){return this.apply(this.arrayLengthGt.name,{length:e})}arrayLengthGte(e){return this.apply(this.arrayLengthGte.name,{length:e})}arrayLengthLt(e){return this.apply(this.arrayLengthLt.name,{length:e})}arrayLengthLte(e){return this.apply(this.arrayLengthLte.name,{length:e})}ascii(){return this.apply(this.ascii.name)}before(e,r,a,l=!0){return this.apply(this.before.name,{date:e,format:r,displayFormat:a,strict:l})}between(e,r){return this.apply(this.between.name,{min:e,max:r})}boolean(){return this.apply(this.boolean.name)}contains(e){return this.apply(this.contains.name,{value:e})}containsAll(e){return this.apply(this.containsAll.name,{values:e})}containsAny(e){return this.apply(this.containsAny.name,{values:e})}date(e,r=!0){return this.apply(this.date.name,{format:e,strict:r})}declined(){return this.apply(this.declined.name)}different(e,r){return this.apply(this.different.name,{field:e,value:r})}distinct(){return this.apply(this.distinct.name)}domain(){return this.apply(this.domain.name)}email(){return this.apply(this.email.name)}endsWith(e){return this.apply(this.endsWith.name,{value:e})}equals(e){return this.apply(this.equals.name,{value:e})}file(){return this.apply(this.file.name)}fileSize(e){return this.apply(this.fileSize.name,{size:e})}fileSizeBetween(e,r){return this.apply(this.fileSizeBetween.name,{min:e,max:r})}fileSizeGt(e){return this.apply(this.fileSizeGt.name,{size:e})}fileSizeGte(e){return this.apply(this.fileSizeGte.name,{size:e})}fileSizeLt(e){return this.apply(this.fileSizeLt.name,{size:e})}fileSizeLte(e){return this.apply(this.fileSizeLte.name,{size:e})}gt(e){return this.apply(this.gt.name,{value:e})}gte(e){return this.apply(this.gte.name,{value:e})}http(){return this.appliedProtocols[this.http.name]=!0,this.apply(this.http.name)}httpOrHttps(){return this.appliedProtocols[this.http.name]=!0,this.appliedProtocols[this.https.name]=!0,this.apply(this.httpOrHttps.name)}https(){return this.appliedProtocols[this.https.name]=!0,this.apply(this.https.name)}integer(){return this.apply(this.integer.name)}ip(){const e=Object.keys(this.appliedProtocols).length>0;return this.apply(this.ip.name,{includeProtocol:e})}ipv4(){const e=Object.keys(this.appliedProtocols).length>0;return this.apply(this.ipv4.name,{includeProtocol:e})}ipv6(){const e=Object.keys(this.appliedProtocols).length>0;return this.apply(this.ipv6.name,{includeProtocol:e})}iso8601(){return this.apply(this.iso8601.name)}json(){return this.apply(this.json.name)}jsonSchema(e){return this.apply(this.jsonSchema.name,{schema:e,locale:this.locale,field:this.name})}lowercase(){return this.apply(this.lowercase.name)}lt(e){return this.apply(this.lt.name,{value:e})}lte(e){return this.apply(this.lte.name,{value:e})}notContains(e){return this.apply(this.notContains.name,{value:e})}notContainsAll(e){return this.apply(this.notContainsAll.name,{values:e})}notContainsAny(e){return this.apply(this.notContainsAny.name,{values:e})}notEndsWith(e){return this.apply(this.notEndsWith.name,{value:e})}notEquals(e){return this.apply(this.notEquals.name,{value:e})}notOneOf(e){return this.apply(this.notOneOf.name,{values:e})}notStartsWith(e){return this.apply(this.notStartsWith.name,{value:e})}notStartsWithNumber(){return this.apply(this.notStartsWithNumber.name)}notSubsetOf(e){return this.apply(this.notSubsetOf.name,{values:e})}number(){return this.apply(this.number.name)}numeric(){return this.apply(this.numeric.name)}object(){return this.apply(this.object.name)}oneOf(e){return this.apply(this.oneOf.name,{values:e})}protocol(e){const r=Array.isArray(e)?e:[e];return r.forEach(a=>this.appliedProtocols[a]=!0),this.apply(this.protocol.name,{values:r})}regex(e){return this.apply(this.regex.name,{expression:e})}required(){return this.apply(this.required.name)}requiredWhen(e){return this.when({required:e}).required()}same(e,r){return this.apply(this.same.name,{field:e,value:r})}size(e){return this.apply(this.size.name,{size:e})}startsWith(e){return this.apply(this.startsWith.name,{value:e})}startsWithNumber(){return this.apply(this.startsWithNumber.name)}string(){return this.apply(this.string.name)}stringContains(e){return this.apply(this.stringContains.name,{value:e})}stringContainsAll(e){return this.apply(this.stringContainsAll.name,{values:e})}stringContainsAny(e){return this.apply(this.stringContainsAny.name,{values:e})}stringLength(e){return this.apply(this.stringLength.name,{length:e})}stringLengthBetween(e,r){return this.apply(this.stringLengthBetween.name,{min:e,max:r})}stringLengthGt(e){return this.apply(this.stringLengthGt.name,{length:e})}stringLengthGte(e){return this.apply(this.stringLengthGte.name,{length:e})}stringLengthLt(e){return this.apply(this.stringLengthLt.name,{length:e})}stringLengthLte(e){return this.apply(this.stringLengthLte.name,{length:e})}stringNotContains(e){return this.apply(this.stringNotContains.name,{value:e})}stringNotContainsAll(e){return this.apply(this.stringNotContainsAll.name,{values:e})}stringNotContainsAny(e){return this.apply(this.stringNotContainsAny.name,{values:e})}subsetOf(e){return this.apply(this.subsetOf.name,{values:e})}unique(e,r=[]){return this.apply(this.unique.name,{values:e,ignored:r})}uppercase(){return this.apply(this.uppercase.name)}url(){return this.apply(this.url.name)}when(e){return typeof e=="object"?(this.conditions=e,this):(e||(this.shouldSkip=!0),this)}}const K={en:{accepted:t=>`The ${t} field must be accepted.`,alpha:t=>`The ${t} field must only contain letters.`,alphaDash:t=>`The ${t} field must only contain letters, numbers, dashes and underscores.`,alphaDashDot:t=>`The ${t} field must only contain letters, numbers, dashes, underscores and dots.`,alphaNum:t=>`The ${t} field must only contain letters and numbers.`,array:t=>`The ${t} field must be an array.`,arrayLength:(t,e)=>{const{length:r}=e;return`The ${t} field must be ${n(r)} items.`},arrayLengthBetween:(t,e)=>{const{min:r,max:a}=e;return`The ${t} field must be between ${n(r)} and ${n(a)} items.`},arrayLengthGt:(t,e)=>{const{length:r}=e;return`The ${t} field must be greater than ${n(r)} items.`},arrayLengthGte:(t,e)=>{const{length:r}=e;return`The ${t} field must be greater than or equal to ${n(r)} items.`},arrayLengthLt:(t,e)=>{const{length:r}=e;return`The ${t} field must be less than ${n(r)} items.`},arrayLengthLte:(t,e)=>{const{length:r}=e;return`The ${t} field must be less than or equal to ${n(r)} items.`},ascii:t=>`The ${t} field must only contain ASCII characters and symbols.`,between:(t,e)=>{const{min:r,max:a}=e;return{number:`The ${t} field must be between ${n(r)} and ${n(a)}.`,array:`The ${t} field must contain items where each item is between ${n(r)} and ${n(a)}.`}},boolean:t=>`The ${t} field must be a boolean value.`,contains:(t,e)=>{const{value:r}=e;return`The ${t} field must contain ${i(r)}.`},containsAll:(t,e)=>{const{values:r}=e;return`The ${t} field must contain all of the following values: ${r.map(i).join(", ")}.`},containsAny:(t,e)=>{const{values:r}=e;return`The ${t} field must contain at least one of the following values: ${r.map(i).join(", ")}.`},declined:t=>`The ${t} field must be declined.`,different:(t,e)=>{const{field:r}=e;return`The ${t} and ${r} fields must be different.`},distinct:t=>`The ${t} field must not contain duplicate values.`,domain:t=>`The ${t} field must be a valid domain.`,email:t=>`The ${t} field must be a valid email address.`,endsWith:(t,e)=>{const{value:r}=e;return`The ${t} field must end with ${i(r)}.`},equals:(t,e)=>{const{value:r}=e;return`The ${t} field must be equal to ${r}.`},file:t=>`The ${t} field must be a file.`,fileSize:(t,e)=>{const{size:r}=e;return{file:`The ${t} field must be ${n(r)} kilobytes.`,array:`The ${t} field must contain items where each item is ${n(r)} kilobytes.`}},fileSizeBetween:(t,e)=>{const{min:r,max:a}=e;return{file:`The ${t} field must be between ${n(r)} and ${n(a)} kilobytes.`,array:`The ${t} field must contain items where each item is between ${n(r)} and ${n(a)} kilobytes.`}},fileSizeGt:(t,e)=>{const{size:r}=e;return{file:`The ${t} field must be greater than ${n(r)} kilobytes.`,array:`The ${t} field must contain items where each item is greater than ${n(r)} kilobytes.`}},fileSizeGte:(t,e)=>{const{size:r}=e;return{file:`The ${t} field must be greater than or equal to ${n(r)} kilobytes.`,array:`The ${t} field must contain items where each item is greater than or equal to ${n(r)} kilobytes.`}},fileSizeLt:(t,e)=>{const{size:r}=e;return{file:`The ${t} field must be less than ${n(r)} kilobytes.`,array:`The ${t} field must contain items where each item is less than ${n(r)} kilobytes.`}},fileSizeLte:(t,e)=>{const{size:r}=e;return{file:`The ${t} field must be less than or equal to ${n(r)} kilobytes.`,array:`The ${t} field must contain items where each item is less than or equal to ${n(r)} kilobytes.`}},gt:(t,e)=>{const{value:r}=e;return{number:`The ${t} field must be greater than ${n(r)}.`,array:`The ${t} field must contain items where each item is greater than ${n(r)}.`}},gte:(t,e)=>{const{value:r}=e;return{number:`The ${t} field must be greater than or equal to ${n(r)}.`,array:`The ${t} field must contain items where each item is greater than or equal to ${n(r)}.`}},http:t=>`The ${t} field must start with the "http://" protocol.`,httpOrHttps:t=>`The ${t} field must start with the "http://" or "https://" protocols.`,https:t=>`The ${t} field must start with the "https://" protocol.`,integer:t=>`The ${t} field must be an integer.`,ip:t=>`The ${t} field must be a valid IP address.`,ipv4:t=>`The ${t} field must be a valid IPv4 address.`,ipv6:t=>`The ${t} field must be a valid IPv6 address.`,json:t=>`The ${t} field must be a valid JSON string.`,lowercase:t=>`The ${t} field must be lowercase.`,lt:(t,e)=>{const{value:r}=e;return{number:`The ${t} field must be less than ${n(r)}.`,array:`The ${t} field must contain items where each item is less than ${n(r)}.`}},lte:(t,e)=>{const{value:r}=e;return{number:`The ${t} field must be less than or equal to ${n(r)}.`,array:`The ${t} field must contain items where each item is less than or equal to ${n(r)}.`}},notContains:(t,e)=>{const{value:r}=e;return`The ${t} field must not contain ${i(r)}.`},notContainsAll:(t,e)=>{const{values:r}=e;return`The ${t} field must not contain all of the following values together: ${r.map(i).join(", ")}.`},notContainsAny:(t,e)=>{const{values:r}=e;return`The ${t} field must not contain any of the following values: ${r.map(i).join(", ")}.`},notEndsWith:(t,e)=>{const{value:r}=e;return`The ${t} field must not end with ${i(r)}.`},notEquals:(t,e)=>{const{value:r}=e;return`The ${t} field must not be equal to ${r}.`},notOneOf:(t,e)=>{const{values:r}=e;return`The ${t} field must not be one of the following values: ${r.map(i).join(", ")}.`},notStartsWith:(t,e)=>{const{value:r}=e;return`The ${t} field must not start with ${i(r)}.`},notStartsWithNumber:t=>`The ${t} field must not start with a number.`,notSubsetOf:(t,e)=>{const{values:r}=e;return`The ${t} field must not be a subset of the following values: ${r.map(i).join(", ")}.`},number:t=>`The ${t} field must be a number.`,numeric:t=>`The ${t} field must be a number.`,object:t=>`The ${t} field must be an object.`,oneOf:(t,e)=>{const{values:r}=e;return`The ${t} field must be one of the following values: ${r.map(i).join(", ")}.`},protocol:(t,e)=>{const{values:r}=e;if(r.length===1){const[a]=r;return`The ${t} field must start with the "${a}://" protocol.`}return`The ${t} field must start with one of the following protocols: ${r.map(a=>`${a}://`).map(i).join(", ")}.`},regex:t=>`The ${t} field must match the required format.`,required:t=>`The ${t} field is required.`,same:(t,e)=>{const{field:r}=e;return`The ${t} and ${r} fields must match.`},size:(t,e)=>{const{size:r}=e;return{number:`The ${t} field must be ${n(r)}.`,array:`The ${t} field must contain items where each item is ${n(r)}.`}},startsWith:(t,e)=>{const{value:r}=e;return`The ${t} field must start with ${i(r)}.`},startsWithNumber:t=>`The ${t} field must start with a number.`,string:t=>`The ${t} field must be a string.`,stringContains:(t,e)=>{const{value:r}=e;return`The ${t} field must contain ${i(r)}.`},stringContainsAll:(t,e)=>{const{values:r}=e;return`The ${t} field must contain all of the following text: ${r.map(i).join(", ")}.`},stringContainsAny:(t,e)=>{const{values:r}=e;return`The ${t} field must contain at least one of the following text: ${r.map(i).join(", ")}.`},stringLength:(t,e)=>{const{length:r}=e;return{string:`The ${t} field must be ${n(r)} characters.`,array:`The ${t} field must contain items where each item is ${n(r)} characters.`}},stringLengthBetween:(t,e)=>{const{min:r,max:a}=e;return{string:`The ${t} field must be between ${n(r)} and ${n(a)} characters.`,array:`The ${t} field must contain items where each item is between ${n(r)} and ${n(a)} characters.`}},stringLengthGt:(t,e)=>{const{length:r}=e;return{string:`The ${t} field must be greater than ${n(r)} characters.`,array:`The ${t} field must contain items where each item is greater than ${n(r)} characters.`}},stringLengthGte:(t,e)=>{const{length:r}=e;return{string:`The ${t} field must be greater than or equal to ${n(r)} characters.`,array:`The ${t} field must contain items where each item is greater than or equal to ${n(r)} characters.`}},stringLengthLt:(t,e)=>{const{length:r}=e;return{string:`The ${t} field must be less than ${n(r)} characters.`,array:`The ${t} field must contain items where each item is less than ${n(r)} characters.`}},stringLengthLte:(t,e)=>{const{length:r}=e;return{string:`The ${t} field must be less than or equal to ${n(r)} characters.`,array:`The ${t} field must contain items where each item is less than or equal to ${n(r)} characters.`}},stringNotContains:(t,e)=>{const{value:r}=e;return`The ${t} field must not contain ${i(r)}.`},stringNotContainsAll:(t,e)=>{const{values:r}=e;return`The ${t} field must not contain all of the following text together: ${r.map(i).join(", ")}.`},stringNotContainsAny:(t,e)=>{const{values:r}=e;return`The ${t} field must not contain any of the following text: ${r.map(i).join(", ")}.`},subsetOf:(t,e)=>{const{values:r}=e;return`The ${t} field must be a subset of the following values: ${r.map(i).join(", ")}.`},unique:t=>`The ${t} field has already been taken.`,uppercase:t=>`The ${t} field must be uppercase.`,url:t=>`The ${t} field must be a valid URL.`},"zh-TW":{accepted:()=>"此欄位必須被同意",alpha:()=>"此欄位只能包含字母",alphaDash:()=>"此欄位只能包含字母、數字、連接號和底線",alphaDashDot:()=>"此欄位只能包含字母、數字、連接號、底線和點",alphaNum:()=>"此欄位只能包含字母和數字",array:()=>"此欄位必須是一個陣列",arrayLength:(t,e)=>{const{length:r}=e;return`此欄位必須是${n(r)}個項目`},arrayLengthBetween:(t,e)=>{const{min:r,max:a}=e;return`此欄位必須介於${n(r)}到${n(a)}個項目之間`},arrayLengthGt:(t,e)=>{const{length:r}=e;return`此欄位必須大於${n(r)}個項目`},arrayLengthGte:(t,e)=>{const{length:r}=e;return`此欄位必須大於或等於${n(r)}個項目`},arrayLengthLt:(t,e)=>{const{length:r}=e;return`此欄位必須小於${n(r)}個項目`},arrayLengthLte:(t,e)=>{const{length:r}=e;return`此欄位必須小於或等於${n(r)}個項目`},ascii:()=>"此欄位只能包含 ASCII 字元和符號",between:(t,e)=>{const{min:r,max:a}=e;return{number:`此欄位必須介於${n(r)}到${n(a)}`,array:`此欄位中的每個項目都必須介於${n(r)}到${n(a)}`}},boolean:()=>"此欄位必須是一個布林值",contains:(t,e)=>{const{value:r}=e;return`此欄位必須包含${i(r)}`},containsAll:(t,e)=>{const{values:r}=e;return`此欄位必須包含以下所有項目:${r.map(i).join(", ")}`},containsAny:(t,e)=>{const{values:r}=e;return`此欄位必須包含以下其中一個項目:${r.map(i).join(", ")}`},declined:()=>"此欄位必須被拒絕",different:(t,e)=>{const{field:r}=e;return`此欄位必須和${r}欄位不同`},distinct:()=>"此欄位不能包含重複的值",domain:()=>"此欄位必須是有效的網域",email:()=>"此欄位必須是有效的電子郵件地址",endsWith:(t,e)=>{const{value:r}=e;return`此欄位必須以${i(r)}結尾`},equals:(t,e)=>{const{value:r}=e;return`此欄位必須是${r}`},file:()=>"此欄位必須是檔案",fileSize:(t,e)=>{const{size:r}=e;return{file:`此欄位必須是${n(r)} KB`,array:`此欄位中的每個項目都必須是${n(r)} KB`}},fileSizeBetween:(t,e)=>{const{min:r,max:a}=e;return{file:`此欄位必須介於${n(r)}到${n(a)} KB 之間`,array:`此欄位中的每個項目都必須介於${n(r)}到${n(a)} KB 之間`}},fileSizeGt:(t,e)=>{const{size:r}=e;return{file:`此欄位必須大於${n(r)} KB`,array:`此欄位中的每個項目都必須大於${n(r)} KB`}},fileSizeGte:(t,e)=>{const{size:r}=e;return{file:`此欄位必須大於或等於${n(r)} KB`,array:`此欄位中的每個項目都必須大於或等於${n(r)} KB`}},fileSizeLt:(t,e)=>{const{size:r}=e;return{file:`此欄位必須小於${n(r)} KB`,array:`此欄位中的每個項目都必須小於${n(r)} KB`}},fileSizeLte:(t,e)=>{const{size:r}=e;return{file:`此欄位必須小於或等於${n(r)} KB`,array:`此欄位中的每個項目都必須小於或等於${n(r)} KB`}},gt:(t,e)=>{const{value:r}=e;return{number:`此欄位必須大於${n(r)}`,array:`此欄位中的每個項目都必須大於${n(r)}`}},gte:(t,e)=>{const{value:r}=e;return{number:`此欄位必須大於或等於${n(r)}`,array:`此欄位中的每個項目都必須大於或等於${n(r)}`}},http:()=>'此欄位必須以 "http://" 協議開頭',httpOrHttps:()=>'此欄位必須以 "http://" 或 "https://" 協議開頭',https:()=>'此欄位必須以 "https://" 協議開頭',integer:()=>"此欄位必須是整數",ip:()=>"此欄位必須是有效的 IP 位址",ipv4:()=>"此欄位必須是有效的 IPv4 位址",ipv6:()=>"此欄位必須是有效的 IPv6 位址",json:()=>"此欄位必須是有效的 JSON 字串",lowercase:()=>"此欄位必須是小寫",lt:(t,e)=>{const{value:r}=e;return{number:`此欄位必須小於${n(r)}`,array:`此欄位中的每個項目都必須小於${n(r)}`}},lte:(t,e)=>{const{value:r}=e;return{number:`此欄位必須小於或等於${n(r)}`,array:`此欄位中的每個項目都必須小於或等於${n(r)}`}},notContains:(t,e)=>{const{values:r}=e;return`此欄位不能包含${i(r)}`},notContainsAll:(t,e)=>{const{values:r}=e;return`此欄位不能同時包含以下所有值:${r.map(i).join(", ")}`},notContainsAny:(t,e)=>{const{values:r}=e;return`此欄位不能包含以下任何值:${r.map(i).join(", ")}`},notEndsWith:(t,e)=>{const{value:r}=e;return`此欄位不能以${i(r)}結尾`},notEquals:(t,e)=>{const{value:r}=e;return`此欄位不能是${r}`},notOneOf:(t,e)=>{const{values:r}=e;return`此欄位不能是以下任何值:${r.map(i).join(", ")}`},notStartsWith:(t,e)=>{const{value:r}=e;return`此欄位不能以${i(r)}開頭`},notStartsWithNumber:()=>"此欄位不能以數字開頭",notSubsetOf:(t,e)=>{const{values:r}=e;return`此欄位不能是以下項目的子集:${r.map(i).join(", ")}`},number:()=>"此欄位必須是數字",numeric:()=>"此欄位必須是數字",object:()=>"此欄位必須是物件",oneOf:(t,e)=>{const{values:r}=e;return`此欄位必須是以下其中一個值:${r.map(i).join(", ")}`},protocol:(t,e)=>{const{values:r}=e;if(r.length===1){const[a]=r;return`此欄位必須以 "${a}://" 協議開頭`}return`此欄位必須以以下其中一個協議開頭:${r.map(a=>`${a}://`).map(i).join(", ")}`},regex:()=>"此欄位必須符合所需的格式",required:()=>"此欄位為必填",same:(t,e)=>{const{field:r}=e;return`此欄位必須與${r}欄位相同`},size:(t,e)=>{const{size:r}=e;return{number:`此欄位必須是${n(r)}`,array:`此欄位中的每個項目都必須是${n(r)}`}},startsWith:(t,e)=>{const{value:r}=e;return`此欄位必須以${i(r)}開頭`},startsWithNumber:()=>"此欄位必須以數字開頭",string:()=>"此欄位必須是字串",stringContains:(t,e)=>{const{value:r}=e;return`此欄位必須包含${i(r)}`},stringContainsAll:(t,e)=>{const{values:r}=e;return`此欄位必須包含以下所有文字:${r.map(i).join(", ")}`},stringContainsAny:(t,e)=>{const{values:r}=e;return`此欄位必須包含以下其中一個文字:${r.map(i).join(", ")}`},stringLength:(t,e)=>{const{length:r}=e;return{string:`此欄位必須是${n(r)}個字元`,array:`此欄位中的每個項目都必須是${n(r)}個字元`}},stringLengthBetween:(t,e)=>{const{min:r,max:a}=e;return{string:`此欄位必須介於${n(r)}到${n(a)}個字元之間`,array:`此欄位中的每個項目都必須介於${n(r)}到${n(a)}個字元之間`}},stringLengthGt:(t,e)=>{const{length:r}=e;return{string:`此欄位必須大於${n(r)}個字元`,array:`此欄位中的每個項目都必須大於${n(r)}個字元`}},stringLengthGte:(t,e)=>{const{length:r}=e;return{string:`此欄位必須大於或等於${n(r)}個字元`,array:`此欄位中的每個項目都必須大於或等於${n(r)}個字元`}},stringLengthLt:(t,e)=>{const{length:r}=e;return{string:`此欄位必須小於${n(r)}個字元`,array:`此欄位中的每個項目都必須小於${n(r)}個字元`}},stringLengthLte:(t,e)=>{const{length:r}=e;return{string:`此欄位必須小於或等於${n(r)}個字元`,array:`此欄位中的每個項目都必須小於或等於${n(r)}個字元`}},stringNotContains:(t,e)=>{const{value:r}=e;return`此欄位不能包含${i(r)}`},stringNotContainsAll:(t,e)=>{const{values:r}=e;return`此欄位不能同時包含以下所有文字:${r.map(i).join(", ")}`},stringNotContainsAny:(t,e)=>{const{values:r}=e;return`此欄位不能包含以下任何文字:${r.map(i).join(", ")}`},subsetOf:(t,e)=>{const{values:r}=e;return`此欄位必須是以下項目的子集:${r.map(i).join(", ")}`},unique:()=>"此欄位已經存在",uppercase:()=>"此欄位必須是大寫",url:()=>"此欄位必須是有效的 URL"}},Z=()=>t=>s(t)?!1:["y","yes","on","1","true"].includes(String(t).toLowerCase()),M=()=>t=>s(t)?!1:/^[a-zA-Z]+$/.test(String(t)),H=()=>t=>s(t)?!1:/^[a-zA-Z0-9-_]+$/.test(String(t)),U=()=>t=>s(t)?!1:/^[a-zA-Z0-9-_.]+$/.test(String(t)),V=()=>t=>s(t)?!1:/^[a-zA-Z0-9]+$/.test(String(t)),J=()=>t=>Array.isArray(t),Q=({length:t})=>e=>s(e)?!1:Array.isArray(e)?e.length===t:!1,w=({length:t})=>e=>s(e)?!1:Array.isArray(e)?e.length>=t:!1,R=({length:t})=>e=>s(e)?!1:Array.isArray(e)?e.length<=t:!1,X=({min:t,max:e})=>r=>s(r)?!1:w({length:t})(r)&&R({length:e})(r),Y=({length:t})=>e=>s(e)?!1:Array.isArray(e)?e.length>t:!1,ee=({length:t})=>e=>s(e)?!1:Array.isArray(e)?e.length<t:!1,te=()=>t=>s(t)?!1:/^[\x20-\x7E]+$/.test(String(t)),c=({value:t})=>e=>s(e)?!1:typeof e=="number"?e>=t:Array.isArray(e)?e.every(r=>c({value:t})(r)):!1,m=({value:t})=>e=>s(e)?!1:typeof e=="number"?e<=t:Array.isArray(e)?e.every(r=>m({value:t})(r)):!1,re=({min:t,max:e})=>r=>s(r)?!1:c({value:t})(r)&&m({value:e})(r),ne=()=>t=>s(t)?!1:typeof t=="boolean",se=({value:t})=>e=>s(e)?!1:Array.isArray(e)?e.includes(t):!1,ae=({values:t})=>e=>s(e)?!1:Array.isArray(e)?t.every(r=>e.includes(r)):!1,ie=({values:t})=>e=>s(e)?!1:Array.isArray(e)?t.some(r=>e.includes(r)):!1,le=()=>t=>s(t)?!1:["n","no","off","0","false"].includes(String(t).toLowerCase()),oe=({value:t})=>e=>s(e)?!1:e!==t,ue=()=>t=>s(t)?!1:Array.isArray(t)?new Set(t).size===t.length:!0,he=()=>t=>s(t)?!1:/^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(String(t)),fe=()=>t=>s(t)?!1:/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(String(t)),S=({value:t})=>e=>s(e)?!1:String(e).toLowerCase().endsWith(t.toLowerCase()),ce=({value:t})=>e=>e===t,me=()=>t=>t instanceof File,z=({size:t})=>e=>{if(s(e))return!1;if(e instanceof File){const r=t*1024,a=(t+1)*1024;return e.size>=r&&e.size<a}return Array.isArray(e)?e.every(r=>z({size:t})(r)):!1},y=({size:t})=>e=>s(e)?!1:e instanceof File?e.size>=t*1024:Array.isArray(e)?e.every(r=>y({size:t})(r)):!1,g=({size:t})=>e=>s(e)?!1:e instanceof File?e.size<=t*1024:Array.isArray(e)?e.every(r=>g({size:t})(r)):!1,ye=({min:t,max:e})=>r=>s(r)?!1:y({size:t})(r)&&g({size:e})(r),C=({size:t})=>e=>s(e)?!1:e instanceof File?e.size>t*1024:Array.isArray(e)?e.every(r=>C({size:t})(r)):!1,_=({size:t})=>e=>s(e)?!1:e instanceof File?e.size<t*1024:Array.isArray(e)?e.every(r=>_({size:t})(r)):!1,j=({value:t})=>e=>s(e)?!1:typeof e=="number"?e>t:Array.isArray(e)?e.every(r=>j({value:t})(r)):!1,$=({value:t})=>e=>s(e)?!1:String(e).toLowerCase().startsWith(t.toLowerCase()),d=({values:t})=>e=>s(e)?!1:t.map(r=>`${r}://`).some(r=>$({value:r})(e)),F=()=>t=>s(t)?!1:d({values:["http"]})(t),q=()=>t=>s(t)?!1:d({values:["https"]})(t),ge=()=>t=>s(t)?!1:F()(t)||q()(t),p=()=>t=>s(t)?!1:typeof t=="number",$e=()=>t=>s(t)?!1:p()(t)&&Number.isInteger(t),b=({includeProtocol:t}={})=>e=>{if(s(e))return!1;if(t)try{const{host:r}=new URL(String(e));return b({})(r)}catch{return!1}return/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:\d+)?$/.test(String(e))},A=({includeProtocol:t}={})=>e=>{if(s(e))return!1;if(t)try{const{host:r}=new URL(String(e));return A({})(r)}catch{return!1}return/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/.test(String(e))},de=({includeProtocol:t}={})=>e=>s(e)?!1:b({includeProtocol:t})(e)||A({includeProtocol:t})(e),pe=()=>t=>{if(s(t))return!1;try{return JSON.parse(String(t)),!0}catch{return!1}},be=()=>t=>s(t)?!1:String(t)===String(t).toLowerCase(),O=({value:t})=>e=>s(e)?!1:typeof e=="number"?e<t:Array.isArray(e)?e.every(r=>O({value:t})(r)):!1,Ae=({value:t})=>e=>s(e)?!1:Array.isArray(e)?!e.includes(t):!1,Le=({values:t})=>e=>s(e)?!1:Array.isArray(e)?!t.every(r=>e.includes(r)):!1,ve=({values:t})=>e=>s(e)?!1:Array.isArray(e)?!t.some(r=>e.includes(r)):!1,Te=({value:t})=>e=>s(e)?!1:!S({value:t})(e),we=({value:t})=>e=>e!==t,W=({values:t})=>e=>s(e)?!1:!t.includes(e),Re=({value:t})=>e=>s(e)?!1:!$({value:t})(e),N=()=>t=>s(t)?!1:/^\d/.test(String(t)),Se=()=>t=>s(t)?!1:!N()(t),ze=({values:t})=>e=>s(e)?!1:Array.isArray(e)?e.some(r=>!t.includes(r)):W({values:t})(e),G=()=>t=>typeof t=="string",Ce=()=>t=>s(t)?!1:G()(t)?/^-?\d+(\.\d+)?$/.test(String(t)):p()(t),_e=()=>t=>typeof t=="object"&&t!==null&&!Array.isArray(t),k=({values:t})=>e=>s(e)?!1:t.includes(e),je=({expression:t})=>e=>{if(s(e))return!1;if(!(t instanceof RegExp))throw new TypeError("The expression provided is not a valid RegExp.");return t.test(String(e))},Fe=()=>t=>!s(t),qe=({value:t})=>e=>s(e)?!1:Array.isArray(e)?e.every(r=>r===t):e===t,x=({size:t})=>e=>s(e)?!1:typeof e=="number"?e===t:Array.isArray(e)?e.every(r=>x({size:t})(r)):!1,B=({value:t})=>e=>s(e)?!1:typeof e=="string"?e.includes(t):!1,Oe=({values:t})=>e=>s(e)?!1:typeof e=="string"?t.every(r=>B({value:r})(e)):!1,We=({values:t})=>e=>s(e)?!1:typeof e=="string"?t.some(r=>e.includes(r)):!1,E=({length:t})=>e=>s(e)?!1:typeof e=="string"?e.length===t:Array.isArray(e)?e.every(r=>E({length:t})(r)):!1,L=({length:t})=>e=>s(e)?!1:typeof e=="string"?e.length>=t:Array.isArray(e)?e.every(r=>L({length:t})(r)):!1,v=({length:t})=>e=>s(e)?!1:typeof e=="string"?e.length<=t:Array.isArray(e)?e.every(r=>v({length:t})(r)):!1,Ne=({min:t,max:e})=>r=>s(r)?!1:L({length:t})(r)&&v({length:e})(r),D=({length:t})=>e=>s(e)?!1:typeof e=="string"?e.length>t:Array.isArray(e)?e.every(r=>D({length:t})(r)):!1,P=({length:t})=>e=>s(e)?!1:typeof e=="string"?e.length<t:Array.isArray(e)?e.every(r=>P({length:t})(r)):!1,Ge={accepted:Z,alpha:M,alphaDash:H,alphaDashDot:U,alphaNum:V,array:J,arrayLength:Q,arrayLengthBetween:X,arrayLengthGt:Y,arrayLengthGte:w,arrayLengthLt:ee,arrayLengthLte:R,ascii:te,between:re,boolean:ne,contains:se,containsAll:ae,containsAny:ie,declined:le,different:oe,distinct:ue,domain:he,email:fe,endsWith:S,equals:ce,file:me,fileSize:z,fileSizeBetween:ye,fileSizeGt:C,fileSizeGte:y,fileSizeLt:_,fileSizeLte:g,gt:j,gte:c,http:F,httpOrHttps:ge,https:q,integer:$e,ip:de,ipv4:b,ipv6:A,json:pe,lowercase:be,lt:O,lte:m,notContains:Ae,notContainsAll:Le,notContainsAny:ve,notEndsWith:Te,notEquals:we,notOneOf:W,notStartsWith:Re,notStartsWithNumber:Se,notSubsetOf:ze,number:p,numeric:Ce,object:_e,oneOf:k,protocol:d,regex:je,required:Fe,same:qe,size:x,startsWith:$,startsWithNumber:N,string:G,stringContains:B,stringContainsAll:Oe,stringContainsAny:We,stringLength:E,stringLengthBetween:Ne,stringLengthGt:D,stringLengthGte:L,stringLengthLt:P,stringLengthLte:v,stringNotContains:({value:t})=>e=>s(e)?!1:typeof e=="string"?!e.includes(t):!1,stringNotContainsAll:({values:t})=>e=>s(e)?!1:typeof e=="string"?!t.every(r=>e.includes(r)):!1,stringNotContainsAny:({values:t})=>e=>s(e)?!1:typeof e=="string"?!t.some(r=>e.includes(r)):!1,subsetOf:({values:t})=>e=>s(e)?!1:Array.isArray(e)?e.every(r=>t.includes(r)):k({values:t})(e),unique:({values:t,ignored:e=[]})=>r=>s(r)?!1:(Array.isArray(e)?e:[e]).some(a=>a===r)?!0:!t.some(a=>a===r),uppercase:()=>t=>s(t)?!1:String(t)===String(t).toUpperCase(),url:()=>t=>{if(s(t))return!1;try{return new URL(String(t)),!0}catch{return!1}}};class ke{constructor({fallbackLocale:e,locale:r,plugins:a}={}){u(this,"locale","en");u(this,"fallbackLocale","en");u(this,"locales",{});u(this,"rules",{});this.registerLocales(K),this.registerRules(Ge),e&&this.setFallbackLocale(e),r&&this.setLocale(r),a&&a.forEach(l=>this.registerPlugin(l))}getLocale(){return this.locale}getFallbackLocale(){return this.fallbackLocale}setLocale(e){if(!(e in this.locales))throw new Error(`The "${e}" locale is not registered.`);return this.locale=e,this}setFallbackLocale(e){if(!(e in this.locales))throw new Error(`The "${e}" fallback locale is not registered.`);return this.fallbackLocale=e,this}defineField(e){return new T({name:e,locale:this.locale,fallbackLocale:this.fallbackLocale,locales:this.locales,rules:this.rules})}registerLocales(e){return this.locales=Object.keys(e).reduce((r,a)=>(r[a]={...this.locales[a],...e[a]},r),{...this.locales}),this}registerRules(e){return this.rules={...this.rules,...e},this}registerPlugin(e){if(!e||!e.locales||!e.rules)throw new Error('The plugin must have "locales" and "rules" properties.');return this.registerLocales(e.locales).registerRules(e.rules)}}h.FieldValidator=T,h.FormValidator=ke,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Rule, RuleArguments } from '@kklab/fortress-validator-types';
|
|
2
|
+
export interface StringContainsRuleArguments extends RuleArguments {
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
declare const stringContainsRule: Rule<StringContainsRuleArguments>;
|
|
6
|
+
export default stringContainsRule;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Rule, RuleArguments } from '@kklab/fortress-validator-types';
|
|
2
|
+
export interface StringNotContainsRuleArguments extends RuleArguments {
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
declare const stringNotContainsRule: Rule<StringNotContainsRuleArguments>;
|
|
6
|
+
export default stringNotContainsRule;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kklab/fortress-validator",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.19",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"release": "npm run test && npm run build && npm publish --access public"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@kklab/fortress-validator-utils": "^1.0.
|
|
17
|
+
"@kklab/fortress-validator-utils": "^1.0.4"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@kklab/fortress-validator-plugin-date": "^1.0.4",
|