@kklab/fortress-validator 1.0.10 → 1.0.11
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/dist/index.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
var x = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var l = (t, e, r) => (
|
|
4
|
-
const
|
|
2
|
+
var z = (t, e, r) => e in t ? x(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var l = (t, e, r) => (z(t, typeof e != "symbol" ? e + "" : e, r), r);
|
|
4
|
+
const d = (t) => {
|
|
5
|
+
const e = ",、;:!?。()《》「」『』【】〔〕", r = "\\x20-\\x7E", n = new RegExp(`\\s*([${e}])`, "gu"), i = new RegExp(`([${e}])\\s*([${r}])`, "gu"), u = new RegExp(`([^${r}${e}])([${r}])`, "gu"), S = new RegExp(`([${r}])([^${r}${e}])`, "gu");
|
|
6
|
+
return t.replace(n, "$1").replace(i, "$1$2").replace(u, "$1 $2").replace(S, "$1 $2").replace(/ +/g, " ");
|
|
7
|
+
}, s = (t, e = 0) => new Intl.NumberFormat(void 0, {
|
|
5
8
|
minimumFractionDigits: e,
|
|
6
9
|
maximumFractionDigits: e
|
|
7
|
-
}).format(t),
|
|
8
|
-
class
|
|
10
|
+
}).format(t), C = (t) => Object.prototype.toString.call(t).toLowerCase().slice(8, -1), a = (t) => t == null || t === "" || Array.isArray(t) && t.length < 1;
|
|
11
|
+
class _ {
|
|
9
12
|
constructor({
|
|
10
13
|
name: e,
|
|
11
14
|
locale: r,
|
|
12
|
-
fallbackLocale:
|
|
13
|
-
locales:
|
|
15
|
+
fallbackLocale: n,
|
|
16
|
+
locales: i,
|
|
14
17
|
rules: u
|
|
15
18
|
}) {
|
|
16
19
|
l(this, "name");
|
|
@@ -21,7 +24,7 @@ class C {
|
|
|
21
24
|
l(this, "ruleFunctions", []);
|
|
22
25
|
l(this, "conditions", {});
|
|
23
26
|
l(this, "shouldSkip", !1);
|
|
24
|
-
this.name = e, this.locale = r, this.fallbackLocale =
|
|
27
|
+
this.name = e, this.locale = r, this.fallbackLocale = n, this.locales = i, this.rules = u;
|
|
25
28
|
}
|
|
26
29
|
get formattedName() {
|
|
27
30
|
return this.name.toLowerCase();
|
|
@@ -50,28 +53,28 @@ class C {
|
|
|
50
53
|
return this.rules[e];
|
|
51
54
|
}
|
|
52
55
|
buildRuleFunction(e, r) {
|
|
53
|
-
return (
|
|
54
|
-
if (
|
|
56
|
+
return (n) => {
|
|
57
|
+
if (a(n) && !this.mandatoryRules.includes(e))
|
|
55
58
|
return !0;
|
|
56
|
-
const
|
|
57
|
-
return typeof
|
|
59
|
+
const i = this.getRule(e)(r)(n);
|
|
60
|
+
return typeof i == "string" ? i : i === !0 ? !0 : this.buildRuleFunctionMessage(e, r, n);
|
|
58
61
|
};
|
|
59
62
|
}
|
|
60
|
-
buildRuleFunctionMessage(e, r,
|
|
61
|
-
const
|
|
62
|
-
if (typeof
|
|
63
|
-
const u =
|
|
64
|
-
if (!(u in
|
|
63
|
+
buildRuleFunctionMessage(e, r, n) {
|
|
64
|
+
const i = this.getMessage(e)(this.formattedName, r);
|
|
65
|
+
if (typeof i == "object") {
|
|
66
|
+
const u = C(n);
|
|
67
|
+
if (!(u in i))
|
|
65
68
|
throw new Error(`The message for the "${e}" rule of the "${u}" type is missing.`);
|
|
66
|
-
return
|
|
69
|
+
return d(i[u]);
|
|
67
70
|
}
|
|
68
|
-
return
|
|
71
|
+
return d(i);
|
|
69
72
|
}
|
|
70
73
|
pushRuleFunction(e, r) {
|
|
71
74
|
if (e in this.conditions && !this.conditions[e])
|
|
72
75
|
return this;
|
|
73
|
-
const
|
|
74
|
-
return this.ruleFunctions.push(
|
|
76
|
+
const n = this.buildRuleFunction(e, r);
|
|
77
|
+
return this.ruleFunctions.push(n), this;
|
|
75
78
|
}
|
|
76
79
|
getRuleFunctions() {
|
|
77
80
|
return this.ruleFunctions;
|
|
@@ -89,9 +92,9 @@ class C {
|
|
|
89
92
|
if (this.shouldSkip)
|
|
90
93
|
return !0;
|
|
91
94
|
for (const r of this.ruleFunctions) {
|
|
92
|
-
const
|
|
93
|
-
if (typeof
|
|
94
|
-
return
|
|
95
|
+
const n = r(e);
|
|
96
|
+
if (typeof n == "string")
|
|
97
|
+
return n;
|
|
95
98
|
}
|
|
96
99
|
return !0;
|
|
97
100
|
}
|
|
@@ -110,8 +113,8 @@ class C {
|
|
|
110
113
|
/**
|
|
111
114
|
* Passes if the field's value is a date that occurs after the specified date.
|
|
112
115
|
*/
|
|
113
|
-
after(e, r,
|
|
114
|
-
return this.apply(this.after.name, { date: e, format: r, displayFormat:
|
|
116
|
+
after(e, r, n, i = !0) {
|
|
117
|
+
return this.apply(this.after.name, { date: e, format: r, displayFormat: n, strict: i });
|
|
115
118
|
}
|
|
116
119
|
/**
|
|
117
120
|
* Passes if the field's value contains only letters.
|
|
@@ -152,8 +155,8 @@ class C {
|
|
|
152
155
|
/**
|
|
153
156
|
* Passes if the field's value is a date that occurs before the specified date.
|
|
154
157
|
*/
|
|
155
|
-
before(e, r,
|
|
156
|
-
return this.apply(this.before.name, { date: e, format: r, displayFormat:
|
|
158
|
+
before(e, r, n, i = !0) {
|
|
159
|
+
return this.apply(this.before.name, { date: e, format: r, displayFormat: n, strict: i });
|
|
157
160
|
}
|
|
158
161
|
/**
|
|
159
162
|
* Passes if the field's value is between the specified minimum and maximum values.
|
|
@@ -492,7 +495,7 @@ class C {
|
|
|
492
495
|
return typeof e == "object" ? (this.conditions = e, this) : (e || (this.shouldSkip = !0), this);
|
|
493
496
|
}
|
|
494
497
|
}
|
|
495
|
-
const
|
|
498
|
+
const q = {
|
|
496
499
|
accepted: (t) => `The ${t} field must be accepted.`,
|
|
497
500
|
alpha: (t) => `The ${t} field must only contain letters.`,
|
|
498
501
|
alphaDash: (t) => `The ${t} field must only contain letters, numbers, dashes and underscores.`,
|
|
@@ -501,24 +504,24 @@ const _ = {
|
|
|
501
504
|
array: (t) => `The ${t} field must be an array.`,
|
|
502
505
|
ascii: (t) => `The ${t} field must only contain ASCII characters and symbols.`,
|
|
503
506
|
between: (t, e) => {
|
|
504
|
-
const { min: r, max:
|
|
507
|
+
const { min: r, max: n } = e;
|
|
505
508
|
return {
|
|
506
|
-
number: `The ${t} field must be between ${
|
|
507
|
-
array: `The ${t} field must contain items where each item is between ${
|
|
509
|
+
number: `The ${t} field must be between ${s(r)} and ${s(n)}.`,
|
|
510
|
+
array: `The ${t} field must contain items where each item is between ${s(r)} and ${s(n)}.`
|
|
508
511
|
};
|
|
509
512
|
},
|
|
510
513
|
betweenLength: (t, e) => {
|
|
511
|
-
const { min: r, max:
|
|
512
|
-
return `The ${t} field must be between ${
|
|
514
|
+
const { min: r, max: n } = e;
|
|
515
|
+
return `The ${t} field must be between ${s(r)} and ${s(n)} items.`;
|
|
513
516
|
},
|
|
514
517
|
boolean: (t) => `The ${t} field must be a boolean value.`,
|
|
515
518
|
containsAll: (t, e) => {
|
|
516
519
|
const { values: r } = e;
|
|
517
|
-
return `The ${t} field must contain all of the following values: ${r.join(", ")}.`;
|
|
520
|
+
return `The ${t} field must contain all of the following values: ${r.map((n) => `"${n}"`).join(", ")}.`;
|
|
518
521
|
},
|
|
519
522
|
containsAny: (t, e) => {
|
|
520
523
|
const { values: r } = e;
|
|
521
|
-
return `The ${t} field must contain at least one of the following values: ${r.join(", ")}.`;
|
|
524
|
+
return `The ${t} field must contain at least one of the following values: ${r.map((n) => `"${n}"`).join(", ")}.`;
|
|
522
525
|
},
|
|
523
526
|
declined: (t) => `The ${t} field must be declined.`,
|
|
524
527
|
different: (t, e) => {
|
|
@@ -538,31 +541,31 @@ const _ = {
|
|
|
538
541
|
},
|
|
539
542
|
file: (t) => `The ${t} field must be a file.`,
|
|
540
543
|
fileBetweenSize: (t, e) => {
|
|
541
|
-
const { min: r, max:
|
|
544
|
+
const { min: r, max: n } = e;
|
|
542
545
|
return {
|
|
543
|
-
file: `The ${t} field must be between ${
|
|
544
|
-
array: `The ${t} field must contain items where each item is between ${
|
|
546
|
+
file: `The ${t} field must be between ${s(r)} and ${s(n)} kilobytes.`,
|
|
547
|
+
array: `The ${t} field must contain items where each item is between ${s(r)} and ${s(n)} kilobytes.`
|
|
545
548
|
};
|
|
546
549
|
},
|
|
547
550
|
fileMaxSize: (t, e) => {
|
|
548
551
|
const { size: r } = e;
|
|
549
552
|
return {
|
|
550
|
-
file: `The ${t} field must not be greater than ${
|
|
551
|
-
array: `The ${t} field must contain items where each item is not greater than ${
|
|
553
|
+
file: `The ${t} field must not be greater than ${s(r)} kilobytes.`,
|
|
554
|
+
array: `The ${t} field must contain items where each item is not greater than ${s(r)} kilobytes.`
|
|
552
555
|
};
|
|
553
556
|
},
|
|
554
557
|
fileMinSize: (t, e) => {
|
|
555
558
|
const { size: r } = e;
|
|
556
559
|
return {
|
|
557
|
-
file: `The ${t} field must be at least ${
|
|
558
|
-
array: `The ${t} field must contain items where each item is at least ${
|
|
560
|
+
file: `The ${t} field must be at least ${s(r)} kilobytes.`,
|
|
561
|
+
array: `The ${t} field must contain items where each item is at least ${s(r)} kilobytes.`
|
|
559
562
|
};
|
|
560
563
|
},
|
|
561
564
|
fileSize: (t, e) => {
|
|
562
565
|
const { size: r } = e;
|
|
563
566
|
return {
|
|
564
|
-
file: `The ${t} field must be ${
|
|
565
|
-
array: `The ${t} field must contain items where each item is ${
|
|
567
|
+
file: `The ${t} field must be ${s(r)} kilobytes.`,
|
|
568
|
+
array: `The ${t} field must contain items where each item is ${s(r)} kilobytes.`
|
|
566
569
|
};
|
|
567
570
|
},
|
|
568
571
|
http: (t) => `The ${t} field must start with either "http://" or "https://".`,
|
|
@@ -571,38 +574,38 @@ const _ = {
|
|
|
571
574
|
json: (t) => `The ${t} field must be a valid JSON string.`,
|
|
572
575
|
length: (t, e) => {
|
|
573
576
|
const { length: r } = e;
|
|
574
|
-
return `The ${t} field must be ${
|
|
577
|
+
return `The ${t} field must be ${s(r)} items.`;
|
|
575
578
|
},
|
|
576
579
|
lowercase: (t) => `The ${t} field must be lowercase.`,
|
|
577
580
|
max: (t, e) => {
|
|
578
581
|
const { max: r } = e;
|
|
579
582
|
return {
|
|
580
|
-
number: `The ${t} field must not be greater than ${
|
|
581
|
-
array: `The ${t} field must contain items where each item is not greater than ${
|
|
583
|
+
number: `The ${t} field must not be greater than ${s(r)}.`,
|
|
584
|
+
array: `The ${t} field must contain items where each item is not greater than ${s(r)}.`
|
|
582
585
|
};
|
|
583
586
|
},
|
|
584
587
|
maxLength: (t, e) => {
|
|
585
588
|
const { length: r } = e;
|
|
586
|
-
return `The ${t} field must not be greater than ${
|
|
589
|
+
return `The ${t} field must not be greater than ${s(r)} items.`;
|
|
587
590
|
},
|
|
588
591
|
min: (t, e) => {
|
|
589
592
|
const { min: r } = e;
|
|
590
593
|
return {
|
|
591
|
-
number: `The ${t} field must be at least ${
|
|
592
|
-
array: `The ${t} field must contain items where each item is at least ${
|
|
594
|
+
number: `The ${t} field must be at least ${s(r)}.`,
|
|
595
|
+
array: `The ${t} field must contain items where each item is at least ${s(r)}.`
|
|
593
596
|
};
|
|
594
597
|
},
|
|
595
598
|
minLength: (t, e) => {
|
|
596
599
|
const { length: r } = e;
|
|
597
|
-
return `The ${t} field must be at least ${
|
|
600
|
+
return `The ${t} field must be at least ${s(r)} items.`;
|
|
598
601
|
},
|
|
599
602
|
notContainsAll: (t, e) => {
|
|
600
603
|
const { values: r } = e;
|
|
601
|
-
return `The ${t} field must not contain all of the following values together: ${r.join(", ")}.`;
|
|
604
|
+
return `The ${t} field must not contain all of the following values together: ${r.map((n) => `"${n}"`).join(", ")}.`;
|
|
602
605
|
},
|
|
603
606
|
notContainsAny: (t, e) => {
|
|
604
607
|
const { values: r } = e;
|
|
605
|
-
return `The ${t} field must not contain any of the following values: ${r.join(", ")}.`;
|
|
608
|
+
return `The ${t} field must not contain any of the following values: ${r.map((n) => `"${n}"`).join(", ")}.`;
|
|
606
609
|
},
|
|
607
610
|
notEquals: (t, e) => {
|
|
608
611
|
const { value: r } = e;
|
|
@@ -610,13 +613,13 @@ const _ = {
|
|
|
610
613
|
},
|
|
611
614
|
notOneOf: (t, e) => {
|
|
612
615
|
const { values: r } = e;
|
|
613
|
-
return `The ${t} field must not be one of the following values: ${r.join(", ")}.`;
|
|
616
|
+
return `The ${t} field must not be one of the following values: ${r.map((n) => `"${n}"`).join(", ")}.`;
|
|
614
617
|
},
|
|
615
618
|
number: (t) => `The ${t} field must be a number.`,
|
|
616
619
|
numeric: (t) => `The ${t} field must be a number.`,
|
|
617
620
|
oneOf: (t, e) => {
|
|
618
621
|
const { values: r } = e;
|
|
619
|
-
return `The ${t} field must be one of the following values: ${r.join(", ")}.`;
|
|
622
|
+
return `The ${t} field must be one of the following values: ${r.map((n) => `"${n}"`).join(", ")}.`;
|
|
620
623
|
},
|
|
621
624
|
regex: (t) => `The ${t} field must match the required format.`,
|
|
622
625
|
required: (t) => `The ${t} field is required.`,
|
|
@@ -627,8 +630,8 @@ const _ = {
|
|
|
627
630
|
size: (t, e) => {
|
|
628
631
|
const { size: r } = e;
|
|
629
632
|
return {
|
|
630
|
-
number: `The ${t} field must be ${
|
|
631
|
-
array: `The ${t} field must contain items where each item is ${
|
|
633
|
+
number: `The ${t} field must be ${s(r)}.`,
|
|
634
|
+
array: `The ${t} field must contain items where each item is ${s(r)}.`
|
|
632
635
|
};
|
|
633
636
|
},
|
|
634
637
|
startsWith: (t, e) => {
|
|
@@ -637,53 +640,53 @@ const _ = {
|
|
|
637
640
|
},
|
|
638
641
|
string: (t) => `The ${t} field must be a string.`,
|
|
639
642
|
stringBetweenLength: (t, e) => {
|
|
640
|
-
const { min: r, max:
|
|
643
|
+
const { min: r, max: n } = e;
|
|
641
644
|
return {
|
|
642
|
-
string: `The ${t} field must be between ${
|
|
643
|
-
array: `The ${t} field must contain items where each item is between ${
|
|
645
|
+
string: `The ${t} field must be between ${s(r)} and ${s(n)} characters.`,
|
|
646
|
+
array: `The ${t} field must contain items where each item is between ${s(r)} and ${s(n)} characters.`
|
|
644
647
|
};
|
|
645
648
|
},
|
|
646
649
|
stringContainsAll: (t, e) => {
|
|
647
650
|
const { values: r } = e;
|
|
648
|
-
return `The ${t} field must contain all of the following text: ${r.join(", ")}.`;
|
|
651
|
+
return `The ${t} field must contain all of the following text: ${r.map((n) => `"${n}"`).join(", ")}.`;
|
|
649
652
|
},
|
|
650
653
|
stringContainsAny: (t, e) => {
|
|
651
654
|
const { values: r } = e;
|
|
652
|
-
return `The ${t} field must contain at least one of the following text: ${r.join(", ")}.`;
|
|
655
|
+
return `The ${t} field must contain at least one of the following text: ${r.map((n) => `"${n}"`).join(", ")}.`;
|
|
653
656
|
},
|
|
654
657
|
stringLength: (t, e) => {
|
|
655
658
|
const { length: r } = e;
|
|
656
659
|
return {
|
|
657
|
-
string: `The ${t} field must be ${
|
|
658
|
-
array: `The ${t} field must contain items where each item is ${
|
|
660
|
+
string: `The ${t} field must be ${s(r)} characters.`,
|
|
661
|
+
array: `The ${t} field must contain items where each item is ${s(r)} characters.`
|
|
659
662
|
};
|
|
660
663
|
},
|
|
661
664
|
stringMaxLength: (t, e) => {
|
|
662
665
|
const { length: r } = e;
|
|
663
666
|
return {
|
|
664
|
-
string: `The ${t} field must not be greater than ${
|
|
665
|
-
array: `The ${t} field must contain items where each item is not greater than ${
|
|
667
|
+
string: `The ${t} field must not be greater than ${s(r)} characters.`,
|
|
668
|
+
array: `The ${t} field must contain items where each item is not greater than ${s(r)} characters.`
|
|
666
669
|
};
|
|
667
670
|
},
|
|
668
671
|
stringMinLength: (t, e) => {
|
|
669
672
|
const { length: r } = e;
|
|
670
673
|
return {
|
|
671
|
-
string: `The ${t} field must be at least ${
|
|
672
|
-
array: `The ${t} field must contain items where each item is at least ${
|
|
674
|
+
string: `The ${t} field must be at least ${s(r)} characters.`,
|
|
675
|
+
array: `The ${t} field must contain items where each item is at least ${s(r)} characters.`
|
|
673
676
|
};
|
|
674
677
|
},
|
|
675
678
|
stringNotContainsAll: (t, e) => {
|
|
676
679
|
const { values: r } = e;
|
|
677
|
-
return `The ${t} field must not contain all of the following text together: ${r.join(", ")}.`;
|
|
680
|
+
return `The ${t} field must not contain all of the following text together: ${r.map((n) => `"${n}"`).join(", ")}.`;
|
|
678
681
|
},
|
|
679
682
|
stringNotContainsAny: (t, e) => {
|
|
680
683
|
const { values: r } = e;
|
|
681
|
-
return `The ${t} field must not contain any of the following text: ${r.join(", ")}.`;
|
|
684
|
+
return `The ${t} field must not contain any of the following text: ${r.map((n) => `"${n}"`).join(", ")}.`;
|
|
682
685
|
},
|
|
683
686
|
unique: (t) => `The ${t} field has already been taken.`,
|
|
684
687
|
uppercase: (t) => `The ${t} field must be uppercase.`,
|
|
685
688
|
url: (t) => `The ${t} field must be a valid URL.`
|
|
686
|
-
},
|
|
689
|
+
}, j = {
|
|
687
690
|
accepted: () => "此欄位必須被同意",
|
|
688
691
|
alpha: () => "此欄位只能包含字母",
|
|
689
692
|
alphaDash: () => "此欄位只能包含字母、數字、連接號和底線",
|
|
@@ -692,15 +695,15 @@ const _ = {
|
|
|
692
695
|
array: () => "此欄位必須是一個陣列",
|
|
693
696
|
ascii: () => "此欄位只能包含ASCII字元和符號",
|
|
694
697
|
between: (t, e) => {
|
|
695
|
-
const { min: r, max:
|
|
698
|
+
const { min: r, max: n } = e;
|
|
696
699
|
return {
|
|
697
|
-
number: `此欄位必須介於${
|
|
698
|
-
array: `此欄位中的每個項目都必須介於${
|
|
700
|
+
number: `此欄位必須介於${s(r)}到${s(n)}`,
|
|
701
|
+
array: `此欄位中的每個項目都必須介於${s(r)}到${s(n)}`
|
|
699
702
|
};
|
|
700
703
|
},
|
|
701
704
|
betweenLength: (t, e) => {
|
|
702
|
-
const { min: r, max:
|
|
703
|
-
return `此欄位必須介於${
|
|
705
|
+
const { min: r, max: n } = e;
|
|
706
|
+
return `此欄位必須介於${s(r)}到${s(n)}個項目之間`;
|
|
704
707
|
},
|
|
705
708
|
boolean: () => "此欄位必須是一個布林值",
|
|
706
709
|
containsAll: (t, e) => {
|
|
@@ -729,31 +732,31 @@ const _ = {
|
|
|
729
732
|
},
|
|
730
733
|
file: () => "此欄位必須是檔案",
|
|
731
734
|
fileBetweenSize: (t, e) => {
|
|
732
|
-
const { min: r, max:
|
|
735
|
+
const { min: r, max: n } = e;
|
|
733
736
|
return {
|
|
734
|
-
file: `此欄位必須介於${
|
|
735
|
-
array: `此欄位中的每個項目都必須介於${
|
|
737
|
+
file: `此欄位必須介於${s(r)}到${s(n)} KB之間`,
|
|
738
|
+
array: `此欄位中的每個項目都必須介於${s(r)}到${s(n)} KB之間`
|
|
736
739
|
};
|
|
737
740
|
},
|
|
738
741
|
fileMaxSize: (t, e) => {
|
|
739
742
|
const { size: r } = e;
|
|
740
743
|
return {
|
|
741
|
-
file: `此欄位不能大於${
|
|
742
|
-
array: `此欄位中的每個項目都不能大於${
|
|
744
|
+
file: `此欄位不能大於${s(r)} KB`,
|
|
745
|
+
array: `此欄位中的每個項目都不能大於${s(r)} KB`
|
|
743
746
|
};
|
|
744
747
|
},
|
|
745
748
|
fileMinSize: (t, e) => {
|
|
746
749
|
const { size: r } = e;
|
|
747
750
|
return {
|
|
748
|
-
file: `此欄位不能小於${
|
|
749
|
-
array: `此欄位中的每個項目都不能小於${
|
|
751
|
+
file: `此欄位不能小於${s(r)} KB`,
|
|
752
|
+
array: `此欄位中的每個項目都不能小於${s(r)} KB`
|
|
750
753
|
};
|
|
751
754
|
},
|
|
752
755
|
fileSize: (t, e) => {
|
|
753
756
|
const { size: r } = e;
|
|
754
757
|
return {
|
|
755
|
-
file: `此欄位必須是${
|
|
756
|
-
array: `此欄位中的每個項目都必須是${
|
|
758
|
+
file: `此欄位必須是${s(r)} KB`,
|
|
759
|
+
array: `此欄位中的每個項目都必須是${s(r)} KB`
|
|
757
760
|
};
|
|
758
761
|
},
|
|
759
762
|
http: () => "此欄位必須以 http:// 或 https:// 開頭",
|
|
@@ -762,30 +765,30 @@ const _ = {
|
|
|
762
765
|
json: () => "此欄位必須是有效的 JSON 字串",
|
|
763
766
|
length: (t, e) => {
|
|
764
767
|
const { length: r } = e;
|
|
765
|
-
return `此欄位必須包含${
|
|
768
|
+
return `此欄位必須包含${s(r)}個項目`;
|
|
766
769
|
},
|
|
767
770
|
lowercase: () => "此欄位必須是小寫",
|
|
768
771
|
max: (t, e) => {
|
|
769
772
|
const { max: r } = e;
|
|
770
773
|
return {
|
|
771
|
-
number: `此欄位不能大於${
|
|
772
|
-
array: `此欄位中的每個項目都不能大於${
|
|
774
|
+
number: `此欄位不能大於${s(r)}`,
|
|
775
|
+
array: `此欄位中的每個項目都不能大於${s(r)}`
|
|
773
776
|
};
|
|
774
777
|
},
|
|
775
778
|
maxLength: (t, e) => {
|
|
776
779
|
const { length: r } = e;
|
|
777
|
-
return `此欄位不能大於${
|
|
780
|
+
return `此欄位不能大於${s(r)}個項目`;
|
|
778
781
|
},
|
|
779
782
|
min: (t, e) => {
|
|
780
783
|
const { min: r } = e;
|
|
781
784
|
return {
|
|
782
|
-
number: `此欄位不能小於${
|
|
783
|
-
array: `此欄位中的每個項目都不能小於${
|
|
785
|
+
number: `此欄位不能小於${s(r)}`,
|
|
786
|
+
array: `此欄位中的每個項目都不能小於${s(r)}`
|
|
784
787
|
};
|
|
785
788
|
},
|
|
786
789
|
minLength: (t, e) => {
|
|
787
790
|
const { length: r } = e;
|
|
788
|
-
return `此欄位不能小於${
|
|
791
|
+
return `此欄位不能小於${s(r)}個項目`;
|
|
789
792
|
},
|
|
790
793
|
notContainsAll: (t, e) => {
|
|
791
794
|
const { values: r } = e;
|
|
@@ -818,8 +821,8 @@ const _ = {
|
|
|
818
821
|
size: (t, e) => {
|
|
819
822
|
const { size: r } = e;
|
|
820
823
|
return {
|
|
821
|
-
number: `此欄位必須是${
|
|
822
|
-
array: `此欄位中的每個項目都必須是${
|
|
824
|
+
number: `此欄位必須是${s(r)}`,
|
|
825
|
+
array: `此欄位中的每個項目都必須是${s(r)}`
|
|
823
826
|
};
|
|
824
827
|
},
|
|
825
828
|
startsWith: (t, e) => {
|
|
@@ -828,10 +831,10 @@ const _ = {
|
|
|
828
831
|
},
|
|
829
832
|
string: () => "此欄位必須是字串",
|
|
830
833
|
stringBetweenLength: (t, e) => {
|
|
831
|
-
const { min: r, max:
|
|
834
|
+
const { min: r, max: n } = e;
|
|
832
835
|
return {
|
|
833
|
-
string: `此欄位必須介於${
|
|
834
|
-
array: `此欄位中的每個項目都必須介於${
|
|
836
|
+
string: `此欄位必須介於${s(r)}到${s(n)}個字元之間`,
|
|
837
|
+
array: `此欄位中的每個項目都必須介於${s(r)}到${s(n)}個字元之間`
|
|
835
838
|
};
|
|
836
839
|
},
|
|
837
840
|
stringContainsAll: (t, e) => {
|
|
@@ -845,22 +848,22 @@ const _ = {
|
|
|
845
848
|
stringLength: (t, e) => {
|
|
846
849
|
const { length: r } = e;
|
|
847
850
|
return {
|
|
848
|
-
string: `此欄位必須是${
|
|
849
|
-
array: `此欄位中的每個項目都必須是${
|
|
851
|
+
string: `此欄位必須是${s(r)}個字元`,
|
|
852
|
+
array: `此欄位中的每個項目都必須是${s(r)}個字元`
|
|
850
853
|
};
|
|
851
854
|
},
|
|
852
855
|
stringMaxLength: (t, e) => {
|
|
853
856
|
const { length: r } = e;
|
|
854
857
|
return {
|
|
855
|
-
string: `此欄位不能大於${
|
|
856
|
-
array: `此欄位中的每個項目都不能大於${
|
|
858
|
+
string: `此欄位不能大於${s(r)}個字元`,
|
|
859
|
+
array: `此欄位中的每個項目都不能大於${s(r)}個字元`
|
|
857
860
|
};
|
|
858
861
|
},
|
|
859
862
|
stringMinLength: (t, e) => {
|
|
860
863
|
const { length: r } = e;
|
|
861
864
|
return {
|
|
862
|
-
string: `此欄位不能小於${
|
|
863
|
-
array: `此欄位中的每個項目都不能小於${
|
|
865
|
+
string: `此欄位不能小於${s(r)}個字元`,
|
|
866
|
+
array: `此欄位中的每個項目都不能小於${s(r)}個字元`
|
|
864
867
|
};
|
|
865
868
|
},
|
|
866
869
|
stringNotContainsAll: (t, e) => {
|
|
@@ -874,102 +877,102 @@ const _ = {
|
|
|
874
877
|
unique: () => "此欄位已經存在",
|
|
875
878
|
uppercase: () => "此欄位必須是大寫",
|
|
876
879
|
url: () => "此欄位必須是有效的網址"
|
|
877
|
-
},
|
|
878
|
-
en:
|
|
879
|
-
"zh-TW":
|
|
880
|
-
},
|
|
881
|
-
if (
|
|
880
|
+
}, M = {
|
|
881
|
+
en: q,
|
|
882
|
+
"zh-TW": j
|
|
883
|
+
}, F = () => (t) => a(t) ? !1 : ["y", "yes", "on", "1", "true"].includes(String(t).toLowerCase()), k = () => (t) => a(t) ? !1 : /^[a-zA-Z]+$/.test(String(t)), O = () => (t) => a(t) ? !1 : /^[a-zA-Z0-9-_]+$/.test(String(t)), E = () => (t) => a(t) ? !1 : /^[a-zA-Z0-9-_.]+$/.test(String(t)), B = () => (t) => a(t) ? !1 : /^[a-zA-Z0-9]+$/.test(String(t)), D = () => (t) => Array.isArray(t), N = () => (t) => a(t) ? !1 : /^[\x20-\x7E]+$/.test(String(t)), h = ({ max: t }) => (e) => a(e) ? !1 : typeof e == "number" ? e <= t : Array.isArray(e) ? e.every((r) => h({ max: t })(r)) : !1, c = ({ min: t }) => (e) => a(e) ? !1 : typeof e == "number" ? e >= t : Array.isArray(e) ? e.every((r) => c({ min: t })(r)) : !1, W = ({ min: t, max: e }) => (r) => a(r) ? !1 : c({ min: t })(r) && h({ max: e })(r), A = ({ length: t }) => (e) => a(e) ? !1 : Array.isArray(e) ? e.length <= t : !1, w = ({ length: t }) => (e) => a(e) ? !1 : Array.isArray(e) ? e.length >= t : !1, Z = ({ min: t, max: e }) => (r) => a(r) ? !1 : w({ length: t })(r) && A({ length: e })(r), K = () => (t) => a(t) ? !1 : typeof t == "boolean", p = ({ values: t }) => (e) => a(e) ? !1 : Array.isArray(e) ? t.every((r) => e.includes(r)) : !1, b = ({ values: t }) => (e) => a(e) ? !1 : Array.isArray(e) ? t.some((r) => e.includes(r)) : !1, I = () => (t) => a(t) ? !1 : ["n", "no", "off", "0", "false"].includes(String(t).toLowerCase()), J = ({ value: t }) => (e) => a(e) ? !1 : e !== t, P = () => (t) => a(t) ? !1 : Array.isArray(t) ? new Set(t).size === t.length : !0, U = () => (t) => a(t) ? !1 : /^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(String(t)), V = () => (t) => a(t) ? !1 : /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(String(t)), G = ({ value: t }) => (e) => a(e) ? !1 : String(e).endsWith(t), H = ({ value: t }) => (e) => e === t, Q = () => (t) => t instanceof File, f = ({ size: t }) => (e) => a(e) ? !1 : e instanceof File ? e.size <= t * 1024 : Array.isArray(e) ? e.every((r) => f({ size: t })(r)) : !1, m = ({ size: t }) => (e) => a(e) ? !1 : e instanceof File ? e.size >= t * 1024 : Array.isArray(e) ? e.every((r) => m({ size: t })(r)) : !1, X = ({ min: t, max: e }) => (r) => a(r) ? !1 : m({ size: t })(r) && f({ size: e })(r), T = ({ size: t }) => (e) => {
|
|
884
|
+
if (a(e))
|
|
882
885
|
return !1;
|
|
883
886
|
if (e instanceof File) {
|
|
884
|
-
const r = t * 1024,
|
|
885
|
-
return e.size >= r && e.size <
|
|
887
|
+
const r = t * 1024, n = (t + 1) * 1024;
|
|
888
|
+
return e.size >= r && e.size < n;
|
|
886
889
|
}
|
|
887
890
|
return Array.isArray(e) ? e.every((r) => T({ size: t })(r)) : !1;
|
|
888
|
-
}, o = ({ value: t }) => (e) =>
|
|
889
|
-
if (
|
|
891
|
+
}, o = ({ value: t }) => (e) => a(e) ? !1 : String(e).startsWith(t), Y = () => (t) => a(t) ? !1 : o({ value: "http://" })(t) || o({ value: "https://" })(t), ee = () => (t) => a(t) ? !1 : o({ value: "https://" })(t), g = () => (t) => a(t) ? !1 : typeof t == "number", te = () => (t) => a(t) ? !1 : g()(t) && Number.isInteger(t), re = () => (t) => {
|
|
892
|
+
if (a(t))
|
|
890
893
|
return !1;
|
|
891
894
|
try {
|
|
892
895
|
return JSON.parse(String(t)), !0;
|
|
893
896
|
} catch {
|
|
894
897
|
return !1;
|
|
895
898
|
}
|
|
896
|
-
},
|
|
897
|
-
if (
|
|
899
|
+
}, ne = ({ length: t }) => (e) => a(e) ? !1 : Array.isArray(e) ? e.length === t : !1, se = () => (t) => a(t) ? !1 : String(t) === String(t).toLowerCase(), ae = ({ values: t }) => (e) => a(e) ? !1 : Array.isArray(e) ? !t.every((r) => e.includes(r)) : !1, ie = ({ values: t }) => (e) => a(e) ? !1 : Array.isArray(e) ? !t.some((r) => e.includes(r)) : !1, le = ({ value: t }) => (e) => e !== t, ue = ({ values: t }) => (e) => a(e) ? !1 : !t.includes(e), R = () => (t) => typeof t == "string", oe = () => (t) => a(t) ? !1 : R()(t) ? /^-?\d+(\.\d+)?$/.test(String(t)) : g()(t), he = ({ values: t }) => (e) => a(e) ? !1 : t.includes(e), ce = ({ expression: t }) => (e) => {
|
|
900
|
+
if (a(e))
|
|
898
901
|
return !1;
|
|
899
902
|
if (!(t instanceof RegExp))
|
|
900
903
|
throw new TypeError("The expression provided is not a valid RegExp.");
|
|
901
904
|
return t.test(String(e));
|
|
902
|
-
},
|
|
903
|
-
accepted:
|
|
904
|
-
alpha:
|
|
905
|
-
alphaDash:
|
|
906
|
-
alphaDashDot:
|
|
905
|
+
}, fe = () => (t) => !a(t), me = ({ value: t }) => (e) => a(e) ? !1 : Array.isArray(e) ? e.every((r) => r === t) : e === t, L = ({ size: t }) => (e) => a(e) ? !1 : typeof e == "number" ? e === t : Array.isArray(e) ? e.every((r) => L({ size: t })(r)) : !1, y = ({ length: t }) => (e) => a(e) ? !1 : typeof e == "string" ? e.length <= t : Array.isArray(e) ? e.every((r) => y({ length: t })(r)) : !1, $ = ({ length: t }) => (e) => a(e) ? !1 : typeof e == "string" ? e.length >= t : Array.isArray(e) ? e.every((r) => $({ length: t })(r)) : !1, ge = ({ min: t, max: e }) => (r) => a(r) ? !1 : $({ length: t })(r) && y({ length: e })(r), v = ({ length: t }) => (e) => a(e) ? !1 : typeof e == "string" ? e.length === t : Array.isArray(e) ? e.every((r) => v({ length: t })(r)) : !1, ye = ({ values: t }) => (e) => a(e) ? !1 : typeof e == "string" ? !t.every((r) => e.includes(r)) : !1, $e = ({ values: t }) => (e) => a(e) ? !1 : typeof e == "string" ? !t.some((r) => e.includes(r)) : !1, de = ({ values: t, ignored: e = [] }) => (r) => a(r) ? !1 : (Array.isArray(e) ? e : [e]).some((n) => n === r) ? !0 : !t.some((n) => n === r), pe = () => (t) => a(t) ? !1 : String(t) === String(t).toUpperCase(), be = () => (t) => a(t) ? !1 : /^(https?):\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}.*$/.test(String(t)), Ae = {
|
|
906
|
+
accepted: F,
|
|
907
|
+
alpha: k,
|
|
908
|
+
alphaDash: O,
|
|
909
|
+
alphaDashDot: E,
|
|
907
910
|
alphaNum: B,
|
|
908
911
|
array: D,
|
|
909
|
-
ascii:
|
|
910
|
-
between:
|
|
911
|
-
betweenLength:
|
|
912
|
-
boolean:
|
|
912
|
+
ascii: N,
|
|
913
|
+
between: W,
|
|
914
|
+
betweenLength: Z,
|
|
915
|
+
boolean: K,
|
|
913
916
|
containsAll: p,
|
|
914
917
|
containsAny: b,
|
|
915
|
-
declined:
|
|
916
|
-
different:
|
|
917
|
-
distinct:
|
|
918
|
-
domain:
|
|
919
|
-
email:
|
|
920
|
-
endsWith:
|
|
921
|
-
equals:
|
|
922
|
-
file:
|
|
923
|
-
fileBetweenSize:
|
|
918
|
+
declined: I,
|
|
919
|
+
different: J,
|
|
920
|
+
distinct: P,
|
|
921
|
+
domain: U,
|
|
922
|
+
email: V,
|
|
923
|
+
endsWith: G,
|
|
924
|
+
equals: H,
|
|
925
|
+
file: Q,
|
|
926
|
+
fileBetweenSize: X,
|
|
924
927
|
fileMaxSize: f,
|
|
925
928
|
fileMinSize: m,
|
|
926
929
|
fileSize: T,
|
|
927
|
-
http:
|
|
928
|
-
https:
|
|
929
|
-
integer:
|
|
930
|
-
json:
|
|
931
|
-
length:
|
|
932
|
-
lowercase:
|
|
930
|
+
http: Y,
|
|
931
|
+
https: ee,
|
|
932
|
+
integer: te,
|
|
933
|
+
json: re,
|
|
934
|
+
length: ne,
|
|
935
|
+
lowercase: se,
|
|
933
936
|
max: h,
|
|
934
937
|
maxLength: A,
|
|
935
938
|
min: c,
|
|
936
939
|
minLength: w,
|
|
937
|
-
notContainsAll:
|
|
940
|
+
notContainsAll: ae,
|
|
938
941
|
notContainsAny: ie,
|
|
939
|
-
notEquals:
|
|
940
|
-
notOneOf:
|
|
942
|
+
notEquals: le,
|
|
943
|
+
notOneOf: ue,
|
|
941
944
|
number: g,
|
|
942
|
-
numeric:
|
|
943
|
-
oneOf:
|
|
944
|
-
regex:
|
|
945
|
-
required:
|
|
946
|
-
same:
|
|
945
|
+
numeric: oe,
|
|
946
|
+
oneOf: he,
|
|
947
|
+
regex: ce,
|
|
948
|
+
required: fe,
|
|
949
|
+
same: me,
|
|
947
950
|
size: L,
|
|
948
951
|
startsWith: o,
|
|
949
952
|
string: R,
|
|
950
|
-
stringBetweenLength:
|
|
953
|
+
stringBetweenLength: ge,
|
|
951
954
|
stringContainsAll: p,
|
|
952
955
|
stringContainsAny: b,
|
|
953
956
|
stringLength: v,
|
|
954
957
|
stringMaxLength: y,
|
|
955
|
-
stringMinLength:
|
|
956
|
-
stringNotContainsAll:
|
|
957
|
-
stringNotContainsAny:
|
|
958
|
+
stringMinLength: $,
|
|
959
|
+
stringNotContainsAll: ye,
|
|
960
|
+
stringNotContainsAny: $e,
|
|
958
961
|
unique: de,
|
|
959
|
-
uppercase:
|
|
960
|
-
url:
|
|
962
|
+
uppercase: pe,
|
|
963
|
+
url: be
|
|
961
964
|
};
|
|
962
|
-
class
|
|
965
|
+
class Te {
|
|
963
966
|
constructor({
|
|
964
967
|
fallbackLocale: e,
|
|
965
968
|
locale: r,
|
|
966
|
-
plugins:
|
|
969
|
+
plugins: n
|
|
967
970
|
} = {}) {
|
|
968
971
|
l(this, "locale", "en");
|
|
969
972
|
l(this, "fallbackLocale", "en");
|
|
970
973
|
l(this, "locales", {});
|
|
971
974
|
l(this, "rules", {});
|
|
972
|
-
this.registerLocales(
|
|
975
|
+
this.registerLocales(M), this.registerRules(Ae), e && this.setFallbackLocale(e), r && this.setLocale(r), n && n.forEach((i) => this.registerPlugin(i));
|
|
973
976
|
}
|
|
974
977
|
getLocale() {
|
|
975
978
|
return this.locale;
|
|
@@ -988,7 +991,7 @@ class we {
|
|
|
988
991
|
return this.fallbackLocale = e, this;
|
|
989
992
|
}
|
|
990
993
|
defineField(e) {
|
|
991
|
-
return new
|
|
994
|
+
return new _({
|
|
992
995
|
name: e,
|
|
993
996
|
locale: this.locale,
|
|
994
997
|
fallbackLocale: this.fallbackLocale,
|
|
@@ -998,7 +1001,7 @@ class we {
|
|
|
998
1001
|
}
|
|
999
1002
|
registerLocales(e) {
|
|
1000
1003
|
return this.locales = Object.keys(e).reduce(
|
|
1001
|
-
(r,
|
|
1004
|
+
(r, n) => (r[n] = { ...this.locales[n], ...e[n] }, r),
|
|
1002
1005
|
{ ...this.locales }
|
|
1003
1006
|
), this;
|
|
1004
1007
|
}
|
|
@@ -1012,6 +1015,6 @@ class we {
|
|
|
1012
1015
|
}
|
|
1013
1016
|
}
|
|
1014
1017
|
export {
|
|
1015
|
-
|
|
1016
|
-
|
|
1018
|
+
_ as FieldValidator,
|
|
1019
|
+
Te as FormValidator
|
|
1017
1020
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(u,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(u=typeof globalThis<"u"?globalThis:u||self,l(u.Fortress={}))})(this,function(u){"use strict";var me=Object.defineProperty;var ge=(u,l,n)=>l in u?me(u,l,{enumerable:!0,configurable:!0,writable:!0,value:n}):u[l]=n;var o=(u,l,n)=>(ge(u,typeof l!="symbol"?l+"":l,n),n);const l=t=>t.replace(/([^\x20-\x7E])([\x20-\x7E])/gu,"$1 $2").replace(/([\x20-\x7E])([^\x20-\x7E])/gu,"$1 $2").replace(/ +/g," "),n=(t,e=0)=>new Intl.NumberFormat(void 0,{minimumFractionDigits:e,maximumFractionDigits:e}).format(t),z=t=>Object.prototype.toString.call(t).toLowerCase().slice(8,-1),s=t=>t==null||t===""||Array.isArray(t)&&t.length<1;class b{constructor({name:e,locale:r,fallbackLocale:i,locales:a,rules:h}){o(this,"name");o(this,"locale");o(this,"fallbackLocale");o(this,"locales");o(this,"rules");o(this,"ruleFunctions",[]);o(this,"conditions",{});o(this,"shouldSkip",!1);this.name=e,this.locale=r,this.fallbackLocale=i,this.locales=a,this.rules=h}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 i=>{if(s(i)&&!this.mandatoryRules.includes(e))return!0;const a=this.getRule(e)(r)(i);return typeof a=="string"?a:a===!0?!0:this.buildRuleFunctionMessage(e,r,i)}}buildRuleFunctionMessage(e,r,i){const a=this.getMessage(e)(this.formattedName,r);if(typeof a=="object"){const h=z(i);if(!(h in a))throw new Error(`The message for the "${e}" rule of the "${h}" type is missing.`);return l(a[h])}return l(a)}pushRuleFunction(e,r){if(e in this.conditions&&!this.conditions[e])return this;const i=this.buildRuleFunction(e,r);return this.ruleFunctions.push(i),this}getRuleFunctions(){return this.ruleFunctions}collect(){return this.shouldSkip?[]:this.getRuleFunctions()}validate(e){if(this.shouldSkip)return!0;for(const r of this.ruleFunctions){const i=r(e);if(typeof i=="string")return i}return!0}apply(e,r={}){return this.pushRuleFunction(e,r)}accepted(){return this.apply(this.accepted.name)}after(e,r,i,a=!0){return this.apply(this.after.name,{date:e,format:r,displayFormat:i,strict:a})}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)}ascii(){return this.apply(this.ascii.name)}before(e,r,i,a=!0){return this.apply(this.before.name,{date:e,format:r,displayFormat:i,strict:a})}between(e,r){return this.apply(this.between.name,{min:e,max:r})}betweenLength(e,r){return this.apply(this.betweenLength.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)}fileBetweenSize(e,r){return this.apply(this.fileBetweenSize.name,{min:e,max:r})}fileMaxSize(e){return this.apply(this.fileMaxSize.name,{size:e})}fileMinSize(e){return this.apply(this.fileMinSize.name,{size:e})}fileSize(e){return this.apply(this.fileSize.name,{size:e})}http(){return this.apply(this.http.name)}https(){return this.apply(this.https.name)}integer(){return this.apply(this.integer.name)}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})}length(e){return this.apply(this.length.name,{length:e})}lowercase(){return this.apply(this.lowercase.name)}max(e){return this.apply(this.max.name,{max:e})}maxLength(e){return this.apply(this.maxLength.name,{length:e})}min(e){return this.apply(this.min.name,{min:e})}minLength(e){return this.apply(this.minLength.name,{length:e})}notContainsAll(e){return this.apply(this.notContainsAll.name,{values:e})}notContainsAny(e){return this.apply(this.notContainsAny.name,{values:e})}notEquals(e){return this.apply(this.notEquals.name,{value:e})}notOneOf(e){return this.apply(this.notOneOf.name,{values:e})}number(){return this.apply(this.number.name)}numeric(){return this.apply(this.numeric.name)}oneOf(e){return this.apply(this.oneOf.name,{values:e})}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})}string(){return this.apply(this.string.name)}stringBetweenLength(e,r){return this.apply(this.stringBetweenLength.name,{min:e,max:r})}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})}stringMaxLength(e){return this.apply(this.stringMaxLength.name,{length:e})}stringMinLength(e){return this.apply(this.stringMinLength.name,{length:e})}stringNotContainsAll(e){return this.apply(this.stringNotContainsAll.name,{values:e})}stringNotContainsAny(e){return this.apply(this.stringNotContainsAny.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 C={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.`,ascii:t=>`The ${t} field must only contain ASCII characters and symbols.`,between:(t,e)=>{const{min:r,max:i}=e;return{number:`The ${t} field must be between ${n(r)} and ${n(i)}.`,array:`The ${t} field must contain items where each item is between ${n(r)} and ${n(i)}.`}},betweenLength:(t,e)=>{const{min:r,max:i}=e;return`The ${t} field must be between ${n(r)} and ${n(i)} items.`},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.join(", ")}.`},containsAny:(t,e)=>{const{values:r}=e;return`The ${t} field must contain at least one of the following values: ${r.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 ${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.`,fileBetweenSize:(t,e)=>{const{min:r,max:i}=e;return{file:`The ${t} field must be between ${n(r)} and ${n(i)} kilobytes.`,array:`The ${t} field must contain items where each item is between ${n(r)} and ${n(i)} kilobytes.`}},fileMaxSize:(t,e)=>{const{size:r}=e;return{file:`The ${t} field must not be greater than ${n(r)} kilobytes.`,array:`The ${t} field must contain items where each item is not greater than ${n(r)} kilobytes.`}},fileMinSize:(t,e)=>{const{size:r}=e;return{file:`The ${t} field must be at least ${n(r)} kilobytes.`,array:`The ${t} field must contain items where each item is at least ${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 either "http://" or "https://".`,https:t=>`The ${t} field must start with "http://".`,integer:t=>`The ${t} field must be an integer.`,json:t=>`The ${t} field must be a valid JSON string.`,length:(t,e)=>{const{length:r}=e;return`The ${t} field must be ${n(r)} items.`},lowercase:t=>`The ${t} field must be lowercase.`,max:(t,e)=>{const{max:r}=e;return{number:`The ${t} field must not be greater than ${n(r)}.`,array:`The ${t} field must contain items where each item is not greater than ${n(r)}.`}},maxLength:(t,e)=>{const{length:r}=e;return`The ${t} field must not be greater than ${n(r)} items.`},min:(t,e)=>{const{min:r}=e;return{number:`The ${t} field must be at least ${n(r)}.`,array:`The ${t} field must contain items where each item is at least ${n(r)}.`}},minLength:(t,e)=>{const{length:r}=e;return`The ${t} field must be at least ${n(r)} items.`},notContainsAll:(t,e)=>{const{values:r}=e;return`The ${t} field must not contain all of the following values together: ${r.join(", ")}.`},notContainsAny:(t,e)=>{const{values:r}=e;return`The ${t} field must not contain any of the following values: ${r.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.join(", ")}.`},number:t=>`The ${t} field must be a number.`,numeric:t=>`The ${t} field must be a number.`,oneOf:(t,e)=>{const{values:r}=e;return`The ${t} field must be one of the following values: ${r.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 ${r}.`},string:t=>`The ${t} field must be a string.`,stringBetweenLength:(t,e)=>{const{min:r,max:i}=e;return{string:`The ${t} field must be between ${n(r)} and ${n(i)} characters.`,array:`The ${t} field must contain items where each item is between ${n(r)} and ${n(i)} characters.`}},stringContainsAll:(t,e)=>{const{values:r}=e;return`The ${t} field must contain all of the following text: ${r.join(", ")}.`},stringContainsAny:(t,e)=>{const{values:r}=e;return`The ${t} field must contain at least one of the following text: ${r.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.`}},stringMaxLength:(t,e)=>{const{length:r}=e;return{string:`The ${t} field must not be greater than ${n(r)} characters.`,array:`The ${t} field must contain items where each item is not greater than ${n(r)} characters.`}},stringMinLength:(t,e)=>{const{length:r}=e;return{string:`The ${t} field must be at least ${n(r)} characters.`,array:`The ${t} field must contain items where each item is at least ${n(r)} characters.`}},stringNotContainsAll:(t,e)=>{const{values:r}=e;return`The ${t} field must not contain all of the following text together: ${r.join(", ")}.`},stringNotContainsAny:(t,e)=>{const{values:r}=e;return`The ${t} field must not contain any of the following text: ${r.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:()=>"此欄位必須是一個陣列",ascii:()=>"此欄位只能包含ASCII字元和符號",between:(t,e)=>{const{min:r,max:i}=e;return{number:`此欄位必須介於${n(r)}到${n(i)}`,array:`此欄位中的每個項目都必須介於${n(r)}到${n(i)}`}},betweenLength:(t,e)=>{const{min:r,max:i}=e;return`此欄位必須介於${n(r)}到${n(i)}個項目之間`},boolean:()=>"此欄位必須是一個布林值",containsAll:(t,e)=>{const{values:r}=e;return`此欄位必須包含以下所有項目:${r.join(", ")}`},containsAny:(t,e)=>{const{values:r}=e;return`此欄位必須包含以下其中一個項目:${r.join(", ")}`},declined:()=>"此欄位必須被拒絕",different:(t,e)=>{const{field:r}=e;return`此欄位必須和${r}欄位不同`},distinct:()=>"此欄位不能包含重複的值",domain:()=>"此欄位必須是有效的網域",email:()=>"此欄位必須是有效的電子郵件地址",endsWith:(t,e)=>{const{value:r}=e;return`此欄位必須以${r}結尾`},equals:(t,e)=>{const{value:r}=e;return`此欄位必須是${r}`},file:()=>"此欄位必須是檔案",fileBetweenSize:(t,e)=>{const{min:r,max:i}=e;return{file:`此欄位必須介於${n(r)}到${n(i)} KB之間`,array:`此欄位中的每個項目都必須介於${n(r)}到${n(i)} KB之間`}},fileMaxSize:(t,e)=>{const{size:r}=e;return{file:`此欄位不能大於${n(r)} KB`,array:`此欄位中的每個項目都不能大於${n(r)} KB`}},fileMinSize:(t,e)=>{const{size:r}=e;return{file:`此欄位不能小於${n(r)} KB`,array:`此欄位中的每個項目都不能小於${n(r)} KB`}},fileSize:(t,e)=>{const{size:r}=e;return{file:`此欄位必須是${n(r)} KB`,array:`此欄位中的每個項目都必須是${n(r)} KB`}},http:()=>"此欄位必須以 http:// 或 https:// 開頭",https:()=>"此欄位必須以 https:// 開頭",integer:()=>"此欄位必須是整數",json:()=>"此欄位必須是有效的 JSON 字串",length:(t,e)=>{const{length:r}=e;return`此欄位必須包含${n(r)}個項目`},lowercase:()=>"此欄位必須是小寫",max:(t,e)=>{const{max:r}=e;return{number:`此欄位不能大於${n(r)}`,array:`此欄位中的每個項目都不能大於${n(r)}`}},maxLength:(t,e)=>{const{length:r}=e;return`此欄位不能大於${n(r)}個項目`},min:(t,e)=>{const{min:r}=e;return{number:`此欄位不能小於${n(r)}`,array:`此欄位中的每個項目都不能小於${n(r)}`}},minLength:(t,e)=>{const{length:r}=e;return`此欄位不能小於${n(r)}個項目`},notContainsAll:(t,e)=>{const{values:r}=e;return`此欄位不能同時包含以下所有值:${r.join(", ")}`},notContainsAny:(t,e)=>{const{values:r}=e;return`此欄位不能包含以下任何值:${r.join(", ")}`},notEquals:(t,e)=>{const{value:r}=e;return`此欄位不能是${r}`},notOneOf:(t,e)=>{const{values:r}=e;return`此欄位不能是以下任何值:${r.join(", ")}`},number:()=>"此欄位必須是數字",numeric:()=>"此欄位必須是數字",oneOf:(t,e)=>{const{values:r}=e;return`此欄位必須是以下任何值:${r.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`此欄位必須以${r}開頭`},string:()=>"此欄位必須是字串",stringBetweenLength:(t,e)=>{const{min:r,max:i}=e;return{string:`此欄位必須介於${n(r)}到${n(i)}個字元之間`,array:`此欄位中的每個項目都必須介於${n(r)}到${n(i)}個字元之間`}},stringContainsAll:(t,e)=>{const{values:r}=e;return`此欄位必須包含以下所有文字:${r.join(", ")}`},stringContainsAny:(t,e)=>{const{values:r}=e;return`此欄位必須包含以下其中一個文字:${r.join(", ")}`},stringLength:(t,e)=>{const{length:r}=e;return{string:`此欄位必須是${n(r)}個字元`,array:`此欄位中的每個項目都必須是${n(r)}個字元`}},stringMaxLength:(t,e)=>{const{length:r}=e;return{string:`此欄位不能大於${n(r)}個字元`,array:`此欄位中的每個項目都不能大於${n(r)}個字元`}},stringMinLength:(t,e)=>{const{length:r}=e;return{string:`此欄位不能小於${n(r)}個字元`,array:`此欄位中的每個項目都不能小於${n(r)}個字元`}},stringNotContainsAll:(t,e)=>{const{values:r}=e;return`此欄位不能同時包含以下所有文字:${r.join(", ")}`},stringNotContainsAny:(t,e)=>{const{values:r}=e;return`此欄位不能包含以下任何文字:${r.join(", ")}`},unique:()=>"此欄位已經存在",uppercase:()=>"此欄位必須是大寫",url:()=>"此欄位必須是有效的網址"}},_=()=>t=>s(t)?!1:["y","yes","on","1","true"].includes(String(t).toLowerCase()),j=()=>t=>s(t)?!1:/^[a-zA-Z]+$/.test(String(t)),q=()=>t=>s(t)?!1:/^[a-zA-Z0-9-_]+$/.test(String(t)),M=()=>t=>s(t)?!1:/^[a-zA-Z0-9-_.]+$/.test(String(t)),F=()=>t=>s(t)?!1:/^[a-zA-Z0-9]+$/.test(String(t)),k=()=>t=>Array.isArray(t),O=()=>t=>s(t)?!1:/^[\x20-\x7E]+$/.test(String(t)),c=({max:t})=>e=>s(e)?!1:typeof e=="number"?e<=t:Array.isArray(e)?e.every(r=>c({max:t})(r)):!1,m=({min:t})=>e=>s(e)?!1:typeof e=="number"?e>=t:Array.isArray(e)?e.every(r=>m({min:t})(r)):!1,B=({min:t,max:e})=>r=>s(r)?!1:m({min:t})(r)&&c({max:e})(r),A=({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,D=({min:t,max:e})=>r=>s(r)?!1:w({length:t})(r)&&A({length:e})(r),E=()=>t=>s(t)?!1:typeof t=="boolean",T=({values:t})=>e=>s(e)?!1:Array.isArray(e)?t.every(r=>e.includes(r)):!1,R=({values:t})=>e=>s(e)?!1:Array.isArray(e)?t.some(r=>e.includes(r)):!1,W=()=>t=>s(t)?!1:["n","no","off","0","false"].includes(String(t).toLowerCase()),N=({value:t})=>e=>s(e)?!1:e!==t,Z=()=>t=>s(t)?!1:Array.isArray(t)?new Set(t).size===t.length:!0,K=()=>t=>s(t)?!1:/^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(String(t)),I=()=>t=>s(t)?!1:/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(String(t)),V=({value:t})=>e=>s(e)?!1:String(e).endsWith(t),J=({value:t})=>e=>e===t,P=()=>t=>t instanceof File,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,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,U=({min:t,max:e})=>r=>s(r)?!1:y({size:t})(r)&&g({size:e})(r),L=({size:t})=>e=>{if(s(e))return!1;if(e instanceof File){const r=t*1024,i=(t+1)*1024;return e.size>=r&&e.size<i}return Array.isArray(e)?e.every(r=>L({size:t})(r)):!1},f=({value:t})=>e=>s(e)?!1:String(e).startsWith(t),G=()=>t=>s(t)?!1:f({value:"http://"})(t)||f({value:"https://"})(t),H=()=>t=>s(t)?!1:f({value:"https://"})(t),d=()=>t=>s(t)?!1:typeof t=="number",Q=()=>t=>s(t)?!1:d()(t)&&Number.isInteger(t),X=()=>t=>{if(s(t))return!1;try{return JSON.parse(String(t)),!0}catch{return!1}},Y=({length:t})=>e=>s(e)?!1:Array.isArray(e)?e.length===t:!1,ee=()=>t=>s(t)?!1:String(t)===String(t).toLowerCase(),te=({values:t})=>e=>s(e)?!1:Array.isArray(e)?!t.every(r=>e.includes(r)):!1,re=({values:t})=>e=>s(e)?!1:Array.isArray(e)?!t.some(r=>e.includes(r)):!1,ne=({value:t})=>e=>e!==t,se=({values:t})=>e=>s(e)?!1:!t.includes(e),v=()=>t=>typeof t=="string",ie=()=>t=>s(t)?!1:v()(t)?/^-?\d+(\.\d+)?$/.test(String(t)):d()(t),ae=({values:t})=>e=>s(e)?!1:t.includes(e),le=({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))},ue=()=>t=>!s(t),oe=({value:t})=>e=>s(e)?!1:Array.isArray(e)?e.every(r=>r===t):e===t,S=({size:t})=>e=>s(e)?!1:typeof e=="number"?e===t:Array.isArray(e)?e.every(r=>S({size:t})(r)):!1,$=({length:t})=>e=>s(e)?!1:typeof e=="string"?e.length<=t:Array.isArray(e)?e.every(r=>$({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,he=({min:t,max:e})=>r=>s(r)?!1:p({length:t})(r)&&$({length:e})(r),x=({length:t})=>e=>s(e)?!1:typeof e=="string"?e.length===t:Array.isArray(e)?e.every(r=>x({length:t})(r)):!1,fe={accepted:_,alpha:j,alphaDash:q,alphaDashDot:M,alphaNum:F,array:k,ascii:O,between:B,betweenLength:D,boolean:E,containsAll:T,containsAny:R,declined:W,different:N,distinct:Z,domain:K,email:I,endsWith:V,equals:J,file:P,fileBetweenSize:U,fileMaxSize:g,fileMinSize:y,fileSize:L,http:G,https:H,integer:Q,json:X,length:Y,lowercase:ee,max:c,maxLength:A,min:m,minLength:w,notContainsAll:te,notContainsAny:re,notEquals:ne,notOneOf:se,number:d,numeric:ie,oneOf:ae,regex:le,required:ue,same:oe,size:S,startsWith:f,string:v,stringBetweenLength:he,stringContainsAll:T,stringContainsAny:R,stringLength:x,stringMaxLength:$,stringMinLength:p,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,unique:({values:t,ignored:e=[]})=>r=>s(r)?!1:(Array.isArray(e)?e:[e]).some(i=>i===r)?!0:!t.some(i=>i===r),uppercase:()=>t=>s(t)?!1:String(t)===String(t).toUpperCase(),url:()=>t=>s(t)?!1:/^(https?):\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}.*$/.test(String(t))};class ce{constructor({fallbackLocale:e,locale:r,plugins:i}={}){o(this,"locale","en");o(this,"fallbackLocale","en");o(this,"locales",{});o(this,"rules",{});this.registerLocales(C),this.registerRules(fe),e&&this.setFallbackLocale(e),r&&this.setLocale(r),i&&i.forEach(a=>this.registerPlugin(a))}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 b({name:e,locale:this.locale,fallbackLocale:this.fallbackLocale,locales:this.locales,rules:this.rules})}registerLocales(e){return this.locales=Object.keys(e).reduce((r,i)=>(r[i]={...this.locales[i],...e[i]},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)}}u.FieldValidator=b,u.FormValidator=ce,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(u,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(u=typeof globalThis<"u"?globalThis:u||self,l(u.Fortress={}))})(this,function(u){"use strict";var ge=Object.defineProperty;var ye=(u,l,n)=>l in u?ge(u,l,{enumerable:!0,configurable:!0,writable:!0,value:n}):u[l]=n;var o=(u,l,n)=>(ye(u,typeof l!="symbol"?l+"":l,n),n);const l=t=>{const e=",、;:!?。()《》「」『』【】〔〕",r="\\x20-\\x7E",s=new RegExp(`\\s*([${e}])`,"gu"),a=new RegExp(`([${e}])\\s*([${r}])`,"gu"),h=new RegExp(`([^${r}${e}])([${r}])`,"gu"),me=new RegExp(`([${r}])([^${r}${e}])`,"gu");return t.replace(s,"$1").replace(a,"$1$2").replace(h,"$1 $2").replace(me,"$1 $2").replace(/ +/g," ")},n=(t,e=0)=>new Intl.NumberFormat(void 0,{minimumFractionDigits:e,maximumFractionDigits:e}).format(t),z=t=>Object.prototype.toString.call(t).toLowerCase().slice(8,-1),i=t=>t==null||t===""||Array.isArray(t)&&t.length<1;class b{constructor({name:e,locale:r,fallbackLocale:s,locales:a,rules:h}){o(this,"name");o(this,"locale");o(this,"fallbackLocale");o(this,"locales");o(this,"rules");o(this,"ruleFunctions",[]);o(this,"conditions",{});o(this,"shouldSkip",!1);this.name=e,this.locale=r,this.fallbackLocale=s,this.locales=a,this.rules=h}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 s=>{if(i(s)&&!this.mandatoryRules.includes(e))return!0;const a=this.getRule(e)(r)(s);return typeof a=="string"?a:a===!0?!0:this.buildRuleFunctionMessage(e,r,s)}}buildRuleFunctionMessage(e,r,s){const a=this.getMessage(e)(this.formattedName,r);if(typeof a=="object"){const h=z(s);if(!(h in a))throw new Error(`The message for the "${e}" rule of the "${h}" type is missing.`);return l(a[h])}return l(a)}pushRuleFunction(e,r){if(e in this.conditions&&!this.conditions[e])return this;const s=this.buildRuleFunction(e,r);return this.ruleFunctions.push(s),this}getRuleFunctions(){return this.ruleFunctions}collect(){return this.shouldSkip?[]:this.getRuleFunctions()}validate(e){if(this.shouldSkip)return!0;for(const r of this.ruleFunctions){const s=r(e);if(typeof s=="string")return s}return!0}apply(e,r={}){return this.pushRuleFunction(e,r)}accepted(){return this.apply(this.accepted.name)}after(e,r,s,a=!0){return this.apply(this.after.name,{date:e,format:r,displayFormat:s,strict:a})}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)}ascii(){return this.apply(this.ascii.name)}before(e,r,s,a=!0){return this.apply(this.before.name,{date:e,format:r,displayFormat:s,strict:a})}between(e,r){return this.apply(this.between.name,{min:e,max:r})}betweenLength(e,r){return this.apply(this.betweenLength.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)}fileBetweenSize(e,r){return this.apply(this.fileBetweenSize.name,{min:e,max:r})}fileMaxSize(e){return this.apply(this.fileMaxSize.name,{size:e})}fileMinSize(e){return this.apply(this.fileMinSize.name,{size:e})}fileSize(e){return this.apply(this.fileSize.name,{size:e})}http(){return this.apply(this.http.name)}https(){return this.apply(this.https.name)}integer(){return this.apply(this.integer.name)}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})}length(e){return this.apply(this.length.name,{length:e})}lowercase(){return this.apply(this.lowercase.name)}max(e){return this.apply(this.max.name,{max:e})}maxLength(e){return this.apply(this.maxLength.name,{length:e})}min(e){return this.apply(this.min.name,{min:e})}minLength(e){return this.apply(this.minLength.name,{length:e})}notContainsAll(e){return this.apply(this.notContainsAll.name,{values:e})}notContainsAny(e){return this.apply(this.notContainsAny.name,{values:e})}notEquals(e){return this.apply(this.notEquals.name,{value:e})}notOneOf(e){return this.apply(this.notOneOf.name,{values:e})}number(){return this.apply(this.number.name)}numeric(){return this.apply(this.numeric.name)}oneOf(e){return this.apply(this.oneOf.name,{values:e})}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})}string(){return this.apply(this.string.name)}stringBetweenLength(e,r){return this.apply(this.stringBetweenLength.name,{min:e,max:r})}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})}stringMaxLength(e){return this.apply(this.stringMaxLength.name,{length:e})}stringMinLength(e){return this.apply(this.stringMinLength.name,{length:e})}stringNotContainsAll(e){return this.apply(this.stringNotContainsAll.name,{values:e})}stringNotContainsAny(e){return this.apply(this.stringNotContainsAny.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 C={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.`,ascii:t=>`The ${t} field must only contain ASCII characters and symbols.`,between:(t,e)=>{const{min:r,max:s}=e;return{number:`The ${t} field must be between ${n(r)} and ${n(s)}.`,array:`The ${t} field must contain items where each item is between ${n(r)} and ${n(s)}.`}},betweenLength:(t,e)=>{const{min:r,max:s}=e;return`The ${t} field must be between ${n(r)} and ${n(s)} items.`},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(s=>`"${s}"`).join(", ")}.`},containsAny:(t,e)=>{const{values:r}=e;return`The ${t} field must contain at least one of the following values: ${r.map(s=>`"${s}"`).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 ${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.`,fileBetweenSize:(t,e)=>{const{min:r,max:s}=e;return{file:`The ${t} field must be between ${n(r)} and ${n(s)} kilobytes.`,array:`The ${t} field must contain items where each item is between ${n(r)} and ${n(s)} kilobytes.`}},fileMaxSize:(t,e)=>{const{size:r}=e;return{file:`The ${t} field must not be greater than ${n(r)} kilobytes.`,array:`The ${t} field must contain items where each item is not greater than ${n(r)} kilobytes.`}},fileMinSize:(t,e)=>{const{size:r}=e;return{file:`The ${t} field must be at least ${n(r)} kilobytes.`,array:`The ${t} field must contain items where each item is at least ${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 either "http://" or "https://".`,https:t=>`The ${t} field must start with "http://".`,integer:t=>`The ${t} field must be an integer.`,json:t=>`The ${t} field must be a valid JSON string.`,length:(t,e)=>{const{length:r}=e;return`The ${t} field must be ${n(r)} items.`},lowercase:t=>`The ${t} field must be lowercase.`,max:(t,e)=>{const{max:r}=e;return{number:`The ${t} field must not be greater than ${n(r)}.`,array:`The ${t} field must contain items where each item is not greater than ${n(r)}.`}},maxLength:(t,e)=>{const{length:r}=e;return`The ${t} field must not be greater than ${n(r)} items.`},min:(t,e)=>{const{min:r}=e;return{number:`The ${t} field must be at least ${n(r)}.`,array:`The ${t} field must contain items where each item is at least ${n(r)}.`}},minLength:(t,e)=>{const{length:r}=e;return`The ${t} field must be at least ${n(r)} items.`},notContainsAll:(t,e)=>{const{values:r}=e;return`The ${t} field must not contain all of the following values together: ${r.map(s=>`"${s}"`).join(", ")}.`},notContainsAny:(t,e)=>{const{values:r}=e;return`The ${t} field must not contain any of the following values: ${r.map(s=>`"${s}"`).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(s=>`"${s}"`).join(", ")}.`},number:t=>`The ${t} field must be a number.`,numeric:t=>`The ${t} field must be a number.`,oneOf:(t,e)=>{const{values:r}=e;return`The ${t} field must be one of the following values: ${r.map(s=>`"${s}"`).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 ${r}.`},string:t=>`The ${t} field must be a string.`,stringBetweenLength:(t,e)=>{const{min:r,max:s}=e;return{string:`The ${t} field must be between ${n(r)} and ${n(s)} characters.`,array:`The ${t} field must contain items where each item is between ${n(r)} and ${n(s)} characters.`}},stringContainsAll:(t,e)=>{const{values:r}=e;return`The ${t} field must contain all of the following text: ${r.map(s=>`"${s}"`).join(", ")}.`},stringContainsAny:(t,e)=>{const{values:r}=e;return`The ${t} field must contain at least one of the following text: ${r.map(s=>`"${s}"`).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.`}},stringMaxLength:(t,e)=>{const{length:r}=e;return{string:`The ${t} field must not be greater than ${n(r)} characters.`,array:`The ${t} field must contain items where each item is not greater than ${n(r)} characters.`}},stringMinLength:(t,e)=>{const{length:r}=e;return{string:`The ${t} field must be at least ${n(r)} characters.`,array:`The ${t} field must contain items where each item is at least ${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(s=>`"${s}"`).join(", ")}.`},stringNotContainsAny:(t,e)=>{const{values:r}=e;return`The ${t} field must not contain any of the following text: ${r.map(s=>`"${s}"`).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:()=>"此欄位必須是一個陣列",ascii:()=>"此欄位只能包含ASCII字元和符號",between:(t,e)=>{const{min:r,max:s}=e;return{number:`此欄位必須介於${n(r)}到${n(s)}`,array:`此欄位中的每個項目都必須介於${n(r)}到${n(s)}`}},betweenLength:(t,e)=>{const{min:r,max:s}=e;return`此欄位必須介於${n(r)}到${n(s)}個項目之間`},boolean:()=>"此欄位必須是一個布林值",containsAll:(t,e)=>{const{values:r}=e;return`此欄位必須包含以下所有項目:${r.join(", ")}`},containsAny:(t,e)=>{const{values:r}=e;return`此欄位必須包含以下其中一個項目:${r.join(", ")}`},declined:()=>"此欄位必須被拒絕",different:(t,e)=>{const{field:r}=e;return`此欄位必須和${r}欄位不同`},distinct:()=>"此欄位不能包含重複的值",domain:()=>"此欄位必須是有效的網域",email:()=>"此欄位必須是有效的電子郵件地址",endsWith:(t,e)=>{const{value:r}=e;return`此欄位必須以${r}結尾`},equals:(t,e)=>{const{value:r}=e;return`此欄位必須是${r}`},file:()=>"此欄位必須是檔案",fileBetweenSize:(t,e)=>{const{min:r,max:s}=e;return{file:`此欄位必須介於${n(r)}到${n(s)} KB之間`,array:`此欄位中的每個項目都必須介於${n(r)}到${n(s)} KB之間`}},fileMaxSize:(t,e)=>{const{size:r}=e;return{file:`此欄位不能大於${n(r)} KB`,array:`此欄位中的每個項目都不能大於${n(r)} KB`}},fileMinSize:(t,e)=>{const{size:r}=e;return{file:`此欄位不能小於${n(r)} KB`,array:`此欄位中的每個項目都不能小於${n(r)} KB`}},fileSize:(t,e)=>{const{size:r}=e;return{file:`此欄位必須是${n(r)} KB`,array:`此欄位中的每個項目都必須是${n(r)} KB`}},http:()=>"此欄位必須以 http:// 或 https:// 開頭",https:()=>"此欄位必須以 https:// 開頭",integer:()=>"此欄位必須是整數",json:()=>"此欄位必須是有效的 JSON 字串",length:(t,e)=>{const{length:r}=e;return`此欄位必須包含${n(r)}個項目`},lowercase:()=>"此欄位必須是小寫",max:(t,e)=>{const{max:r}=e;return{number:`此欄位不能大於${n(r)}`,array:`此欄位中的每個項目都不能大於${n(r)}`}},maxLength:(t,e)=>{const{length:r}=e;return`此欄位不能大於${n(r)}個項目`},min:(t,e)=>{const{min:r}=e;return{number:`此欄位不能小於${n(r)}`,array:`此欄位中的每個項目都不能小於${n(r)}`}},minLength:(t,e)=>{const{length:r}=e;return`此欄位不能小於${n(r)}個項目`},notContainsAll:(t,e)=>{const{values:r}=e;return`此欄位不能同時包含以下所有值:${r.join(", ")}`},notContainsAny:(t,e)=>{const{values:r}=e;return`此欄位不能包含以下任何值:${r.join(", ")}`},notEquals:(t,e)=>{const{value:r}=e;return`此欄位不能是${r}`},notOneOf:(t,e)=>{const{values:r}=e;return`此欄位不能是以下任何值:${r.join(", ")}`},number:()=>"此欄位必須是數字",numeric:()=>"此欄位必須是數字",oneOf:(t,e)=>{const{values:r}=e;return`此欄位必須是以下任何值:${r.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`此欄位必須以${r}開頭`},string:()=>"此欄位必須是字串",stringBetweenLength:(t,e)=>{const{min:r,max:s}=e;return{string:`此欄位必須介於${n(r)}到${n(s)}個字元之間`,array:`此欄位中的每個項目都必須介於${n(r)}到${n(s)}個字元之間`}},stringContainsAll:(t,e)=>{const{values:r}=e;return`此欄位必須包含以下所有文字:${r.join(", ")}`},stringContainsAny:(t,e)=>{const{values:r}=e;return`此欄位必須包含以下其中一個文字:${r.join(", ")}`},stringLength:(t,e)=>{const{length:r}=e;return{string:`此欄位必須是${n(r)}個字元`,array:`此欄位中的每個項目都必須是${n(r)}個字元`}},stringMaxLength:(t,e)=>{const{length:r}=e;return{string:`此欄位不能大於${n(r)}個字元`,array:`此欄位中的每個項目都不能大於${n(r)}個字元`}},stringMinLength:(t,e)=>{const{length:r}=e;return{string:`此欄位不能小於${n(r)}個字元`,array:`此欄位中的每個項目都不能小於${n(r)}個字元`}},stringNotContainsAll:(t,e)=>{const{values:r}=e;return`此欄位不能同時包含以下所有文字:${r.join(", ")}`},stringNotContainsAny:(t,e)=>{const{values:r}=e;return`此欄位不能包含以下任何文字:${r.join(", ")}`},unique:()=>"此欄位已經存在",uppercase:()=>"此欄位必須是大寫",url:()=>"此欄位必須是有效的網址"}},_=()=>t=>i(t)?!1:["y","yes","on","1","true"].includes(String(t).toLowerCase()),j=()=>t=>i(t)?!1:/^[a-zA-Z]+$/.test(String(t)),q=()=>t=>i(t)?!1:/^[a-zA-Z0-9-_]+$/.test(String(t)),M=()=>t=>i(t)?!1:/^[a-zA-Z0-9-_.]+$/.test(String(t)),F=()=>t=>i(t)?!1:/^[a-zA-Z0-9]+$/.test(String(t)),k=()=>t=>Array.isArray(t),O=()=>t=>i(t)?!1:/^[\x20-\x7E]+$/.test(String(t)),c=({max:t})=>e=>i(e)?!1:typeof e=="number"?e<=t:Array.isArray(e)?e.every(r=>c({max:t})(r)):!1,m=({min:t})=>e=>i(e)?!1:typeof e=="number"?e>=t:Array.isArray(e)?e.every(r=>m({min:t})(r)):!1,E=({min:t,max:e})=>r=>i(r)?!1:m({min:t})(r)&&c({max:e})(r),A=({length:t})=>e=>i(e)?!1:Array.isArray(e)?e.length<=t:!1,w=({length:t})=>e=>i(e)?!1:Array.isArray(e)?e.length>=t:!1,N=({min:t,max:e})=>r=>i(r)?!1:w({length:t})(r)&&A({length:e})(r),B=()=>t=>i(t)?!1:typeof t=="boolean",T=({values:t})=>e=>i(e)?!1:Array.isArray(e)?t.every(r=>e.includes(r)):!1,R=({values:t})=>e=>i(e)?!1:Array.isArray(e)?t.some(r=>e.includes(r)):!1,D=()=>t=>i(t)?!1:["n","no","off","0","false"].includes(String(t).toLowerCase()),W=({value:t})=>e=>i(e)?!1:e!==t,Z=()=>t=>i(t)?!1:Array.isArray(t)?new Set(t).size===t.length:!0,K=()=>t=>i(t)?!1:/^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(String(t)),I=()=>t=>i(t)?!1:/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(String(t)),V=({value:t})=>e=>i(e)?!1:String(e).endsWith(t),J=({value:t})=>e=>e===t,P=()=>t=>t instanceof File,g=({size:t})=>e=>i(e)?!1:e instanceof File?e.size<=t*1024:Array.isArray(e)?e.every(r=>g({size:t})(r)):!1,y=({size:t})=>e=>i(e)?!1:e instanceof File?e.size>=t*1024:Array.isArray(e)?e.every(r=>y({size:t})(r)):!1,U=({min:t,max:e})=>r=>i(r)?!1:y({size:t})(r)&&g({size:e})(r),L=({size:t})=>e=>{if(i(e))return!1;if(e instanceof File){const r=t*1024,s=(t+1)*1024;return e.size>=r&&e.size<s}return Array.isArray(e)?e.every(r=>L({size:t})(r)):!1},f=({value:t})=>e=>i(e)?!1:String(e).startsWith(t),G=()=>t=>i(t)?!1:f({value:"http://"})(t)||f({value:"https://"})(t),H=()=>t=>i(t)?!1:f({value:"https://"})(t),$=()=>t=>i(t)?!1:typeof t=="number",Q=()=>t=>i(t)?!1:$()(t)&&Number.isInteger(t),X=()=>t=>{if(i(t))return!1;try{return JSON.parse(String(t)),!0}catch{return!1}},Y=({length:t})=>e=>i(e)?!1:Array.isArray(e)?e.length===t:!1,ee=()=>t=>i(t)?!1:String(t)===String(t).toLowerCase(),te=({values:t})=>e=>i(e)?!1:Array.isArray(e)?!t.every(r=>e.includes(r)):!1,re=({values:t})=>e=>i(e)?!1:Array.isArray(e)?!t.some(r=>e.includes(r)):!1,ne=({value:t})=>e=>e!==t,se=({values:t})=>e=>i(e)?!1:!t.includes(e),v=()=>t=>typeof t=="string",ie=()=>t=>i(t)?!1:v()(t)?/^-?\d+(\.\d+)?$/.test(String(t)):$()(t),ae=({values:t})=>e=>i(e)?!1:t.includes(e),le=({expression:t})=>e=>{if(i(e))return!1;if(!(t instanceof RegExp))throw new TypeError("The expression provided is not a valid RegExp.");return t.test(String(e))},ue=()=>t=>!i(t),oe=({value:t})=>e=>i(e)?!1:Array.isArray(e)?e.every(r=>r===t):e===t,S=({size:t})=>e=>i(e)?!1:typeof e=="number"?e===t:Array.isArray(e)?e.every(r=>S({size:t})(r)):!1,d=({length:t})=>e=>i(e)?!1:typeof e=="string"?e.length<=t:Array.isArray(e)?e.every(r=>d({length:t})(r)):!1,p=({length:t})=>e=>i(e)?!1:typeof e=="string"?e.length>=t:Array.isArray(e)?e.every(r=>p({length:t})(r)):!1,he=({min:t,max:e})=>r=>i(r)?!1:p({length:t})(r)&&d({length:e})(r),x=({length:t})=>e=>i(e)?!1:typeof e=="string"?e.length===t:Array.isArray(e)?e.every(r=>x({length:t})(r)):!1,fe={accepted:_,alpha:j,alphaDash:q,alphaDashDot:M,alphaNum:F,array:k,ascii:O,between:E,betweenLength:N,boolean:B,containsAll:T,containsAny:R,declined:D,different:W,distinct:Z,domain:K,email:I,endsWith:V,equals:J,file:P,fileBetweenSize:U,fileMaxSize:g,fileMinSize:y,fileSize:L,http:G,https:H,integer:Q,json:X,length:Y,lowercase:ee,max:c,maxLength:A,min:m,minLength:w,notContainsAll:te,notContainsAny:re,notEquals:ne,notOneOf:se,number:$,numeric:ie,oneOf:ae,regex:le,required:ue,same:oe,size:S,startsWith:f,string:v,stringBetweenLength:he,stringContainsAll:T,stringContainsAny:R,stringLength:x,stringMaxLength:d,stringMinLength:p,stringNotContainsAll:({values:t})=>e=>i(e)?!1:typeof e=="string"?!t.every(r=>e.includes(r)):!1,stringNotContainsAny:({values:t})=>e=>i(e)?!1:typeof e=="string"?!t.some(r=>e.includes(r)):!1,unique:({values:t,ignored:e=[]})=>r=>i(r)?!1:(Array.isArray(e)?e:[e]).some(s=>s===r)?!0:!t.some(s=>s===r),uppercase:()=>t=>i(t)?!1:String(t)===String(t).toUpperCase(),url:()=>t=>i(t)?!1:/^(https?):\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}.*$/.test(String(t))};class ce{constructor({fallbackLocale:e,locale:r,plugins:s}={}){o(this,"locale","en");o(this,"fallbackLocale","en");o(this,"locales",{});o(this,"rules",{});this.registerLocales(C),this.registerRules(fe),e&&this.setFallbackLocale(e),r&&this.setLocale(r),s&&s.forEach(a=>this.registerPlugin(a))}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 b({name:e,locale:this.locale,fallbackLocale:this.fallbackLocale,locales:this.locales,rules:this.rules})}registerLocales(e){return this.locales=Object.keys(e).reduce((r,s)=>(r[s]={...this.locales[s],...e[s]},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)}}u.FieldValidator=b,u.FormValidator=ce,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -2,5 +2,5 @@ import { Rule, RuleArguments } from '@kklab/fortress-validator-types';
|
|
|
2
2
|
export interface NotContainsAllRuleArguments extends RuleArguments {
|
|
3
3
|
values: unknown[];
|
|
4
4
|
}
|
|
5
|
-
declare const
|
|
6
|
-
export default
|
|
5
|
+
declare const notContainsAllRule: Rule<NotContainsAllRuleArguments>;
|
|
6
|
+
export default notContainsAllRule;
|
|
@@ -2,5 +2,5 @@ import { Rule, RuleArguments } from '@kklab/fortress-validator-types';
|
|
|
2
2
|
export interface NotContainsAnyRuleArguments extends RuleArguments {
|
|
3
3
|
values: unknown[];
|
|
4
4
|
}
|
|
5
|
-
declare const
|
|
6
|
-
export default
|
|
5
|
+
declare const notContainsAnyRule: Rule<NotContainsAnyRuleArguments>;
|
|
6
|
+
export default notContainsAnyRule;
|
|
@@ -2,5 +2,5 @@ import { Rule, RuleArguments } from '@kklab/fortress-validator-types';
|
|
|
2
2
|
export interface StringNotContainsAllRuleArguments extends RuleArguments {
|
|
3
3
|
values: string[];
|
|
4
4
|
}
|
|
5
|
-
declare const
|
|
6
|
-
export default
|
|
5
|
+
declare const stringNotContainsAllRule: Rule<StringNotContainsAllRuleArguments>;
|
|
6
|
+
export default stringNotContainsAllRule;
|
|
@@ -2,5 +2,5 @@ import { Rule, RuleArguments } from '@kklab/fortress-validator-types';
|
|
|
2
2
|
export interface StringNotContainsAnyRuleArguments extends RuleArguments {
|
|
3
3
|
values: string[];
|
|
4
4
|
}
|
|
5
|
-
declare const
|
|
6
|
-
export default
|
|
5
|
+
declare const stringNotContainsAnyRule: Rule<StringNotContainsAnyRuleArguments>;
|
|
6
|
+
export default stringNotContainsAnyRule;
|
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.11",
|
|
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.2"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@kklab/fortress-validator-plugin-date": "^1.0.4",
|