@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.
@@ -1,6 +1,6 @@
1
- import { z as o, p as I, i as f, D as L } from "./utils-DnWHDMk6.js";
2
- import { T } from "./typeGuards-yOWv7RXH.js";
3
- const C = /^[\u0400-\u04FF\u00CB\u00EB -]+$/, g = /^(?:[^-]+(?:-[^-]+){0,4}|[^-]+)$/, R = /^[a-zA-Zа-яА-ЯёЁ]+(?:\s*-\s*[a-zA-Zа-яА-ЯёЁ]+){0,4}(?:\s+[a-zA-Zа-яА-ЯёЁ]+(?:\s*-\s*[a-zA-Zа-яА-ЯёЁ]+){0,4})?$/i, l = {
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
- }, Z = (e) => {
16
- const t = e.trim().replace(/\s+/g, " ").split(" "), [s, n, ...i] = t, a = i == null ? void 0 : i.join(" ");
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: s,
19
- name: n,
20
- patronymic: a
18
+ surname: a,
19
+ name: s,
20
+ patronymic: n
21
21
  };
22
- }, ee = o.string({ invalid_type_error: "Обязательно к заполнению", required_error: "Обязательно к заполнению" }).superRefine((e, t) => {
22
+ }, te = d.string({ invalid_type_error: "Обязательно к заполнению", required_error: "Обязательно к заполнению" }).superRefine((e, t) => {
23
23
  e === "" && t.addIssue({
24
- code: o.ZodIssueCode.custom,
24
+ code: d.ZodIssueCode.custom,
25
25
  message: "Введите имя и фамилию"
26
- }), C.test(e) || t.addIssue({
27
- code: o.ZodIssueCode.custom,
26
+ }), Z.test(e) || t.addIssue({
27
+ code: d.ZodIssueCode.custom,
28
28
  message: "Должна быть только кириллица"
29
29
  });
30
- const { surname: s, name: n, patronymic: i } = Z(e);
31
- (!s || !n) && t.addIssue({
32
- code: o.ZodIssueCode.custom,
30
+ const { surname: a, name: s, patronymic: i } = R(e);
31
+ (!a || !s) && t.addIssue({
32
+ code: d.ZodIssueCode.custom,
33
33
  message: "Введите имя и фамилию"
34
- }), g.test(n) || t.addIssue({
35
- code: o.ZodIssueCode.custom,
34
+ }), A.test(s) || t.addIssue({
35
+ code: d.ZodIssueCode.custom,
36
36
  message: "Неверно введено имя"
37
- }), g.test(s) || t.addIssue({
38
- code: o.ZodIssueCode.custom,
37
+ }), A.test(a) || t.addIssue({
38
+ code: d.ZodIssueCode.custom,
39
39
  message: "Неверно введена фамилия"
40
- }), i && (R.test(i) || t.addIssue({
41
- code: o.ZodIssueCode.custom,
40
+ }), i && (S.test(i) || t.addIssue({
41
+ code: d.ZodIssueCode.custom,
42
42
  message: "Неверно введено отчество"
43
43
  }));
44
- }), te = o.string().length(10, { message: l.INVALID_DATE }).superRefine((e, t) => {
45
- const [s, n, i] = (e == null ? void 0 : e.split(".")) ?? "", a = I(`${s}/${n}/${i}`, "dd/MM/yyyy", /* @__PURE__ */ new Date());
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: o.ZodIssueCode.custom,
48
- message: l.INVALID_DATE
49
- }), f(a) || t.addIssue({
50
- code: o.ZodIssueCode.custom,
51
- message: l.INVALID_DATE
52
- }), (/* @__PURE__ */ new Date()).getTime() < new Date(a).getTime() && t.addIssue({
53
- code: o.ZodIssueCode.custom,
54
- message: l.FUTURE_DATE_NOT_ALLOWED
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
- }), ne = o.string().superRefine((e, t) => {
57
- const s = e.charAt(0);
58
- ["3", "4", "5", "6", "9"].includes(s) || t.addIssue({
59
- code: o.ZodIssueCode.custom,
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: o.ZodIssueCode.custom,
62
+ code: d.ZodIssueCode.custom,
63
63
  message: "Введите номер телефона полностью"
64
64
  });
65
- }).transform((e) => `7${e}`), ie = o.coerce.number().min(1e3, `${l.FIX_LENGTH} 4`).max(9999, `${l.FIX_LENGTH} 4`).nullable().superRefine((e, t) => {
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: o.ZodIssueCode.invalid_type,
67
+ code: d.ZodIssueCode.invalid_type,
68
68
  expected: "number",
69
69
  received: "null",
70
- message: `${l.FIX_LENGTH} 4`
70
+ message: `${I.FIX_LENGTH} 4`
71
71
  });
72
- }).default(null), d = {
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: s = L, message: n } = e || {};
92
- return o.string().min(8, (n == null ? void 0 : n.min) || d.DATE_NON_EMPTY()).superRefine((i, a) => {
93
- const u = s.replace(/\W/g, "").length;
94
- if (i.replace(/[._-]/g, "").length < u && a.addIssue({
95
- code: o.ZodIssueCode.too_small,
96
- minimum: u,
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) || d.DATE_NON_EMPTY()
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(i).toISOString();
111
+ c = new Date(u);
103
112
  } catch {
104
- a.addIssue({
105
- code: o.ZodIssueCode.invalid_date,
106
- message: (n == null ? void 0 : n.invalidDate) || d.DATE_INVALID_FORMAT()
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
- else {
110
- const c = I(i, s, /* @__PURE__ */ new Date());
111
- f(c) || a.addIssue({
112
- code: o.ZodIssueCode.invalid_date,
113
- message: (n == null ? void 0 : n.invalidDate) || d.DATE_INVALID_FORMAT()
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: s = L, message: n } = e || {};
119
- return o.string().transform((i) => i || void 0).superRefine((i, a) => {
120
- if (T.isString(i) && i.length) {
121
- const u = s.replace(/\W/g, "").length;
122
- if (i.replace(/[._-]/g, "").length < u && a.addIssue({
123
- code: o.ZodIssueCode.too_small,
124
- minimum: u,
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) || d.DATE_NON_EMPTY()
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(i).toISOString();
153
+ c = new Date(u);
131
154
  } catch {
132
- a.addIssue({
133
- code: o.ZodIssueCode.invalid_date,
134
- message: (n == null ? void 0 : n.invalidDate) || d.DATE_INVALID_FORMAT()
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
- else {
138
- const c = I(i, s, /* @__PURE__ */ new Date());
139
- f(c) || a.addIssue({
140
- code: o.ZodIssueCode.invalid_date,
141
- message: (n == null ? void 0 : n.invalidDate) || d.DATE_INVALID_FORMAT()
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 S(e) {
183
+ function V(e) {
148
184
  const { required: t = !0 } = e || {};
149
185
  return t ? h(e) : P(e);
150
186
  }
151
- const A = /^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/g, V = (e) => {
152
- const { message: t, regexp: s = A } = e || {};
153
- return o.string().min(1, (t == null ? void 0 : t.min) || d.EMAIL_NON_EMPTY()).regex(s, (t == null ? void 0 : t.invalid) || d.EMAIL_INVALID()).default("");
154
- }, H = (e) => {
155
- const { message: t, regexp: s = A } = e || {};
156
- return o.string().refine(
157
- (n) => T.isStringEmpty(n) ? !0 : s.test(n),
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) || d.EMAIL_INVALID()
195
+ message: (t == null ? void 0 : t.invalid) || r.EMAIL_INVALID()
160
196
  }
161
- ).optional().transform((n) => (n == null ? void 0 : n.length) === 0 ? void 0 : n);
197
+ ).optional().transform((s) => (s == null ? void 0 : s.length) === 0 ? void 0 : s);
162
198
  };
163
- function y(e) {
199
+ function Y(e) {
164
200
  const { required: t = !0 } = e || {};
165
- return t ? V(e) : H(e);
201
+ return t ? H(e) : y(e);
166
202
  }
167
203
  const M = (e) => {
168
- const { min: t = 0, max: s, message: n } = e || {};
169
- let i = o.coerce.number().min(t, (n == null ? void 0 : n.min) || d.MIN_VALUE(t));
170
- return s && (i = i.max(s, (n == null ? void 0 : n.min) || d.MAX_VALUE(s))), i.default(0);
171
- }, Y = (e) => M(e).optional().transform((t) => t || void 0);
172
- function F(e) {
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) : Y(e);
210
+ return t ? M(e) : F(e);
175
211
  }
176
- const U = (e) => {
177
- const { ignoreMask: t = !0, maskSymbols: s = /[()+_ -]/g, message: n } = e || {};
178
- let i = o.string().superRefine((a, u) => {
179
- const r = a.replace(s, ""), c = r.charAt(1);
180
- ["3", "4", "5", "6", "7", "9"].includes(c) || u.addIssue({
181
- code: o.ZodIssueCode.invalid_string,
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: (n == null ? void 0 : n.invalidOperator) || d.PHONE_INVALID_OPERATOR()
184
- }), r.length < 11 && u.addIssue({
185
- code: o.ZodIssueCode.too_small,
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: (n == null ? void 0 : n.min) || d.PHONE_NON_EMPTY()
225
+ message: (s == null ? void 0 : s.min) || r.PHONE_NON_EMPTY()
190
226
  });
191
227
  });
192
- return t && (i = i.transform((a) => a.replace(s, ""))), i.default("");
193
- }, G = (e) => {
194
- const { ignoreMask: t = !0, maskSymbols: s = /[()+_ -]/g, message: n } = e || {};
195
- let i = o.string().superRefine((a, u) => {
196
- const r = a.replace(s, ""), c = r.charAt(1);
197
- ["3", "4", "5", "6", "7", "9"].includes(c) || u.addIssue({
198
- code: o.ZodIssueCode.invalid_string,
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: (n == null ? void 0 : n.invalidOperator) || d.PHONE_INVALID_OPERATOR()
201
- }), r.length < 11 && u.addIssue({
202
- code: o.ZodIssueCode.too_small,
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: (n == null ? void 0 : n.min) || d.PHONE_NON_EMPTY()
242
+ message: (s == null ? void 0 : s.min) || r.PHONE_NON_EMPTY()
207
243
  });
208
244
  });
209
- return t && (i = i.transform((a) => a.replace(s, ""))), i.transform((a) => a || void 0);
245
+ return t && (i = i.transform((n) => n.replace(a, ""))), i.transform((n) => n || void 0);
210
246
  };
211
- function b(e) {
247
+ function $(e) {
212
248
  const { required: t = !0 } = e || {};
213
- return t ? U(e) : G(e);
249
+ return t ? G(e) : X(e);
214
250
  }
215
- const $ = (e) => {
216
- var n, i;
217
- const { message: t } = e || {}, s = o.string().min(1, (t == null ? void 0 : t.single) || d.SELECT_NON_EMPTY()).nullable().refine((a) => !!a, (t == null ? void 0 : t.single) || d.SELECT_NON_EMPTY()).default(null);
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 a = o.array(s).min((e == null ? void 0 : e.minLength) || 0, (t == null ? void 0 : t.multiple) || d.SELECT_MULTIPLE_MIN_LENGTH((e == null ? void 0 : e.minLength) || 0));
220
- return e != null && e.length ? a.length(e.length, ((n = e.message) == null ? void 0 : n.length) || d.SELECT_FIX_LENGTH(e.length)).default([]) : (e != null && e.maxLength && (a = a.max(
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) || d.SELECT_MULTIPLE_MAX_LENGTH(e.maxLength)
223
- )), a.default([]));
258
+ ((i = e.message) == null ? void 0 : i.maxLength) || r.SELECT_MULTIPLE_MAX_LENGTH(e.maxLength)
259
+ )), n.default([]));
224
260
  }
225
- return s;
261
+ return a;
226
262
  };
227
- function X(e) {
228
- const t = o.string().nullable().optional();
229
- return e != null && e.multiple ? o.array(t).optional() : t;
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 q(e) {
267
+ function v(e) {
232
268
  const { required: t = !0 } = e || {};
233
- return t ? $(e) : X(e);
269
+ return t ? b(e) : w(e);
234
270
  }
235
- const x = (e) => {
236
- const { min: t = 1, max: s, length: n, message: i } = e || {};
237
- let a = o.string({ message: i == null ? void 0 : i.root }).min(t, { message: (i == null ? void 0 : i.min) || d.MIN_LENGTH(t) });
238
- return s && (a = a.max(s, { message: (i == null ? void 0 : i.max) || d.MAX_LENGTH(s) })), n && (a = a.length(n, { message: (i == null ? void 0 : i.length) || d.FIX_LENGTH(n) })), a.refine((u) => !!u.length, { message: (i == null ? void 0 : i.min) || d.NON_EMPTY() }).default("");
239
- }, v = (e) => {
240
- const { min: t, max: s, length: n, message: i } = e || {};
241
- let a = o.string({ message: i == null ? void 0 : i.root });
242
- return t && (a = a.min(t, { message: (i == null ? void 0 : i.min) || d.MIN_LENGTH(t) })), s && (a = a.max(s, { message: (i == null ? void 0 : i.max) || d.MAX_LENGTH(s) })), n && (a = a.length(n, { message: (i == null ? void 0 : i.length) || d.FIX_LENGTH(n) })), a.optional().transform((u) => u != null && u.length ? u : void 0);
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 w(e) {
245
- const { required: t = !0, ...s } = e || {};
246
- return t ? x(s) : v(s);
280
+ function B(e) {
281
+ const { required: t = !0, ...a } = e || {};
282
+ return t ? q(a) : z(a);
247
283
  }
248
- const O = (e, t) => {
249
- const { message: s, ...n } = t || {}, [i, a, ...u] = e.map((c) => o.literal(c)), r = s ? typeof s == "function" ? s(e) : s : d.VALUE_OUT_OF_RANGE(e);
250
- return o.union([i, a, ...u], {
251
- message: r,
252
- ...n
253
- }).nullable().refine(Boolean, d.NON_EMPTY()).default(null);
254
- }, z = (e, t) => O(e, t).optional();
255
- function B(e, t) {
256
- const { required: s, ...n } = t || {};
257
- return s ? O(e, n) : z(e, n);
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 j = {
260
- getStringSchema: w,
261
- getEmailSchema: y,
262
- getSelectSchema: q,
263
- getNumberSchema: F,
264
- getPhoneSchema: b,
265
- getDateSchema: S,
266
- getUnionSchema: B
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 se {
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, s) {
300
- const { fillArrayWithValue: n } = s || {};
301
- if (t instanceof o.ZodEffects)
302
- return t.innerType() instanceof o.ZodEffects ? this.getZodDefaults(t.innerType(), s) : this.getZodDefaults(o.ZodObject.create(t.innerType().shape), s);
303
- const i = (r) => {
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 r instanceof o.ZodDefault:
306
- return r._def.defaultValue();
307
- case r instanceof o.ZodOptional:
341
+ case o instanceof d.ZodDefault:
342
+ return o._def.defaultValue();
343
+ case o instanceof d.ZodOptional:
308
344
  return;
309
- case r instanceof o.ZodNullable:
345
+ case o instanceof d.ZodNullable:
310
346
  return null;
311
- case r instanceof o.ZodArray:
312
- return n ? [i(r.element)] : [];
313
- case r instanceof o.ZodObject:
314
- return this.getZodDefaults(r, s);
315
- case r instanceof o.ZodUnion:
316
- return i(r._def.options[0]);
317
- case r instanceof o.ZodLiteral:
318
- return r._def.value;
319
- case r instanceof o.ZodEnum:
320
- return r._def.values[0];
321
- case r instanceof o.ZodString:
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 r instanceof o.ZodNumber:
359
+ case o instanceof d.ZodNumber:
324
360
  return 0;
325
- case r instanceof o.ZodBoolean:
361
+ case o instanceof d.ZodBoolean:
326
362
  return !1;
327
- case !("innerType" in r._def):
363
+ case !("innerType" in o._def):
328
364
  return;
329
365
  default:
330
- return i(r._def.innerType);
366
+ return i(o._def.innerType);
331
367
  }
332
- }, a = {};
333
- return Object.entries(t.shape).map(([r, c]) => {
334
- a[r] = i(c);
335
- }), a;
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
- }, E = {
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
- }, W = (e) => {
351
- const [t, s, ...n] = e.trim().replace(/\s+/g, " ").split(" "), i = n.join(" ");
352
- return { surname: t, name: s, patronymic: i };
353
- }, D = (e) => {
354
- const { message: t } = e || {}, { nameOrSurnameEmpty: s, invalidSurname: n, invalidPatronymic: i, invalidName: a } = t || {};
355
- return o.string().superRefine((u, r) => {
356
- const { name: c, surname: N, patronymic: m } = W(u);
357
- E.ONLY_CYRILLIC.test(u) || r.addIssue({
358
- code: o.ZodIssueCode.invalid_string,
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: _.ONLY_CYRILLIC()
361
- }), (!c || !N) && r.addIssue({
362
- code: o.ZodIssueCode.invalid_string,
396
+ message: E.ONLY_CYRILLIC()
397
+ }), (!l || !m) && o.addIssue({
398
+ code: d.ZodIssueCode.invalid_string,
363
399
  validation: "regex",
364
- message: s || _.NAME_OR_SURNAME_NON_EMPTY()
365
- }), E.CHECK_HYPHEN.test(c) || r.addIssue({
366
- code: o.ZodIssueCode.invalid_string,
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: a || _.INVALID_NAME()
369
- }), E.CHECK_HYPHEN.test(N) || r.addIssue({
370
- code: o.ZodIssueCode.invalid_string,
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: n || _.INVALID_SURNAME()
373
- }), m && (E.PATRONYMIC.test(m) || r.addIssue({
374
- code: o.ZodIssueCode.invalid_string,
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 || _.INVALID_PATRONYMIC()
412
+ message: i || E.INVALID_PATRONYMIC()
377
413
  }));
378
414
  }).transform((u) => u.trimEnd()).default("");
379
- }, k = (e) => D(e).optional().transform((t) => t != null && t.length ? t : void 0);
380
- function K(e) {
381
- const { required: t = !0, ...s } = e || {};
382
- return t ? D(s) : k(s);
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 Q = {
385
- getFioSchema: K
386
- }, oe = {
387
- base: j,
388
- dadata: Q
420
+ const J = {
421
+ getFioSchema: Q
422
+ }, ae = {
423
+ base: W,
424
+ dadata: J
389
425
  };
390
426
  export {
391
- g as RgxCheckForHyphen,
392
- R as RgxPatronymic,
393
- C as RgxUnicode,
394
- l as VALIDATION_MESSAGES,
395
- se as ZodUtils,
396
- d as baseDefaultMessages,
397
- j as baseValidationSchemas,
398
- Z as formattedDadataFio,
399
- te as zodCalendarValidate,
400
- ee as zodDadataFioSchema,
401
- ie as zodOtpCodeSchema,
402
- ne as zodPhoneSchema,
403
- oe as zodValidators
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