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