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