@scbt-ecom/ui 0.50.0 → 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.
@@ -1,6 +1,6 @@
1
- import { z as o, p as f, i as N, f as T, D as L, s as D } from "./utils-Od0KoTas.js";
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
2
  import { T as c } from "./typeGuards-BigW-JS1.js";
3
- const Z = /^[\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 = {
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,63 +13,63 @@ 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(" "), [d, s, ...n] = t, i = n == null ? void 0 : n.join(" ");
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: d,
19
- name: s,
18
+ surname: o,
19
+ name: d,
20
20
  patronymic: i
21
21
  };
22
- }, oe = o.string({ invalid_type_error: "Обязательно к заполнению", required_error: "Обязательно к заполнению" }).superRefine((e, t) => {
22
+ }, se = s.string({ invalid_type_error: "Обязательно к заполнению", required_error: "Обязательно к заполнению" }).superRefine((e, t) => {
23
23
  e === "" && t.addIssue({
24
- code: o.ZodIssueCode.custom,
24
+ code: s.ZodIssueCode.custom,
25
25
  message: "Введите имя и фамилию"
26
- }), Z.test(e) || t.addIssue({
27
- code: o.ZodIssueCode.custom,
26
+ }), R.test(e) || t.addIssue({
27
+ code: s.ZodIssueCode.custom,
28
28
  message: "Должна быть только кириллица"
29
29
  });
30
- const { surname: d, name: s, patronymic: n } = P(e);
31
- (!d || !s) && t.addIssue({
32
- code: o.ZodIssueCode.custom,
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: o.ZodIssueCode.custom,
35
+ code: s.ZodIssueCode.custom,
36
+ message: "Неверно введено имя"
37
+ }), A.test(o) || t.addIssue({
38
+ code: s.ZodIssueCode.custom,
39
39
  message: "Неверно введена фамилия"
40
- }), n && (h.test(n) || t.addIssue({
41
- code: o.ZodIssueCode.custom,
40
+ }), n && (y.test(n) || t.addIssue({
41
+ code: s.ZodIssueCode.custom,
42
42
  message: "Неверно введено отчество"
43
43
  }));
44
- }), re = o.string().length(10, { message: I.INVALID_DATE }).superRefine((e, t) => {
45
- const [d, s, n] = (e == null ? void 0 : e.split(".")) ?? "", i = f(`${d}/${s}/${n}`, "dd/MM/yyyy", /* @__PURE__ */ new Date());
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: o.ZodIssueCode.custom,
48
- message: I.INVALID_DATE
47
+ code: s.ZodIssueCode.custom,
48
+ message: E.INVALID_DATE
49
49
  }), N(i) || t.addIssue({
50
- code: o.ZodIssueCode.custom,
51
- message: I.INVALID_DATE
50
+ code: s.ZodIssueCode.custom,
51
+ message: E.INVALID_DATE
52
52
  }), (/* @__PURE__ */ new Date()).getTime() < new Date(i).getTime() && t.addIssue({
53
- code: o.ZodIssueCode.custom,
54
- message: I.FUTURE_DATE_NOT_ALLOWED
53
+ code: s.ZodIssueCode.custom,
54
+ message: E.FUTURE_DATE_NOT_ALLOWED
55
55
  });
56
- }), ae = o.string().superRefine((e, t) => {
57
- const d = e.charAt(0);
58
- ["3", "4", "5", "6", "9"].includes(d) || t.addIssue({
59
- code: o.ZodIssueCode.custom,
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: o.ZodIssueCode.custom,
62
+ code: s.ZodIssueCode.custom,
63
63
  message: "Введите номер телефона полностью"
64
64
  });
65
- }).transform((e) => `7${e}`), ue = o.coerce.number().min(1e3, `${I.FIX_LENGTH} 4`).max(9999, `${I.FIX_LENGTH} 4`).nullable().superRefine((e, t) => {
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: o.ZodIssueCode.invalid_type,
67
+ code: s.ZodIssueCode.invalid_type,
68
68
  expected: "number",
69
69
  received: "null",
70
- message: `${I.FIX_LENGTH} 4`
70
+ message: `${E.FIX_LENGTH} 4`
71
71
  });
72
- }).default(null), a = {
72
+ }).default(null), r = {
73
73
  NON_EMPTY: () => "Поле не может быть пустым",
74
74
  MIN_LENGTH: (e) => `Поле должно содержать минимум символов: ${e}`,
75
75
  MAX_LENGTH: (e) => `Поле должно содержать максимум символов: ${e}`,
@@ -96,209 +96,209 @@ const Z = /^[\u0400-\u04FF\u00CB\u00EB -]+$/, A = /^(?:[^-]+(?:-[^-]+){0,4}|[^-]
96
96
  return `Выбранная дата должна быть не позже ${T(t)}`;
97
97
  },
98
98
  INVALID_URL: () => "Ссылка введена некорректно. Пример: https://example.com, example.com"
99
- }, V = (e) => {
100
- const { iso: t = !0, pattern: d = L, min: s, max: n, message: i } = e || {};
101
- return o.string().min(8, (i == null ? void 0 : i.min) || a.DATE_NON_EMPTY()).superRefine((u, r) => {
102
- const l = d.replace(/\W/g, "").length;
103
- if (u.replace(/[._-]/g, "").length < l && r.addIssue({
104
- code: o.ZodIssueCode.too_small,
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
105
  minimum: l,
106
106
  type: "date",
107
107
  inclusive: !0,
108
- message: (i == null ? void 0 : i.min) || a.DATE_NON_EMPTY()
108
+ message: (i == null ? void 0 : i.min) || r.DATE_NON_EMPTY()
109
109
  }), t) {
110
110
  let _ = null;
111
111
  try {
112
112
  _ = new Date(u);
113
113
  } catch {
114
- r.addIssue({
115
- code: o.ZodIssueCode.invalid_date,
116
- message: (i == null ? void 0 : i.invalidDate) || a.DATE_INVALID_FORMAT()
114
+ a.addIssue({
115
+ code: s.ZodIssueCode.invalid_date,
116
+ message: (i == null ? void 0 : i.invalidDate) || r.DATE_INVALID_FORMAT()
117
117
  });
118
118
  }
119
- s && _.getTime() < (c.isString(s) ? new Date(s).getTime() : s.getTime()) && r.addIssue({
120
- code: o.ZodIssueCode.invalid_date,
121
- message: (i == null ? void 0 : i.min) || a.DATE_MIN(s)
122
- }), n && _.getTime() > (c.isString(n) ? new Date(n).getTime() : n.getTime()) && r.addIssue({
123
- code: o.ZodIssueCode.invalid_date,
124
- message: (i == null ? void 0 : i.max) || a.DATE_MAX(n)
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
+ message: (i == null ? void 0 : i.max) || r.DATE_MAX(n)
125
125
  });
126
126
  } else {
127
- const _ = f(u, d, /* @__PURE__ */ new Date());
128
- N(_) || r.addIssue({
129
- code: o.ZodIssueCode.invalid_date,
130
- message: (i == null ? void 0 : i.invalidDate) || a.DATE_INVALID_FORMAT()
131
- }), s && _.getTime() < (c.isString(s) ? new Date(s).getTime() : s.getTime()) && r.addIssue({
132
- code: o.ZodIssueCode.invalid_date,
133
- message: (i == null ? void 0 : i.min) || a.DATE_MIN(s)
134
- }), n && _.getTime() > (c.isString(n) ? new Date(n).getTime() : n.getTime()) && r.addIssue({
135
- code: o.ZodIssueCode.invalid_date,
136
- message: (i == null ? void 0 : i.max) || a.DATE_MAX(n)
127
+ const _ = I(u, o, /* @__PURE__ */ new Date());
128
+ N(_) || a.addIssue({
129
+ code: s.ZodIssueCode.invalid_date,
130
+ message: (i == null ? void 0 : i.invalidDate) || r.DATE_INVALID_FORMAT()
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
+ message: (i == null ? void 0 : i.max) || r.DATE_MAX(n)
137
137
  });
138
138
  }
139
139
  }).default("");
140
- }, y = (e) => {
141
- const { iso: t = !0, pattern: d = L, min: s, max: n, message: i } = e || {};
142
- return o.string().transform((u) => u || void 0).superRefine((u, r) => {
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
143
  if (c.isString(u) && u.length) {
144
- const l = d.replace(/\W/g, "").length;
145
- if (u.replace(/[._-]/g, "").length < l && r.addIssue({
146
- code: o.ZodIssueCode.too_small,
144
+ const l = o.replace(/\W/g, "").length;
145
+ if (u.replace(/[._-]/g, "").length < l && a.addIssue({
146
+ code: s.ZodIssueCode.too_small,
147
147
  minimum: l,
148
148
  type: "date",
149
149
  inclusive: !0,
150
- message: (i == null ? void 0 : i.min) || a.DATE_NON_EMPTY()
150
+ message: (i == null ? void 0 : i.min) || r.DATE_NON_EMPTY()
151
151
  }), t) {
152
152
  let _ = null;
153
153
  try {
154
154
  _ = new Date(u);
155
155
  } catch {
156
- r.addIssue({
157
- code: o.ZodIssueCode.invalid_date,
158
- message: (i == null ? void 0 : i.invalidDate) || a.DATE_INVALID_FORMAT()
156
+ a.addIssue({
157
+ code: s.ZodIssueCode.invalid_date,
158
+ message: (i == null ? void 0 : i.invalidDate) || r.DATE_INVALID_FORMAT()
159
159
  });
160
160
  }
161
- s && _.getTime() < (c.isString(s) ? new Date(s).getTime() : s.getTime()) && r.addIssue({
162
- code: o.ZodIssueCode.invalid_date,
163
- message: (i == null ? void 0 : i.min) || a.DATE_MIN(s)
164
- }), n && _.getTime() > (c.isString(n) ? new Date(n).getTime() : n.getTime()) && r.addIssue({
165
- code: o.ZodIssueCode.invalid_date,
166
- message: (i == null ? void 0 : i.max) || a.DATE_MAX(n)
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
+ message: (i == null ? void 0 : i.max) || r.DATE_MAX(n)
167
167
  });
168
168
  } else {
169
- const _ = f(u, d, /* @__PURE__ */ new Date());
170
- N(_) || r.addIssue({
171
- code: o.ZodIssueCode.invalid_date,
172
- message: (i == null ? void 0 : i.invalidDate) || a.DATE_INVALID_FORMAT()
173
- }), s && _.getTime() < (c.isString(s) ? new Date(s).getTime() : s.getTime()) && r.addIssue({
174
- code: o.ZodIssueCode.invalid_date,
175
- message: (i == null ? void 0 : i.min) || a.DATE_MIN(s)
176
- }), n && _.getTime() > (c.isString(n) ? new Date(n).getTime() : n.getTime()) && r.addIssue({
177
- code: o.ZodIssueCode.invalid_date,
178
- message: (i == null ? void 0 : i.max) || a.DATE_MAX(n)
169
+ const _ = I(u, o, /* @__PURE__ */ new Date());
170
+ N(_) || a.addIssue({
171
+ code: s.ZodIssueCode.invalid_date,
172
+ message: (i == null ? void 0 : i.invalidDate) || r.DATE_INVALID_FORMAT()
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
+ message: (i == null ? void 0 : i.max) || r.DATE_MAX(n)
179
179
  });
180
180
  }
181
181
  }
182
182
  }).optional();
183
183
  };
184
- function H(e) {
184
+ function U(e) {
185
185
  const { required: t = !0 } = e || {};
186
- return t ? V(e) : y(e);
186
+ return t ? h(e) : V(e);
187
187
  }
188
- const M = /^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/g, U = (e) => {
189
- const { message: t, regexp: d = M } = e || {}, s = c.isString(d) ? new RegExp(d) : d;
190
- return o.string().min(1, (t == null ? void 0 : t.min) || a.EMAIL_NON_EMPTY()).regex(s, (t == null ? void 0 : t.invalid) || a.EMAIL_INVALID()).default("");
191
- }, Y = (e) => {
192
- const { message: t, regexp: d = M } = e || {}, s = c.isString(d) ? new RegExp(d) : d;
193
- return o.string().refine(
194
- (n) => c.isStringEmpty(n) ? !0 : s.test(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
- message: (t == null ? void 0 : t.invalid) || a.EMAIL_INVALID()
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 w(e) {
200
+ function Y(e) {
201
201
  const { required: t = !0 } = e || {};
202
- return t ? U(e) : Y(e);
202
+ return t ? H(e) : w(e);
203
203
  }
204
- const O = (e) => {
205
- const { min: t, max: d, message: s } = e || {};
206
- let n = o.coerce.number();
207
- return t && (n = n.min(t, (s == null ? void 0 : s.min) || a.MIN_VALUE(t))), d && (n = n.max(d, (s == null ? void 0 : s.min) || a.MAX_VALUE(d))), n.default(0);
208
- }, F = (e) => O(e).optional().transform((t) => t || void 0);
209
- function G(e) {
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 ? O(e) : F(e);
211
+ return t ? Z(e) : p(e);
212
212
  }
213
- const X = (e) => {
214
- const { ignoreMask: t = !0, maskSymbols: d = /[()+_ -]/g, message: s } = e || {}, n = c.isString(d) ? new RegExp(d) : d;
215
- let i = o.string().superRefine((u, r) => {
216
- const l = u.replace(n, ""), E = l.charAt(1);
217
- ["3", "4", "5", "6", "7", "9"].includes(E) || r.addIssue({
218
- code: o.ZodIssueCode.invalid_string,
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: (s == null ? void 0 : s.invalidOperator) || a.PHONE_INVALID_OPERATOR()
221
- }), l.length < 11 && r.addIssue({
222
- code: o.ZodIssueCode.too_small,
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: (s == null ? void 0 : s.min) || a.PHONE_NON_EMPTY()
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
- }, $ = (e) => {
231
- const { ignoreMask: t = !0, maskSymbols: d = /[()+_ -]/g, message: s } = e || {}, n = c.isString(d) ? new RegExp(d) : d;
232
- let i = o.string().superRefine((u, r) => {
233
- const l = u.replace(n, ""), E = l.charAt(1);
234
- ["3", "4", "5", "6", "7", "9"].includes(E) || r.addIssue({
235
- code: o.ZodIssueCode.invalid_string,
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: (s == null ? void 0 : s.invalidOperator) || a.PHONE_INVALID_OPERATOR()
238
- }), l.length < 11 && r.addIssue({
239
- code: o.ZodIssueCode.too_small,
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: (s == null ? void 0 : s.min) || a.PHONE_NON_EMPTY()
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 x(e) {
248
+ function $(e) {
249
249
  const { required: t = !0 } = e || {};
250
- return t ? X(e) : $(e);
250
+ return t ? G(e) : b(e);
251
251
  }
252
- const b = (e) => {
253
- var s, n;
254
- const { message: t } = e || {}, d = o.string().min(1, (t == null ? void 0 : t.single) || a.SELECT_NON_EMPTY()).nullable().refine((i) => !!i, (t == null ? void 0 : t.single) || a.SELECT_NON_EMPTY()).default(null);
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 = o.array(d).min((e == null ? void 0 : e.minLength) || 0, (t == null ? void 0 : t.multiple) || a.SELECT_MULTIPLE_MIN_LENGTH((e == null ? void 0 : e.minLength) || 0));
257
- return e != null && e.length ? i.length(e.length, ((s = e.message) == null ? void 0 : s.length) || a.SELECT_FIX_LENGTH(e.length)).default([]) : (e != null && e.maxLength && (i = i.max(
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
- ((n = e.message) == null ? void 0 : n.maxLength) || a.SELECT_MULTIPLE_MAX_LENGTH(e.maxLength)
259
+ ((n = e.message) == null ? void 0 : n.maxLength) || r.SELECT_MULTIPLE_MAX_LENGTH(e.maxLength)
260
260
  )), i.default([]));
261
261
  }
262
- return d;
262
+ return o;
263
263
  };
264
- function q(e) {
265
- const t = o.string().nullable().optional();
266
- return e != null && e.multiple ? o.array(t).optional() : t;
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 v(e) {
268
+ function q(e) {
269
269
  const { required: t = !0 } = e || {};
270
- return t ? b(e) : q(e);
270
+ return t ? X(e) : x(e);
271
271
  }
272
- const p = (e) => {
273
- const { min: t, max: d, length: s, message: n } = e || {};
274
- let i = o.string({ message: n == null ? void 0 : n.root });
275
- return t && (i = i.min(t, { message: (n == null ? void 0 : n.min) || a.MIN_LENGTH(t) })), d && (i = i.max(d, { message: (n == null ? void 0 : n.max) || a.MAX_LENGTH(d) })), s && (i = i.length(s, { message: (n == null ? void 0 : n.length) || a.FIX_LENGTH(s) })), i.refine((u) => !!u.length, { message: (n == null ? void 0 : n.min) || a.NON_EMPTY() }).default("");
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: d, length: s, message: n } = e || {};
278
- let i = o.string({ message: n == null ? void 0 : n.root });
279
- return t && (i = i.min(t, { message: (n == null ? void 0 : n.min) || a.MIN_LENGTH(t) })), d && (i = i.max(d, { message: (n == null ? void 0 : n.max) || a.MAX_LENGTH(d) })), s && (i = i.length(s, { message: (n == null ? void 0 : n.length) || a.FIX_LENGTH(s) })), i.optional().transform((u) => u != null && u.length ? u : void 0);
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, ...d } = e || {};
283
- return t ? p(d) : z(d);
282
+ const { required: t = !0, ...o } = e || {};
283
+ return t ? v(o) : z(o);
284
284
  }
285
- const C = (e, t) => {
286
- const { message: d, ...s } = t || {}, [n, i, ...u] = e.map((l) => o.literal(l)), r = d ? typeof d == "function" ? d(e) : d : a.VALUE_OUT_OF_RANGE(e);
287
- return o.union([n, i, ...u], {
288
- message: r,
289
- ...s
290
- }).nullable().refine(Boolean, a.NON_EMPTY()).default(null);
291
- }, k = (e, t) => C(e, t).optional();
292
- function j(e, t) {
293
- const { required: d, ...s } = t || {};
294
- return d ? C(e, s) : k(e, s);
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
+ }).nullable().refine(Boolean, r.NON_EMPTY()).default(null);
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 R = /^(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: d = R } = e || {}, s = c.isString(d) ? new RegExp(d) : d;
298
- return D().min(1, (t == null ? void 0 : t.min) || a.NON_EMPTY()).regex(s, (t == null ? void 0 : t.invalid) || a.INVALID_URL()).default("");
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: d = R } = e || {}, s = c.isString(d) ? new RegExp(d) : d;
301
- return D().refine((n) => c.isStringEmpty(n) ? !0 : s.test(n), (t == null ? void 0 : t.invalid) || a.INVALID_URL()).optional().transform((n) => n != null && n.length ? n : void 0);
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: w,
310
- getSelectSchema: v,
311
- getNumberSchema: G,
312
- getPhoneSchema: x,
313
- getDateSchema: H,
314
- getUnionSchema: j,
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, d) {
349
- const { fillArrayWithValue: s } = d || {};
350
- if (t instanceof o.ZodEffects)
351
- return t.innerType() instanceof o.ZodEffects ? this.getZodDefaults(t.innerType(), d) : this.getZodDefaults(o.ZodObject.create(t.innerType().shape), d);
352
- const n = (r) => {
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
+ const n = (a) => {
353
353
  switch (!0) {
354
- case r instanceof o.ZodDefault:
355
- return r._def.defaultValue();
356
- case r instanceof o.ZodOptional:
354
+ case (a._def.typeName === "ZodDefault" || a instanceof s.ZodDefault):
355
+ return a._def.defaultValue();
356
+ case (a._def.typeName === "ZodOptional" || a instanceof s.ZodOptional):
357
357
  return;
358
- case r instanceof o.ZodNullable:
358
+ case (a._def.typeName === "ZodNullable" || a instanceof s.ZodNullable):
359
359
  return null;
360
- case r instanceof o.ZodArray:
361
- return s ? [n(r.element)] : [];
362
- case r instanceof o.ZodObject:
363
- return this.getZodDefaults(r, d);
364
- case r instanceof o.ZodUnion:
365
- return n(r._def.options[0]);
366
- case r instanceof o.ZodLiteral:
367
- return r._def.value;
368
- case r instanceof o.ZodDiscriminatedUnion:
369
- return n(r._def.options[0]);
370
- case r instanceof o.ZodEnum:
371
- return r._def.values[0];
372
- case r instanceof o.ZodString:
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
+ return n(a._def.options[0]);
366
+ case (a._def.typeName === "ZodLiteral" || a instanceof s.ZodLiteral):
367
+ return a._def.value;
368
+ case (a._def.typeName === "ZodDiscriminatedUnion" || a instanceof s.ZodDiscriminatedUnion):
369
+ return n(a._def.options[0]);
370
+ case (a._def.typeName === "ZodEnum" || a instanceof s.ZodEnum):
371
+ return a._def.values[0];
372
+ case (a._def.typeName === "ZodString" || a instanceof s.ZodString):
373
373
  return "";
374
- case r instanceof o.ZodNumber:
374
+ case (a._def.typeName === "ZodNumber" || a instanceof s.ZodNumber):
375
375
  return 0;
376
- case r instanceof o.ZodBoolean:
376
+ case (a._def.typeName === "ZodBoolean" || a instanceof s.ZodBoolean):
377
377
  return !1;
378
- case !("innerType" in r._def):
378
+ case !("innerType" in a._def):
379
379
  return;
380
380
  default:
381
- return n(r._def.innerType);
381
+ return n(a._def.innerType);
382
382
  }
383
383
  }, i = {};
384
- return Object.entries(t.shape).map(([r, l]) => {
385
- i[r] = n(l);
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 g = {
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
- }, m = {
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, d, ...s] = e.trim().replace(/\s+/g, " ").split(" "), n = s.join(" ");
403
- return { surname: t, name: d, patronymic: n };
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: d, invalidSurname: s, invalidPatronymic: n, invalidName: i } = t || {};
406
- return o.string().superRefine((u, r) => {
407
- const { name: l, surname: E, patronymic: _ } = ee(u);
408
- m.ONLY_CYRILLIC.test(u) || r.addIssue({
409
- code: o.ZodIssueCode.invalid_string,
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: g.ONLY_CYRILLIC()
412
- }), (!l || !E) && r.addIssue({
413
- code: o.ZodIssueCode.invalid_string,
442
+ message: m.ONLY_CYRILLIC()
443
+ }), (!l || !f) && a.addIssue({
444
+ code: s.ZodIssueCode.invalid_string,
414
445
  validation: "regex",
415
- message: d || g.NAME_OR_SURNAME_NON_EMPTY()
416
- }), m.CHECK_HYPHEN.test(l) || r.addIssue({
417
- code: o.ZodIssueCode.invalid_string,
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 || g.INVALID_NAME()
420
- }), m.CHECK_HYPHEN.test(E) || r.addIssue({
421
- code: o.ZodIssueCode.invalid_string,
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: s || g.INVALID_SURNAME()
424
- }), _ && (m.PATRONYMIC.test(_) || r.addIssue({
425
- code: o.ZodIssueCode.invalid_string,
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 || g.INVALID_PATRONYMIC()
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, ...d } = e || {};
433
- return t ? S(d) : te(d);
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
- h as RgxPatronymic,
444
- Z as RgxUnicode,
445
- I as VALIDATION_MESSAGES,
474
+ y as RgxPatronymic,
475
+ R as RgxUnicode,
476
+ E as VALIDATION_MESSAGES,
446
477
  ce as ZodUtils,
447
- a as baseDefaultMessages,
478
+ r as baseDefaultMessages,
448
479
  J as baseValidationSchemas,
449
480
  P as formattedDadataFio,
450
- re as zodCalendarValidate,
451
- oe as zodDadataFioSchema,
481
+ ae as zodCalendarValidate,
482
+ se as zodDadataFioSchema,
452
483
  ue as zodOtpCodeSchema,
453
- ae as zodPhoneSchema,
484
+ re as zodPhoneSchema,
454
485
  le as zodValidators
455
486
  };
456
487
  //# sourceMappingURL=validation.js.map