@scbt-ecom/ui 0.50.1 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-DXLhMM4P.js → index-714cNgOF.js} +2 -2
- package/dist/{index-DXLhMM4P.js.map → index-714cNgOF.js.map} +1 -1
- package/dist/shared/validation/utils/zodUtils.d.ts +27 -1
- package/dist/ui.js +2 -2
- package/dist/validation.js +244 -213
- package/dist/validation.js.map +1 -1
- package/dist/widget.js +1 -1
- package/package.json +1 -1
package/dist/validation.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { z as
|
|
2
|
-
import { T as
|
|
3
|
-
const
|
|
1
|
+
import { z as s, p as I, i as N, f as T, D as L, s as D } from "./utils-Od0KoTas.js";
|
|
2
|
+
import { T as c } from "./typeGuards-BigW-JS1.js";
|
|
3
|
+
const R = /^[\u0400-\u04FF\u00CB\u00EB -]+$/, A = /^(?:[^-]+(?:-[^-]+){0,4}|[^-]+)$/, y = /^[a-zA-Zа-яА-ЯёЁ]+(?:\s*-\s*[a-zA-Zа-яА-ЯёЁ]+){0,4}(?:\s+[a-zA-Zа-яА-ЯёЁ]+(?:\s*-\s*[a-zA-Zа-яА-ЯёЁ]+){0,4})?$/i, E = {
|
|
4
4
|
REQUIRED: "Поле обязательно к заполнению",
|
|
5
5
|
MIN_LENGTH: "Минимальная длина символов должна быть не менее",
|
|
6
6
|
MAX_LENGTH: "Максимальная длина символов должна быть не более",
|
|
@@ -13,61 +13,61 @@ const Z = /^[\u0400-\u04FF\u00CB\u00EB -]+$/, A = /^(?:[^-]+(?:-[^-]+){0,4}|[^-]
|
|
|
13
13
|
FUTURE_DATE_NOT_ALLOWED: "Нельзя выбрать дату позже текущей",
|
|
14
14
|
INVALID_URL: "Некорректная ссылка"
|
|
15
15
|
}, P = (e) => {
|
|
16
|
-
const t = e.trim().replace(/\s+/g, " ").split(" "), [
|
|
16
|
+
const t = e.trim().replace(/\s+/g, " ").split(" "), [o, d, ...n] = t, i = n == null ? void 0 : n.join(" ");
|
|
17
17
|
return {
|
|
18
|
-
surname:
|
|
19
|
-
name:
|
|
18
|
+
surname: o,
|
|
19
|
+
name: d,
|
|
20
20
|
patronymic: i
|
|
21
21
|
};
|
|
22
|
-
},
|
|
22
|
+
}, se = s.string({ invalid_type_error: "Обязательно к заполнению", required_error: "Обязательно к заполнению" }).superRefine((e, t) => {
|
|
23
23
|
e === "" && t.addIssue({
|
|
24
|
-
code:
|
|
24
|
+
code: s.ZodIssueCode.custom,
|
|
25
25
|
message: "Введите имя и фамилию"
|
|
26
|
-
}),
|
|
27
|
-
code:
|
|
26
|
+
}), R.test(e) || t.addIssue({
|
|
27
|
+
code: s.ZodIssueCode.custom,
|
|
28
28
|
message: "Должна быть только кириллица"
|
|
29
29
|
});
|
|
30
|
-
const { surname:
|
|
31
|
-
(!
|
|
32
|
-
code:
|
|
30
|
+
const { surname: o, name: d, patronymic: n } = P(e);
|
|
31
|
+
(!o || !d) && t.addIssue({
|
|
32
|
+
code: s.ZodIssueCode.custom,
|
|
33
33
|
message: "Введите имя и фамилию"
|
|
34
|
-
}), A.test(s) || t.addIssue({
|
|
35
|
-
code: o.ZodIssueCode.custom,
|
|
36
|
-
message: "Неверно введено имя"
|
|
37
34
|
}), A.test(d) || t.addIssue({
|
|
38
|
-
code:
|
|
35
|
+
code: s.ZodIssueCode.custom,
|
|
36
|
+
message: "Неверно введено имя"
|
|
37
|
+
}), A.test(o) || t.addIssue({
|
|
38
|
+
code: s.ZodIssueCode.custom,
|
|
39
39
|
message: "Неверно введена фамилия"
|
|
40
|
-
}), n && (
|
|
41
|
-
code:
|
|
40
|
+
}), n && (y.test(n) || t.addIssue({
|
|
41
|
+
code: s.ZodIssueCode.custom,
|
|
42
42
|
message: "Неверно введено отчество"
|
|
43
43
|
}));
|
|
44
|
-
}),
|
|
45
|
-
const [
|
|
44
|
+
}), ae = s.string().length(10, { message: E.INVALID_DATE }).superRefine((e, t) => {
|
|
45
|
+
const [o, d, n] = (e == null ? void 0 : e.split(".")) ?? "", i = I(`${o}/${d}/${n}`, "dd/MM/yyyy", /* @__PURE__ */ new Date());
|
|
46
46
|
+n <= 1950 && t.addIssue({
|
|
47
|
-
code:
|
|
48
|
-
message:
|
|
47
|
+
code: s.ZodIssueCode.custom,
|
|
48
|
+
message: E.INVALID_DATE
|
|
49
49
|
}), N(i) || t.addIssue({
|
|
50
|
-
code:
|
|
51
|
-
message:
|
|
50
|
+
code: s.ZodIssueCode.custom,
|
|
51
|
+
message: E.INVALID_DATE
|
|
52
52
|
}), (/* @__PURE__ */ new Date()).getTime() < new Date(i).getTime() && t.addIssue({
|
|
53
|
-
code:
|
|
54
|
-
message:
|
|
53
|
+
code: s.ZodIssueCode.custom,
|
|
54
|
+
message: E.FUTURE_DATE_NOT_ALLOWED
|
|
55
55
|
});
|
|
56
|
-
}),
|
|
57
|
-
const
|
|
58
|
-
["3", "4", "5", "6", "9"].includes(
|
|
59
|
-
code:
|
|
56
|
+
}), re = s.string().superRefine((e, t) => {
|
|
57
|
+
const o = e.charAt(0);
|
|
58
|
+
["3", "4", "5", "6", "9"].includes(o) || t.addIssue({
|
|
59
|
+
code: s.ZodIssueCode.custom,
|
|
60
60
|
message: "Код города/оператора должен начинаться с цифры 3, 4, 5, 6 или 9"
|
|
61
61
|
}), e.length !== 10 && t.addIssue({
|
|
62
|
-
code:
|
|
62
|
+
code: s.ZodIssueCode.custom,
|
|
63
63
|
message: "Введите номер телефона полностью"
|
|
64
64
|
});
|
|
65
|
-
}).transform((e) => `7${e}`), ue =
|
|
65
|
+
}).transform((e) => `7${e}`), ue = s.coerce.number().min(1e3, `${E.FIX_LENGTH} 4`).max(9999, `${E.FIX_LENGTH} 4`).nullable().superRefine((e, t) => {
|
|
66
66
|
e === null && t.addIssue({
|
|
67
|
-
code:
|
|
67
|
+
code: s.ZodIssueCode.invalid_type,
|
|
68
68
|
expected: "number",
|
|
69
69
|
received: "null",
|
|
70
|
-
message: `${
|
|
70
|
+
message: `${E.FIX_LENGTH} 4`
|
|
71
71
|
});
|
|
72
72
|
}).default(null), r = {
|
|
73
73
|
NON_EMPTY: () => "Поле не может быть пустым",
|
|
@@ -88,21 +88,21 @@ const Z = /^[\u0400-\u04FF\u00CB\u00EB -]+$/, A = /^(?:[^-]+(?:-[^-]+){0,4}|[^-]
|
|
|
88
88
|
DATE_NON_EMPTY: () => "Укажите дату",
|
|
89
89
|
VALUE_OUT_OF_RANGE: (e) => `Выберите один из вариантов ${e.join(", ")}`,
|
|
90
90
|
DATE_MIN: (e) => {
|
|
91
|
-
const t =
|
|
91
|
+
const t = c.isString(e) ? new Date(e) : e;
|
|
92
92
|
return `Выбранная дата должна быть не раньше ${T(t)}`;
|
|
93
93
|
},
|
|
94
94
|
DATE_MAX: (e) => {
|
|
95
|
-
const t =
|
|
95
|
+
const t = c.isString(e) ? new Date(e) : e;
|
|
96
96
|
return `Выбранная дата должна быть не позже ${T(t)}`;
|
|
97
97
|
},
|
|
98
98
|
INVALID_URL: () => "Ссылка введена некорректно. Пример: https://example.com, example.com"
|
|
99
|
-
},
|
|
100
|
-
const { iso: t = !0, pattern:
|
|
101
|
-
return
|
|
102
|
-
const
|
|
103
|
-
if (u.replace(/[._-]/g, "").length <
|
|
104
|
-
code:
|
|
105
|
-
minimum:
|
|
99
|
+
}, h = (e) => {
|
|
100
|
+
const { iso: t = !0, pattern: o = L, min: d, max: n, message: i } = e || {};
|
|
101
|
+
return s.string().min(8, (i == null ? void 0 : i.min) || r.DATE_NON_EMPTY()).superRefine((u, a) => {
|
|
102
|
+
const l = o.replace(/\W/g, "").length;
|
|
103
|
+
if (u.replace(/[._-]/g, "").length < l && a.addIssue({
|
|
104
|
+
code: s.ZodIssueCode.too_small,
|
|
105
|
+
minimum: l,
|
|
106
106
|
type: "date",
|
|
107
107
|
inclusive: !0,
|
|
108
108
|
message: (i == null ? void 0 : i.min) || r.DATE_NON_EMPTY()
|
|
@@ -111,40 +111,40 @@ const Z = /^[\u0400-\u04FF\u00CB\u00EB -]+$/, A = /^(?:[^-]+(?:-[^-]+){0,4}|[^-]
|
|
|
111
111
|
try {
|
|
112
112
|
_ = new Date(u);
|
|
113
113
|
} catch {
|
|
114
|
-
|
|
115
|
-
code:
|
|
114
|
+
a.addIssue({
|
|
115
|
+
code: s.ZodIssueCode.invalid_date,
|
|
116
116
|
message: (i == null ? void 0 : i.invalidDate) || r.DATE_INVALID_FORMAT()
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
|
|
120
|
-
code:
|
|
121
|
-
message: (i == null ? void 0 : i.min) || r.DATE_MIN(
|
|
122
|
-
}), n && _.getTime() > (
|
|
123
|
-
code:
|
|
119
|
+
d && _.getTime() < (c.isString(d) ? new Date(d).getTime() : d.getTime()) && a.addIssue({
|
|
120
|
+
code: s.ZodIssueCode.invalid_date,
|
|
121
|
+
message: (i == null ? void 0 : i.min) || r.DATE_MIN(d)
|
|
122
|
+
}), n && _.getTime() > (c.isString(n) ? new Date(n).getTime() : n.getTime()) && a.addIssue({
|
|
123
|
+
code: s.ZodIssueCode.invalid_date,
|
|
124
124
|
message: (i == null ? void 0 : i.max) || r.DATE_MAX(n)
|
|
125
125
|
});
|
|
126
126
|
} else {
|
|
127
|
-
const _ =
|
|
128
|
-
N(_) ||
|
|
129
|
-
code:
|
|
127
|
+
const _ = I(u, o, /* @__PURE__ */ new Date());
|
|
128
|
+
N(_) || a.addIssue({
|
|
129
|
+
code: s.ZodIssueCode.invalid_date,
|
|
130
130
|
message: (i == null ? void 0 : i.invalidDate) || r.DATE_INVALID_FORMAT()
|
|
131
|
-
}),
|
|
132
|
-
code:
|
|
133
|
-
message: (i == null ? void 0 : i.min) || r.DATE_MIN(
|
|
134
|
-
}), n && _.getTime() > (
|
|
135
|
-
code:
|
|
131
|
+
}), d && _.getTime() < (c.isString(d) ? new Date(d).getTime() : d.getTime()) && a.addIssue({
|
|
132
|
+
code: s.ZodIssueCode.invalid_date,
|
|
133
|
+
message: (i == null ? void 0 : i.min) || r.DATE_MIN(d)
|
|
134
|
+
}), n && _.getTime() > (c.isString(n) ? new Date(n).getTime() : n.getTime()) && a.addIssue({
|
|
135
|
+
code: s.ZodIssueCode.invalid_date,
|
|
136
136
|
message: (i == null ? void 0 : i.max) || r.DATE_MAX(n)
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
}).default("");
|
|
140
|
-
},
|
|
141
|
-
const { iso: t = !0, pattern:
|
|
142
|
-
return
|
|
143
|
-
if (
|
|
144
|
-
const
|
|
145
|
-
if (u.replace(/[._-]/g, "").length <
|
|
146
|
-
code:
|
|
147
|
-
minimum:
|
|
140
|
+
}, V = (e) => {
|
|
141
|
+
const { iso: t = !0, pattern: o = L, min: d, max: n, message: i } = e || {};
|
|
142
|
+
return s.string().transform((u) => u || void 0).superRefine((u, a) => {
|
|
143
|
+
if (c.isString(u) && u.length) {
|
|
144
|
+
const l = o.replace(/\W/g, "").length;
|
|
145
|
+
if (u.replace(/[._-]/g, "").length < l && a.addIssue({
|
|
146
|
+
code: s.ZodIssueCode.too_small,
|
|
147
|
+
minimum: l,
|
|
148
148
|
type: "date",
|
|
149
149
|
inclusive: !0,
|
|
150
150
|
message: (i == null ? void 0 : i.min) || r.DATE_NON_EMPTY()
|
|
@@ -153,152 +153,152 @@ const Z = /^[\u0400-\u04FF\u00CB\u00EB -]+$/, A = /^(?:[^-]+(?:-[^-]+){0,4}|[^-]
|
|
|
153
153
|
try {
|
|
154
154
|
_ = new Date(u);
|
|
155
155
|
} catch {
|
|
156
|
-
|
|
157
|
-
code:
|
|
156
|
+
a.addIssue({
|
|
157
|
+
code: s.ZodIssueCode.invalid_date,
|
|
158
158
|
message: (i == null ? void 0 : i.invalidDate) || r.DATE_INVALID_FORMAT()
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
-
|
|
162
|
-
code:
|
|
163
|
-
message: (i == null ? void 0 : i.min) || r.DATE_MIN(
|
|
164
|
-
}), n && _.getTime() > (
|
|
165
|
-
code:
|
|
161
|
+
d && _.getTime() < (c.isString(d) ? new Date(d).getTime() : d.getTime()) && a.addIssue({
|
|
162
|
+
code: s.ZodIssueCode.invalid_date,
|
|
163
|
+
message: (i == null ? void 0 : i.min) || r.DATE_MIN(d)
|
|
164
|
+
}), n && _.getTime() > (c.isString(n) ? new Date(n).getTime() : n.getTime()) && a.addIssue({
|
|
165
|
+
code: s.ZodIssueCode.invalid_date,
|
|
166
166
|
message: (i == null ? void 0 : i.max) || r.DATE_MAX(n)
|
|
167
167
|
});
|
|
168
168
|
} else {
|
|
169
|
-
const _ =
|
|
170
|
-
N(_) ||
|
|
171
|
-
code:
|
|
169
|
+
const _ = I(u, o, /* @__PURE__ */ new Date());
|
|
170
|
+
N(_) || a.addIssue({
|
|
171
|
+
code: s.ZodIssueCode.invalid_date,
|
|
172
172
|
message: (i == null ? void 0 : i.invalidDate) || r.DATE_INVALID_FORMAT()
|
|
173
|
-
}),
|
|
174
|
-
code:
|
|
175
|
-
message: (i == null ? void 0 : i.min) || r.DATE_MIN(
|
|
176
|
-
}), n && _.getTime() > (
|
|
177
|
-
code:
|
|
173
|
+
}), d && _.getTime() < (c.isString(d) ? new Date(d).getTime() : d.getTime()) && a.addIssue({
|
|
174
|
+
code: s.ZodIssueCode.invalid_date,
|
|
175
|
+
message: (i == null ? void 0 : i.min) || r.DATE_MIN(d)
|
|
176
|
+
}), n && _.getTime() > (c.isString(n) ? new Date(n).getTime() : n.getTime()) && a.addIssue({
|
|
177
|
+
code: s.ZodIssueCode.invalid_date,
|
|
178
178
|
message: (i == null ? void 0 : i.max) || r.DATE_MAX(n)
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
}).optional();
|
|
183
183
|
};
|
|
184
|
-
function
|
|
184
|
+
function U(e) {
|
|
185
185
|
const { required: t = !0 } = e || {};
|
|
186
|
-
return t ?
|
|
186
|
+
return t ? h(e) : V(e);
|
|
187
187
|
}
|
|
188
|
-
const M = /^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/g,
|
|
189
|
-
const { message: t, regexp:
|
|
190
|
-
return
|
|
191
|
-
},
|
|
192
|
-
const { message: t, regexp:
|
|
193
|
-
return
|
|
194
|
-
(n) =>
|
|
188
|
+
const M = /^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/g, H = (e) => {
|
|
189
|
+
const { message: t, regexp: o = M } = e || {}, d = c.isString(o) ? new RegExp(o) : o;
|
|
190
|
+
return s.string().min(1, (t == null ? void 0 : t.min) || r.EMAIL_NON_EMPTY()).regex(d, (t == null ? void 0 : t.invalid) || r.EMAIL_INVALID()).default("");
|
|
191
|
+
}, w = (e) => {
|
|
192
|
+
const { message: t, regexp: o = M } = e || {}, d = c.isString(o) ? new RegExp(o) : o;
|
|
193
|
+
return s.string().refine(
|
|
194
|
+
(n) => c.isStringEmpty(n) ? !0 : d.test(n),
|
|
195
195
|
{
|
|
196
196
|
message: (t == null ? void 0 : t.invalid) || r.EMAIL_INVALID()
|
|
197
197
|
}
|
|
198
198
|
).optional().transform((n) => (n == null ? void 0 : n.length) === 0 ? void 0 : n);
|
|
199
199
|
};
|
|
200
|
-
function
|
|
200
|
+
function Y(e) {
|
|
201
201
|
const { required: t = !0 } = e || {};
|
|
202
|
-
return t ?
|
|
202
|
+
return t ? H(e) : w(e);
|
|
203
203
|
}
|
|
204
|
-
const
|
|
205
|
-
const { min: t, max:
|
|
206
|
-
let n =
|
|
207
|
-
return t && (n = n.min(t, (
|
|
208
|
-
},
|
|
209
|
-
function
|
|
204
|
+
const Z = (e) => {
|
|
205
|
+
const { min: t, max: o, message: d } = e || {};
|
|
206
|
+
let n = s.coerce.number();
|
|
207
|
+
return t && (n = n.min(t, (d == null ? void 0 : d.min) || r.MIN_VALUE(t))), o && (n = n.max(o, (d == null ? void 0 : d.min) || r.MAX_VALUE(o))), n.default(0);
|
|
208
|
+
}, p = (e) => Z(e).optional().transform((t) => t || void 0);
|
|
209
|
+
function F(e) {
|
|
210
210
|
const { required: t = !0 } = e || {};
|
|
211
|
-
return t ?
|
|
211
|
+
return t ? Z(e) : p(e);
|
|
212
212
|
}
|
|
213
|
-
const
|
|
214
|
-
const { ignoreMask: t = !0, maskSymbols:
|
|
215
|
-
let i =
|
|
216
|
-
const
|
|
217
|
-
["3", "4", "5", "6", "7", "9"].includes(
|
|
218
|
-
code:
|
|
213
|
+
const G = (e) => {
|
|
214
|
+
const { ignoreMask: t = !0, maskSymbols: o = /[()+_ -]/g, message: d } = e || {}, n = c.isString(o) ? new RegExp(o) : o;
|
|
215
|
+
let i = s.string().superRefine((u, a) => {
|
|
216
|
+
const l = u.replace(n, ""), f = l.charAt(1);
|
|
217
|
+
["3", "4", "5", "6", "7", "9"].includes(f) || a.addIssue({
|
|
218
|
+
code: s.ZodIssueCode.invalid_string,
|
|
219
219
|
validation: "regex",
|
|
220
|
-
message: (
|
|
221
|
-
}),
|
|
222
|
-
code:
|
|
220
|
+
message: (d == null ? void 0 : d.invalidOperator) || r.PHONE_INVALID_OPERATOR()
|
|
221
|
+
}), l.length < 11 && a.addIssue({
|
|
222
|
+
code: s.ZodIssueCode.too_small,
|
|
223
223
|
minimum: 11,
|
|
224
224
|
inclusive: !0,
|
|
225
225
|
type: "string",
|
|
226
|
-
message: (
|
|
226
|
+
message: (d == null ? void 0 : d.min) || r.PHONE_NON_EMPTY()
|
|
227
227
|
});
|
|
228
228
|
});
|
|
229
229
|
return t && (i = i.transform((u) => u.replace(n, ""))), i.default("");
|
|
230
|
-
},
|
|
231
|
-
const { ignoreMask: t = !0, maskSymbols:
|
|
232
|
-
let i =
|
|
233
|
-
const
|
|
234
|
-
["3", "4", "5", "6", "7", "9"].includes(
|
|
235
|
-
code:
|
|
230
|
+
}, b = (e) => {
|
|
231
|
+
const { ignoreMask: t = !0, maskSymbols: o = /[()+_ -]/g, message: d } = e || {}, n = c.isString(o) ? new RegExp(o) : o;
|
|
232
|
+
let i = s.string().superRefine((u, a) => {
|
|
233
|
+
const l = u.replace(n, ""), f = l.charAt(1);
|
|
234
|
+
["3", "4", "5", "6", "7", "9"].includes(f) || a.addIssue({
|
|
235
|
+
code: s.ZodIssueCode.invalid_string,
|
|
236
236
|
validation: "regex",
|
|
237
|
-
message: (
|
|
238
|
-
}),
|
|
239
|
-
code:
|
|
237
|
+
message: (d == null ? void 0 : d.invalidOperator) || r.PHONE_INVALID_OPERATOR()
|
|
238
|
+
}), l.length < 11 && a.addIssue({
|
|
239
|
+
code: s.ZodIssueCode.too_small,
|
|
240
240
|
minimum: 11,
|
|
241
241
|
inclusive: !0,
|
|
242
242
|
type: "string",
|
|
243
|
-
message: (
|
|
243
|
+
message: (d == null ? void 0 : d.min) || r.PHONE_NON_EMPTY()
|
|
244
244
|
});
|
|
245
245
|
});
|
|
246
246
|
return t && (i = i.transform((u) => u.replace(n, ""))), i.transform((u) => u || void 0);
|
|
247
247
|
};
|
|
248
|
-
function
|
|
248
|
+
function $(e) {
|
|
249
249
|
const { required: t = !0 } = e || {};
|
|
250
|
-
return t ?
|
|
250
|
+
return t ? G(e) : b(e);
|
|
251
251
|
}
|
|
252
|
-
const
|
|
253
|
-
var
|
|
254
|
-
const { message: t } = e || {},
|
|
252
|
+
const X = (e) => {
|
|
253
|
+
var d, n;
|
|
254
|
+
const { message: t } = e || {}, o = s.string().min(1, (t == null ? void 0 : t.single) || r.SELECT_NON_EMPTY()).nullable().refine((i) => !!i, (t == null ? void 0 : t.single) || r.SELECT_NON_EMPTY()).default(null);
|
|
255
255
|
if (e != null && e.multiple) {
|
|
256
|
-
let i =
|
|
257
|
-
return e != null && e.length ? i.length(e.length, ((
|
|
256
|
+
let i = s.array(o).min((e == null ? void 0 : e.minLength) || 0, (t == null ? void 0 : t.multiple) || r.SELECT_MULTIPLE_MIN_LENGTH((e == null ? void 0 : e.minLength) || 0));
|
|
257
|
+
return e != null && e.length ? i.length(e.length, ((d = e.message) == null ? void 0 : d.length) || r.SELECT_FIX_LENGTH(e.length)).default([]) : (e != null && e.maxLength && (i = i.max(
|
|
258
258
|
e.maxLength,
|
|
259
259
|
((n = e.message) == null ? void 0 : n.maxLength) || r.SELECT_MULTIPLE_MAX_LENGTH(e.maxLength)
|
|
260
260
|
)), i.default([]));
|
|
261
261
|
}
|
|
262
|
-
return
|
|
262
|
+
return o;
|
|
263
263
|
};
|
|
264
|
-
function
|
|
265
|
-
const t =
|
|
266
|
-
return e != null && e.multiple ?
|
|
264
|
+
function x(e) {
|
|
265
|
+
const t = s.string().nullable().optional();
|
|
266
|
+
return e != null && e.multiple ? s.array(t).optional() : t;
|
|
267
267
|
}
|
|
268
|
-
function
|
|
268
|
+
function q(e) {
|
|
269
269
|
const { required: t = !0 } = e || {};
|
|
270
|
-
return t ?
|
|
270
|
+
return t ? X(e) : x(e);
|
|
271
271
|
}
|
|
272
|
-
const
|
|
273
|
-
const { min: t, max:
|
|
274
|
-
let i =
|
|
275
|
-
return t && (i = i.min(t, { message: (n == null ? void 0 : n.min) || r.MIN_LENGTH(t) })),
|
|
272
|
+
const v = (e) => {
|
|
273
|
+
const { min: t, max: o, length: d, message: n } = e || {};
|
|
274
|
+
let i = s.string({ message: n == null ? void 0 : n.root });
|
|
275
|
+
return t && (i = i.min(t, { message: (n == null ? void 0 : n.min) || r.MIN_LENGTH(t) })), o && (i = i.max(o, { message: (n == null ? void 0 : n.max) || r.MAX_LENGTH(o) })), d && (i = i.length(d, { message: (n == null ? void 0 : n.length) || r.FIX_LENGTH(d) })), i.refine((u) => !!u.length, { message: (n == null ? void 0 : n.min) || r.NON_EMPTY() }).default("");
|
|
276
276
|
}, z = (e) => {
|
|
277
|
-
const { min: t, max:
|
|
278
|
-
let i =
|
|
279
|
-
return t && (i = i.min(t, { message: (n == null ? void 0 : n.min) || r.MIN_LENGTH(t) })),
|
|
277
|
+
const { min: t, max: o, length: d, message: n } = e || {};
|
|
278
|
+
let i = s.string({ message: n == null ? void 0 : n.root });
|
|
279
|
+
return t && (i = i.min(t, { message: (n == null ? void 0 : n.min) || r.MIN_LENGTH(t) })), o && (i = i.max(o, { message: (n == null ? void 0 : n.max) || r.MAX_LENGTH(o) })), d && (i = i.length(d, { message: (n == null ? void 0 : n.length) || r.FIX_LENGTH(d) })), i.optional().transform((u) => u != null && u.length ? u : void 0);
|
|
280
280
|
};
|
|
281
281
|
function B(e) {
|
|
282
|
-
const { required: t = !0, ...
|
|
283
|
-
return t ?
|
|
282
|
+
const { required: t = !0, ...o } = e || {};
|
|
283
|
+
return t ? v(o) : z(o);
|
|
284
284
|
}
|
|
285
|
-
const
|
|
286
|
-
const { message:
|
|
287
|
-
return
|
|
288
|
-
message:
|
|
289
|
-
...
|
|
285
|
+
const O = (e, t) => {
|
|
286
|
+
const { message: o, ...d } = t || {}, [n, i, ...u] = e.map((l) => s.literal(l)), a = o ? typeof o == "function" ? o(e) : o : r.VALUE_OUT_OF_RANGE(e);
|
|
287
|
+
return s.union([n, i, ...u], {
|
|
288
|
+
message: a,
|
|
289
|
+
...d
|
|
290
290
|
}).nullable().refine(Boolean, r.NON_EMPTY()).default(null);
|
|
291
|
-
},
|
|
292
|
-
function
|
|
293
|
-
const { required:
|
|
294
|
-
return
|
|
291
|
+
}, j = (e, t) => O(e, t).optional();
|
|
292
|
+
function k(e, t) {
|
|
293
|
+
const { required: o, ...d } = t || {};
|
|
294
|
+
return o ? O(e, d) : j(e, d);
|
|
295
295
|
}
|
|
296
|
-
const
|
|
297
|
-
const { message: t, regexp:
|
|
298
|
-
return D().min(1, (t == null ? void 0 : t.min) || r.NON_EMPTY()).regex(
|
|
296
|
+
const C = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([-.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/, W = (e) => {
|
|
297
|
+
const { message: t, regexp: o = C } = e || {}, d = c.isString(o) ? new RegExp(o) : o;
|
|
298
|
+
return D().min(1, (t == null ? void 0 : t.min) || r.NON_EMPTY()).regex(d, (t == null ? void 0 : t.invalid) || r.INVALID_URL()).default("");
|
|
299
299
|
}, K = (e) => {
|
|
300
|
-
const { message: t, regexp:
|
|
301
|
-
return D().refine((n) =>
|
|
300
|
+
const { message: t, regexp: o = C } = e || {}, d = c.isString(o) ? new RegExp(o) : o;
|
|
301
|
+
return D().refine((n) => c.isStringEmpty(n) ? !0 : d.test(n), (t == null ? void 0 : t.invalid) || r.INVALID_URL()).optional().transform((n) => n != null && n.length ? n : void 0);
|
|
302
302
|
};
|
|
303
303
|
function Q(e) {
|
|
304
304
|
const { required: t = !0 } = e || {};
|
|
@@ -306,12 +306,12 @@ function Q(e) {
|
|
|
306
306
|
}
|
|
307
307
|
const J = {
|
|
308
308
|
getStringSchema: B,
|
|
309
|
-
getEmailSchema:
|
|
310
|
-
getSelectSchema:
|
|
311
|
-
getNumberSchema:
|
|
312
|
-
getPhoneSchema:
|
|
313
|
-
getDateSchema:
|
|
314
|
-
getUnionSchema:
|
|
309
|
+
getEmailSchema: Y,
|
|
310
|
+
getSelectSchema: q,
|
|
311
|
+
getNumberSchema: F,
|
|
312
|
+
getPhoneSchema: $,
|
|
313
|
+
getDateSchema: U,
|
|
314
|
+
getUnionSchema: k,
|
|
315
315
|
getUrlSchema: Q
|
|
316
316
|
};
|
|
317
317
|
class ce {
|
|
@@ -345,48 +345,79 @@ class ce {
|
|
|
345
345
|
* // }
|
|
346
346
|
* // }
|
|
347
347
|
*/
|
|
348
|
-
static getZodDefaults(t,
|
|
349
|
-
const { fillArrayWithValue:
|
|
350
|
-
if (t instanceof
|
|
351
|
-
return t.innerType() instanceof
|
|
348
|
+
static getZodDefaults(t, o) {
|
|
349
|
+
const { fillArrayWithValue: d } = o || {};
|
|
350
|
+
if (t instanceof s.ZodEffects)
|
|
351
|
+
return t.innerType() instanceof s.ZodEffects ? this.getZodDefaults(t.innerType(), o) : this.getZodDefaults(s.ZodObject.create(t.innerType().shape), o);
|
|
352
352
|
const n = (a) => {
|
|
353
353
|
switch (!0) {
|
|
354
|
-
case a instanceof
|
|
354
|
+
case (a._def.typeName === "ZodDefault" || a instanceof s.ZodDefault):
|
|
355
355
|
return a._def.defaultValue();
|
|
356
|
-
case a instanceof
|
|
356
|
+
case (a._def.typeName === "ZodOptional" || a instanceof s.ZodOptional):
|
|
357
357
|
return;
|
|
358
|
-
case a instanceof
|
|
358
|
+
case (a._def.typeName === "ZodNullable" || a instanceof s.ZodNullable):
|
|
359
359
|
return null;
|
|
360
|
-
case a instanceof
|
|
361
|
-
return
|
|
362
|
-
case a instanceof
|
|
363
|
-
return this.getZodDefaults(a,
|
|
364
|
-
case a instanceof
|
|
360
|
+
case (a._def.typeName === "ZodArray" || a instanceof s.ZodArray):
|
|
361
|
+
return d ? [n(a.element)] : [];
|
|
362
|
+
case (a._def.typeName === "ZodObject" || a instanceof s.ZodObject):
|
|
363
|
+
return this.getZodDefaults(a, o);
|
|
364
|
+
case (a._def.typeName === "ZodUnion" || a instanceof s.ZodUnion):
|
|
365
365
|
return n(a._def.options[0]);
|
|
366
|
-
case a instanceof
|
|
366
|
+
case (a._def.typeName === "ZodLiteral" || a instanceof s.ZodLiteral):
|
|
367
367
|
return a._def.value;
|
|
368
|
-
case a instanceof
|
|
368
|
+
case (a._def.typeName === "ZodDiscriminatedUnion" || a instanceof s.ZodDiscriminatedUnion):
|
|
369
369
|
return n(a._def.options[0]);
|
|
370
|
-
case a instanceof
|
|
370
|
+
case (a._def.typeName === "ZodEnum" || a instanceof s.ZodEnum):
|
|
371
371
|
return a._def.values[0];
|
|
372
|
-
case a instanceof
|
|
372
|
+
case (a._def.typeName === "ZodString" || a instanceof s.ZodString):
|
|
373
373
|
return "";
|
|
374
|
-
case a instanceof
|
|
374
|
+
case (a._def.typeName === "ZodNumber" || a instanceof s.ZodNumber):
|
|
375
375
|
return 0;
|
|
376
|
-
case a instanceof
|
|
376
|
+
case (a._def.typeName === "ZodBoolean" || a instanceof s.ZodBoolean):
|
|
377
377
|
return !1;
|
|
378
378
|
case !("innerType" in a._def):
|
|
379
379
|
return;
|
|
380
380
|
default:
|
|
381
381
|
return n(a._def.innerType);
|
|
382
382
|
}
|
|
383
|
-
}, i = {}
|
|
384
|
-
return Object.entries(
|
|
385
|
-
i[a] = n(
|
|
383
|
+
}, i = {};
|
|
384
|
+
return Object.entries(t.shape).map(([a, l]) => {
|
|
385
|
+
i[a] = n(l);
|
|
386
386
|
}), i;
|
|
387
387
|
}
|
|
388
|
+
/**
|
|
389
|
+
* Функция для объединения zod схождений
|
|
390
|
+
* @param {ZodIntersection} zodSchema
|
|
391
|
+
* @returns объединенная схема двух схождений
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* let schema = z.object({
|
|
395
|
+
* foo: z.string()
|
|
396
|
+
* })
|
|
397
|
+
* // this will return intersection and we need
|
|
398
|
+
* // to merge its left to right schema's
|
|
399
|
+
* .and(
|
|
400
|
+
* z.object({
|
|
401
|
+
* bar: z.string()
|
|
402
|
+
* })
|
|
403
|
+
* )
|
|
404
|
+
*
|
|
405
|
+
* schema = ZodUtils.zodMergeIntersection(schema)
|
|
406
|
+
*
|
|
407
|
+
* // schema will be
|
|
408
|
+
* z.object({
|
|
409
|
+
* foo: z.string(),
|
|
410
|
+
* bar: z.string()
|
|
411
|
+
* })
|
|
412
|
+
*/
|
|
413
|
+
static zodMergeIntersection(t) {
|
|
414
|
+
const { left: o, right: d } = t._def, n = o instanceof s.ZodDiscriminatedUnion || o._def.typeName === "ZodDiscriminatedUnion" ? o._def.options[0] : o, i = d instanceof s.ZodDiscriminatedUnion || o._def.typeName === "ZodDiscriminatedUnion" ? d._def.options[0] : d;
|
|
415
|
+
if (n instanceof s.ZodObject && i instanceof s.ZodObject)
|
|
416
|
+
return n.merge(i);
|
|
417
|
+
throw new Error(`Cannot merge schema type ${i._def.typeName} to ${n._def.typeName}`);
|
|
418
|
+
}
|
|
388
419
|
}
|
|
389
|
-
const
|
|
420
|
+
const m = {
|
|
390
421
|
NON_EMPTY: () => "Поле обязательно для заполнения",
|
|
391
422
|
VALUE_NO_WHITESPACE: () => "Укажите фамилию, имя и отчество через пробел",
|
|
392
423
|
ONLY_CYRILLIC: () => "Данные должны быть написаны кириллицей",
|
|
@@ -394,43 +425,43 @@ const g = {
|
|
|
394
425
|
INVALID_NAME: () => "Неверно введено имя",
|
|
395
426
|
INVALID_SURNAME: () => "Неверно введена фамилия",
|
|
396
427
|
INVALID_PATRONYMIC: () => "Неверно введено отчество"
|
|
397
|
-
},
|
|
428
|
+
}, g = {
|
|
398
429
|
ONLY_CYRILLIC: /[\u0400-\u04FF\u00CB\u00EB -]/g,
|
|
399
430
|
CHECK_HYPHEN: /^(?:[^-]+(?:-[^-]+){0,4}|[^-]+)$/,
|
|
400
431
|
PATRONYMIC: /^[a-zA-Zа-яА-ЯёЁ]+(?:\s*-\s*[a-zA-Zа-яА-ЯёЁ]+){0,4}(?:\s+[a-zA-Zа-яА-ЯёЁ]+(?:\s*-\s*[a-zA-Zа-яА-ЯёЁ]+){0,4})?$/i
|
|
401
432
|
}, ee = (e) => {
|
|
402
|
-
const [t,
|
|
403
|
-
return { surname: t, name:
|
|
433
|
+
const [t, o, ...d] = e.trim().replace(/\s+/g, " ").split(" "), n = d.join(" ");
|
|
434
|
+
return { surname: t, name: o, patronymic: n };
|
|
404
435
|
}, S = (e) => {
|
|
405
|
-
const { message: t } = e || {}, { nameOrSurnameEmpty:
|
|
406
|
-
return
|
|
407
|
-
const { name:
|
|
408
|
-
|
|
409
|
-
code:
|
|
436
|
+
const { message: t } = e || {}, { nameOrSurnameEmpty: o, invalidSurname: d, invalidPatronymic: n, invalidName: i } = t || {};
|
|
437
|
+
return s.string().superRefine((u, a) => {
|
|
438
|
+
const { name: l, surname: f, patronymic: _ } = ee(u);
|
|
439
|
+
g.ONLY_CYRILLIC.test(u) || a.addIssue({
|
|
440
|
+
code: s.ZodIssueCode.invalid_string,
|
|
410
441
|
validation: "regex",
|
|
411
|
-
message:
|
|
412
|
-
}), (!
|
|
413
|
-
code:
|
|
442
|
+
message: m.ONLY_CYRILLIC()
|
|
443
|
+
}), (!l || !f) && a.addIssue({
|
|
444
|
+
code: s.ZodIssueCode.invalid_string,
|
|
414
445
|
validation: "regex",
|
|
415
|
-
message:
|
|
416
|
-
}),
|
|
417
|
-
code:
|
|
446
|
+
message: o || m.NAME_OR_SURNAME_NON_EMPTY()
|
|
447
|
+
}), g.CHECK_HYPHEN.test(l) || a.addIssue({
|
|
448
|
+
code: s.ZodIssueCode.invalid_string,
|
|
418
449
|
validation: "regex",
|
|
419
|
-
message: i ||
|
|
420
|
-
}),
|
|
421
|
-
code:
|
|
450
|
+
message: i || m.INVALID_NAME()
|
|
451
|
+
}), g.CHECK_HYPHEN.test(f) || a.addIssue({
|
|
452
|
+
code: s.ZodIssueCode.invalid_string,
|
|
422
453
|
validation: "regex",
|
|
423
|
-
message:
|
|
424
|
-
}), _ && (
|
|
425
|
-
code:
|
|
454
|
+
message: d || m.INVALID_SURNAME()
|
|
455
|
+
}), _ && (g.PATRONYMIC.test(_) || a.addIssue({
|
|
456
|
+
code: s.ZodIssueCode.invalid_string,
|
|
426
457
|
validation: "regex",
|
|
427
|
-
message: n ||
|
|
458
|
+
message: n || m.INVALID_PATRONYMIC()
|
|
428
459
|
}));
|
|
429
460
|
}).transform((u) => u.trimEnd()).default("");
|
|
430
461
|
}, te = (e) => S(e).optional().transform((t) => t != null && t.length ? t : void 0);
|
|
431
462
|
function ne(e) {
|
|
432
|
-
const { required: t = !0, ...
|
|
433
|
-
return t ? S(
|
|
463
|
+
const { required: t = !0, ...o } = e || {};
|
|
464
|
+
return t ? S(o) : te(o);
|
|
434
465
|
}
|
|
435
466
|
const ie = {
|
|
436
467
|
getFioSchema: ne
|
|
@@ -440,17 +471,17 @@ const ie = {
|
|
|
440
471
|
};
|
|
441
472
|
export {
|
|
442
473
|
A as RgxCheckForHyphen,
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
474
|
+
y as RgxPatronymic,
|
|
475
|
+
R as RgxUnicode,
|
|
476
|
+
E as VALIDATION_MESSAGES,
|
|
446
477
|
ce as ZodUtils,
|
|
447
478
|
r as baseDefaultMessages,
|
|
448
479
|
J as baseValidationSchemas,
|
|
449
480
|
P as formattedDadataFio,
|
|
450
|
-
|
|
451
|
-
|
|
481
|
+
ae as zodCalendarValidate,
|
|
482
|
+
se as zodDadataFioSchema,
|
|
452
483
|
ue as zodOtpCodeSchema,
|
|
453
|
-
|
|
484
|
+
re as zodPhoneSchema,
|
|
454
485
|
le as zodValidators
|
|
455
486
|
};
|
|
456
487
|
//# sourceMappingURL=validation.js.map
|