@scbt-ecom/ui 0.51.1 → 0.51.3
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/ui.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { j as p, c as We, R as Ye, B as E, u as Je, f as Qe, g as Ze, h as et, i as k, k as Re, l as tt, m as nt, n as U, o as ot, A as rt, H as it, I as N, p as lt, q as me, D as ut, V as st, O as at } from "./index-
|
|
2
|
-
import { d as Un, r as Kn, e as Xn, C as Wn, s as Yn, K as Jn, L as Qn, N as Zn, P as eo, a as to, S as no, U as oo, b as ro, t as io } from "./index-
|
|
1
|
+
import { j as p, c as We, R as Ye, B as E, u as Je, f as Qe, g as Ze, h as et, i as k, k as Re, l as tt, m as nt, n as U, o as ot, A as rt, H as it, I as N, p as lt, q as me, D as ut, V as st, O as at } from "./index-vcD48ARm.js";
|
|
2
|
+
import { d as Un, r as Kn, e as Xn, C as Wn, s as Yn, K as Jn, L as Qn, N as Zn, P as eo, a as to, S as no, U as oo, b as ro, t as io } from "./index-vcD48ARm.js";
|
|
3
3
|
import * as P from "react";
|
|
4
4
|
import { forwardRef as D, useState as he, useEffect as gt } from "react";
|
|
5
5
|
import { c as w, T as Se } from "./typeGuards-BigW-JS1.js";
|
package/dist/validation.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { z as s, p as
|
|
2
|
-
import { T as
|
|
1
|
+
import { z as s, p as g, i as N, f as T, D as L, s as D } from "./utils-Od0KoTas.js";
|
|
2
|
+
import { T as _ } from "./typeGuards-BigW-JS1.js";
|
|
3
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: "Минимальная длина символов должна быть не менее",
|
|
@@ -41,8 +41,8 @@ const R = /^[\u0400-\u04FF\u00CB\u00EB -]+$/, A = /^(?:[^-]+(?:-[^-]+){0,4}|[^-]
|
|
|
41
41
|
code: s.ZodIssueCode.custom,
|
|
42
42
|
message: "Неверно введено отчество"
|
|
43
43
|
}));
|
|
44
|
-
}),
|
|
45
|
-
const [o, d, n] = (e == null ? void 0 : e.split(".")) ?? "", i =
|
|
44
|
+
}), re = s.string().length(10, { message: E.INVALID_DATE }).superRefine((e, t) => {
|
|
45
|
+
const [o, d, n] = (e == null ? void 0 : e.split(".")) ?? "", i = g(`${o}/${d}/${n}`, "dd/MM/yyyy", /* @__PURE__ */ new Date());
|
|
46
46
|
+n <= 1950 && t.addIssue({
|
|
47
47
|
code: s.ZodIssueCode.custom,
|
|
48
48
|
message: E.INVALID_DATE
|
|
@@ -53,7 +53,7 @@ const R = /^[\u0400-\u04FF\u00CB\u00EB -]+$/, A = /^(?:[^-]+(?:-[^-]+){0,4}|[^-]
|
|
|
53
53
|
code: s.ZodIssueCode.custom,
|
|
54
54
|
message: E.FUTURE_DATE_NOT_ALLOWED
|
|
55
55
|
});
|
|
56
|
-
}),
|
|
56
|
+
}), ae = s.string().superRefine((e, t) => {
|
|
57
57
|
const o = e.charAt(0);
|
|
58
58
|
["3", "4", "5", "6", "9"].includes(o) || t.addIssue({
|
|
59
59
|
code: s.ZodIssueCode.custom,
|
|
@@ -69,7 +69,7 @@ const R = /^[\u0400-\u04FF\u00CB\u00EB -]+$/, A = /^(?:[^-]+(?:-[^-]+){0,4}|[^-]
|
|
|
69
69
|
received: "null",
|
|
70
70
|
message: `${E.FIX_LENGTH} 4`
|
|
71
71
|
});
|
|
72
|
-
}).default(null),
|
|
72
|
+
}).default(null), a = {
|
|
73
73
|
NON_EMPTY: () => "Поле не может быть пустым",
|
|
74
74
|
MIN_LENGTH: (e) => `Поле должно содержать минимум символов: ${e}`,
|
|
75
75
|
MAX_LENGTH: (e) => `Поле должно содержать максимум символов: ${e}`,
|
|
@@ -88,94 +88,94 @@ const R = /^[\u0400-\u04FF\u00CB\u00EB -]+$/, A = /^(?:[^-]+(?:-[^-]+){0,4}|[^-]
|
|
|
88
88
|
DATE_NON_EMPTY: () => "Укажите дату",
|
|
89
89
|
VALUE_OUT_OF_RANGE: (e) => `Выберите один из вариантов ${e.join(", ")}`,
|
|
90
90
|
DATE_MIN: (e) => {
|
|
91
|
-
const t =
|
|
91
|
+
const t = _.isString(e) ? new Date(e) : e;
|
|
92
92
|
return `Выбранная дата должна быть не раньше ${T(t)}`;
|
|
93
93
|
},
|
|
94
94
|
DATE_MAX: (e) => {
|
|
95
|
-
const t =
|
|
95
|
+
const t = _.isString(e) ? new Date(e) : e;
|
|
96
96
|
return `Выбранная дата должна быть не позже ${T(t)}`;
|
|
97
97
|
},
|
|
98
98
|
INVALID_URL: () => "Ссылка введена некорректно. Пример: https://example.com, example.com"
|
|
99
|
-
},
|
|
99
|
+
}, V = (e) => {
|
|
100
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) ||
|
|
102
|
-
const
|
|
103
|
-
if (u.replace(/[._-]/g, "").length <
|
|
101
|
+
return s.string().min(8, (i == null ? void 0 : i.min) || a.DATE_NON_EMPTY()).superRefine((u, c) => {
|
|
102
|
+
const r = o.replace(/\W/g, "").length;
|
|
103
|
+
if (u.replace(/[._-]/g, "").length < r && c.addIssue({
|
|
104
104
|
code: s.ZodIssueCode.too_small,
|
|
105
|
-
minimum:
|
|
105
|
+
minimum: r,
|
|
106
106
|
type: "date",
|
|
107
107
|
inclusive: !0,
|
|
108
|
-
message: (i == null ? void 0 : i.min) ||
|
|
108
|
+
message: (i == null ? void 0 : i.min) || a.DATE_NON_EMPTY()
|
|
109
109
|
}), t) {
|
|
110
|
-
let
|
|
110
|
+
let f = null;
|
|
111
111
|
try {
|
|
112
|
-
|
|
112
|
+
f = new Date(u);
|
|
113
113
|
} catch {
|
|
114
|
-
|
|
114
|
+
c.addIssue({
|
|
115
115
|
code: s.ZodIssueCode.invalid_date,
|
|
116
|
-
message: (i == null ? void 0 : i.invalidDate) ||
|
|
116
|
+
message: (i == null ? void 0 : i.invalidDate) || a.DATE_INVALID_FORMAT()
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
d &&
|
|
119
|
+
d && f.getTime() < (_.isString(d) ? new Date(d).getTime() : d.getTime()) && c.addIssue({
|
|
120
120
|
code: s.ZodIssueCode.invalid_date,
|
|
121
|
-
message: (i == null ? void 0 : i.min) ||
|
|
122
|
-
}), n &&
|
|
121
|
+
message: (i == null ? void 0 : i.min) || a.DATE_MIN(d)
|
|
122
|
+
}), n && f.getTime() > (_.isString(n) ? new Date(n).getTime() : n.getTime()) && c.addIssue({
|
|
123
123
|
code: s.ZodIssueCode.invalid_date,
|
|
124
|
-
message: (i == null ? void 0 : i.max) ||
|
|
124
|
+
message: (i == null ? void 0 : i.max) || a.DATE_MAX(n)
|
|
125
125
|
});
|
|
126
126
|
} else {
|
|
127
|
-
const
|
|
128
|
-
N(
|
|
127
|
+
const f = g(u, o, /* @__PURE__ */ new Date());
|
|
128
|
+
N(f) || c.addIssue({
|
|
129
129
|
code: s.ZodIssueCode.invalid_date,
|
|
130
|
-
message: (i == null ? void 0 : i.invalidDate) ||
|
|
131
|
-
}), d &&
|
|
130
|
+
message: (i == null ? void 0 : i.invalidDate) || a.DATE_INVALID_FORMAT()
|
|
131
|
+
}), d && f.getTime() < (_.isString(d) ? new Date(d).getTime() : d.getTime()) && c.addIssue({
|
|
132
132
|
code: s.ZodIssueCode.invalid_date,
|
|
133
|
-
message: (i == null ? void 0 : i.min) ||
|
|
134
|
-
}), n &&
|
|
133
|
+
message: (i == null ? void 0 : i.min) || a.DATE_MIN(d)
|
|
134
|
+
}), n && f.getTime() > (_.isString(n) ? new Date(n).getTime() : n.getTime()) && c.addIssue({
|
|
135
135
|
code: s.ZodIssueCode.invalid_date,
|
|
136
|
-
message: (i == null ? void 0 : i.max) ||
|
|
136
|
+
message: (i == null ? void 0 : i.max) || a.DATE_MAX(n)
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
}).default("");
|
|
140
|
-
},
|
|
140
|
+
}, h = (e) => {
|
|
141
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,
|
|
143
|
-
if (
|
|
144
|
-
const
|
|
145
|
-
if (u.replace(/[._-]/g, "").length <
|
|
142
|
+
return s.string().transform((u) => u || void 0).superRefine((u, c) => {
|
|
143
|
+
if (_.isString(u) && u.length) {
|
|
144
|
+
const r = o.replace(/\W/g, "").length;
|
|
145
|
+
if (u.replace(/[._-]/g, "").length < r && c.addIssue({
|
|
146
146
|
code: s.ZodIssueCode.too_small,
|
|
147
|
-
minimum:
|
|
147
|
+
minimum: r,
|
|
148
148
|
type: "date",
|
|
149
149
|
inclusive: !0,
|
|
150
|
-
message: (i == null ? void 0 : i.min) ||
|
|
150
|
+
message: (i == null ? void 0 : i.min) || a.DATE_NON_EMPTY()
|
|
151
151
|
}), t) {
|
|
152
|
-
let
|
|
152
|
+
let f = null;
|
|
153
153
|
try {
|
|
154
|
-
|
|
154
|
+
f = new Date(u);
|
|
155
155
|
} catch {
|
|
156
|
-
|
|
156
|
+
c.addIssue({
|
|
157
157
|
code: s.ZodIssueCode.invalid_date,
|
|
158
|
-
message: (i == null ? void 0 : i.invalidDate) ||
|
|
158
|
+
message: (i == null ? void 0 : i.invalidDate) || a.DATE_INVALID_FORMAT()
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
-
d &&
|
|
161
|
+
d && f.getTime() < (_.isString(d) ? new Date(d).getTime() : d.getTime()) && c.addIssue({
|
|
162
162
|
code: s.ZodIssueCode.invalid_date,
|
|
163
|
-
message: (i == null ? void 0 : i.min) ||
|
|
164
|
-
}), n &&
|
|
163
|
+
message: (i == null ? void 0 : i.min) || a.DATE_MIN(d)
|
|
164
|
+
}), n && f.getTime() > (_.isString(n) ? new Date(n).getTime() : n.getTime()) && c.addIssue({
|
|
165
165
|
code: s.ZodIssueCode.invalid_date,
|
|
166
|
-
message: (i == null ? void 0 : i.max) ||
|
|
166
|
+
message: (i == null ? void 0 : i.max) || a.DATE_MAX(n)
|
|
167
167
|
});
|
|
168
168
|
} else {
|
|
169
|
-
const
|
|
170
|
-
N(
|
|
169
|
+
const f = g(u, o, /* @__PURE__ */ new Date());
|
|
170
|
+
N(f) || c.addIssue({
|
|
171
171
|
code: s.ZodIssueCode.invalid_date,
|
|
172
|
-
message: (i == null ? void 0 : i.invalidDate) ||
|
|
173
|
-
}), d &&
|
|
172
|
+
message: (i == null ? void 0 : i.invalidDate) || a.DATE_INVALID_FORMAT()
|
|
173
|
+
}), d && f.getTime() < (_.isString(d) ? new Date(d).getTime() : d.getTime()) && c.addIssue({
|
|
174
174
|
code: s.ZodIssueCode.invalid_date,
|
|
175
|
-
message: (i == null ? void 0 : i.min) ||
|
|
176
|
-
}), n &&
|
|
175
|
+
message: (i == null ? void 0 : i.min) || a.DATE_MIN(d)
|
|
176
|
+
}), n && f.getTime() > (_.isString(n) ? new Date(n).getTime() : n.getTime()) && c.addIssue({
|
|
177
177
|
code: s.ZodIssueCode.invalid_date,
|
|
178
|
-
message: (i == null ? void 0 : i.max) ||
|
|
178
|
+
message: (i == null ? void 0 : i.max) || a.DATE_MAX(n)
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
181
|
}
|
|
@@ -183,80 +183,80 @@ const R = /^[\u0400-\u04FF\u00CB\u00EB -]+$/, A = /^(?:[^-]+(?:-[^-]+){0,4}|[^-]
|
|
|
183
183
|
};
|
|
184
184
|
function U(e) {
|
|
185
185
|
const { required: t = !0 } = e || {};
|
|
186
|
-
return t ?
|
|
186
|
+
return t ? V(e) : h(e);
|
|
187
187
|
}
|
|
188
|
-
const
|
|
189
|
-
const { message: t, regexp: o =
|
|
190
|
-
return s.string().min(1, (t == null ? void 0 : t.min) ||
|
|
191
|
-
},
|
|
192
|
-
const { message: t, regexp: o =
|
|
188
|
+
const Z = /^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/g, H = (e) => {
|
|
189
|
+
const { message: t, regexp: o = Z } = e || {}, d = _.isString(o) ? new RegExp(o) : o;
|
|
190
|
+
return s.string().min(1, (t == null ? void 0 : t.min) || a.EMAIL_NON_EMPTY()).regex(d, (t == null ? void 0 : t.invalid) || a.EMAIL_INVALID()).default("");
|
|
191
|
+
}, p = (e) => {
|
|
192
|
+
const { message: t, regexp: o = Z } = e || {}, d = _.isString(o) ? new RegExp(o) : o;
|
|
193
193
|
return s.string().refine(
|
|
194
|
-
(n) =>
|
|
194
|
+
(n) => _.isStringEmpty(n) ? !0 : d.test(n),
|
|
195
195
|
{
|
|
196
|
-
message: (t == null ? void 0 : t.invalid) ||
|
|
196
|
+
message: (t == null ? void 0 : t.invalid) || a.EMAIL_INVALID()
|
|
197
197
|
}
|
|
198
198
|
).optional().transform((n) => (n == null ? void 0 : n.length) === 0 ? void 0 : n);
|
|
199
199
|
};
|
|
200
|
-
function
|
|
200
|
+
function w(e) {
|
|
201
201
|
const { required: t = !0 } = e || {};
|
|
202
|
-
return t ? H(e) :
|
|
202
|
+
return t ? H(e) : p(e);
|
|
203
203
|
}
|
|
204
|
-
const
|
|
204
|
+
const M = (e) => {
|
|
205
205
|
const { min: t, max: o, message: d } = e || {};
|
|
206
206
|
let n = s.coerce.number();
|
|
207
|
-
return t && (n = n.min(t, (d == null ? void 0 : d.min) ||
|
|
208
|
-
},
|
|
209
|
-
function
|
|
207
|
+
return t && (n = n.min(t, (d == null ? void 0 : d.min) || a.MIN_VALUE(t))), o && (n = n.max(o, (d == null ? void 0 : d.min) || a.MAX_VALUE(o))), n.default(0);
|
|
208
|
+
}, Y = (e) => M(e).optional().transform((t) => t || void 0);
|
|
209
|
+
function b(e) {
|
|
210
210
|
const { required: t = !0 } = e || {};
|
|
211
|
-
return t ?
|
|
211
|
+
return t ? M(e) : Y(e);
|
|
212
212
|
}
|
|
213
|
-
const
|
|
214
|
-
const { ignoreMask: t = !0, maskSymbols: o = /[()+_ -]/g, message: d } = e || {}, n =
|
|
215
|
-
let i = s.string().superRefine((u,
|
|
216
|
-
const
|
|
217
|
-
["3", "4", "5", "6", "7", "9"].includes(
|
|
213
|
+
const F = (e) => {
|
|
214
|
+
const { ignoreMask: t = !0, maskSymbols: o = /[()+_ -]/g, message: d } = e || {}, n = _.isString(o) ? new RegExp(o) : o;
|
|
215
|
+
let i = s.string().superRefine((u, c) => {
|
|
216
|
+
const r = u.replace(n, ""), l = r.charAt(1);
|
|
217
|
+
["3", "4", "5", "6", "7", "9"].includes(l) || c.addIssue({
|
|
218
218
|
code: s.ZodIssueCode.invalid_string,
|
|
219
219
|
validation: "regex",
|
|
220
|
-
message: (d == null ? void 0 : d.invalidOperator) ||
|
|
221
|
-
}),
|
|
220
|
+
message: (d == null ? void 0 : d.invalidOperator) || a.PHONE_INVALID_OPERATOR()
|
|
221
|
+
}), r.length < 11 && c.addIssue({
|
|
222
222
|
code: s.ZodIssueCode.too_small,
|
|
223
223
|
minimum: 11,
|
|
224
224
|
inclusive: !0,
|
|
225
225
|
type: "string",
|
|
226
|
-
message: (d == null ? void 0 : d.min) ||
|
|
226
|
+
message: (d == null ? void 0 : d.min) || a.PHONE_NON_EMPTY()
|
|
227
227
|
});
|
|
228
228
|
});
|
|
229
229
|
return t && (i = i.transform((u) => u.replace(n, ""))), i.default("");
|
|
230
|
-
},
|
|
231
|
-
const { ignoreMask: t = !0, maskSymbols: o = /[()+_ -]/g, message: d } = e || {}, n =
|
|
232
|
-
let i = s.string().superRefine((u,
|
|
233
|
-
const
|
|
234
|
-
["3", "4", "5", "6", "7", "9"].includes(
|
|
230
|
+
}, G = (e) => {
|
|
231
|
+
const { ignoreMask: t = !0, maskSymbols: o = /[()+_ -]/g, message: d } = e || {}, n = _.isString(o) ? new RegExp(o) : o;
|
|
232
|
+
let i = s.string().superRefine((u, c) => {
|
|
233
|
+
const r = u.replace(n, ""), l = r.charAt(1);
|
|
234
|
+
["3", "4", "5", "6", "7", "9"].includes(l) || c.addIssue({
|
|
235
235
|
code: s.ZodIssueCode.invalid_string,
|
|
236
236
|
validation: "regex",
|
|
237
|
-
message: (d == null ? void 0 : d.invalidOperator) ||
|
|
238
|
-
}),
|
|
237
|
+
message: (d == null ? void 0 : d.invalidOperator) || a.PHONE_INVALID_OPERATOR()
|
|
238
|
+
}), r.length < 11 && c.addIssue({
|
|
239
239
|
code: s.ZodIssueCode.too_small,
|
|
240
240
|
minimum: 11,
|
|
241
241
|
inclusive: !0,
|
|
242
242
|
type: "string",
|
|
243
|
-
message: (d == null ? void 0 : d.min) ||
|
|
243
|
+
message: (d == null ? void 0 : d.min) || a.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
248
|
function $(e) {
|
|
249
249
|
const { required: t = !0 } = e || {};
|
|
250
|
-
return t ?
|
|
250
|
+
return t ? F(e) : G(e);
|
|
251
251
|
}
|
|
252
252
|
const X = (e) => {
|
|
253
253
|
var d, n;
|
|
254
|
-
const { message: t } = e || {}, o = s.string().min(1, (t == null ? void 0 : t.single) ||
|
|
254
|
+
const { message: t } = e || {}, o = s.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);
|
|
255
255
|
if (e != null && e.multiple) {
|
|
256
|
-
let i = s.array(o).min((e == null ? void 0 : e.minLength) || 0, (t == null ? void 0 : t.multiple) ||
|
|
257
|
-
return e != null && e.length ? i.length(e.length, ((d = e.message) == null ? void 0 : d.length) ||
|
|
256
|
+
let i = s.array(o).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, ((d = e.message) == null ? void 0 : d.length) || a.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) ||
|
|
259
|
+
((n = e.message) == null ? void 0 : n.maxLength) || a.SELECT_MULTIPLE_MAX_LENGTH(e.maxLength)
|
|
260
260
|
)), i.default([]));
|
|
261
261
|
}
|
|
262
262
|
return o;
|
|
@@ -272,43 +272,43 @@ function q(e) {
|
|
|
272
272
|
const v = (e) => {
|
|
273
273
|
const { min: t, max: o, length: d, message: n } = e || {};
|
|
274
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) ||
|
|
275
|
+
return t && (i = i.min(t, { message: (n == null ? void 0 : n.min) || a.MIN_LENGTH(t) })), o && (i = i.max(o, { message: (n == null ? void 0 : n.max) || a.MAX_LENGTH(o) })), d && (i = i.length(d, { message: (n == null ? void 0 : n.length) || a.FIX_LENGTH(d) })), i.refine((u) => !!u.length, { message: (n == null ? void 0 : n.min) || a.NON_EMPTY() }).default("");
|
|
276
276
|
}, z = (e) => {
|
|
277
277
|
const { min: t, max: o, length: d, message: n } = e || {};
|
|
278
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) ||
|
|
279
|
+
return t && (i = i.min(t, { message: (n == null ? void 0 : n.min) || a.MIN_LENGTH(t) })), o && (i = i.max(o, { message: (n == null ? void 0 : n.max) || a.MAX_LENGTH(o) })), d && (i = i.length(d, { message: (n == null ? void 0 : n.length) || a.FIX_LENGTH(d) })), i.optional().transform((u) => u != null && u.length ? u : void 0);
|
|
280
280
|
};
|
|
281
|
-
function
|
|
281
|
+
function j(e) {
|
|
282
282
|
const { required: t = !0, ...o } = e || {};
|
|
283
283
|
return t ? v(o) : z(o);
|
|
284
284
|
}
|
|
285
285
|
const O = (e, t) => {
|
|
286
|
-
const { message: o, ...d } = t || {}, [n, i, ...u] = e.map((
|
|
286
|
+
const { message: o, ...d } = t || {}, [n, i, ...u] = e.map((r) => s.literal(r)), c = o ? typeof o == "function" ? o(e) : o : a.VALUE_OUT_OF_RANGE(e);
|
|
287
287
|
return s.union([n, i, ...u], {
|
|
288
|
-
message:
|
|
288
|
+
message: c,
|
|
289
289
|
...d
|
|
290
|
-
}).nullable().refine(Boolean,
|
|
291
|
-
},
|
|
290
|
+
}).nullable().refine(Boolean, a.NON_EMPTY()).default(null);
|
|
291
|
+
}, B = (e, t) => O(e, t).optional();
|
|
292
292
|
function k(e, t) {
|
|
293
293
|
const { required: o, ...d } = t || {};
|
|
294
|
-
return o ? O(e, d) :
|
|
294
|
+
return o ? O(e, d) : B(e, d);
|
|
295
295
|
}
|
|
296
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 =
|
|
298
|
-
return D().min(1, (t == null ? void 0 : t.min) ||
|
|
297
|
+
const { message: t, regexp: o = C } = e || {}, d = _.isString(o) ? new RegExp(o) : o;
|
|
298
|
+
return D().min(1, (t == null ? void 0 : t.min) || a.NON_EMPTY()).regex(d, (t == null ? void 0 : t.invalid) || a.INVALID_URL()).default("");
|
|
299
299
|
}, K = (e) => {
|
|
300
|
-
const { message: t, regexp: o = C } = e || {}, d =
|
|
301
|
-
return D().refine((n) =>
|
|
300
|
+
const { message: t, regexp: o = C } = e || {}, d = _.isString(o) ? new RegExp(o) : o;
|
|
301
|
+
return D().refine((n) => _.isStringEmpty(n) ? !0 : d.test(n), (t == null ? void 0 : t.invalid) || a.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 || {};
|
|
305
305
|
return t ? W(e) : K(e);
|
|
306
306
|
}
|
|
307
307
|
const J = {
|
|
308
|
-
getStringSchema:
|
|
309
|
-
getEmailSchema:
|
|
308
|
+
getStringSchema: j,
|
|
309
|
+
getEmailSchema: w,
|
|
310
310
|
getSelectSchema: q,
|
|
311
|
-
getNumberSchema:
|
|
311
|
+
getNumberSchema: b,
|
|
312
312
|
getPhoneSchema: $,
|
|
313
313
|
getDateSchema: U,
|
|
314
314
|
getUnionSchema: k,
|
|
@@ -346,44 +346,51 @@ class ce {
|
|
|
346
346
|
* // }
|
|
347
347
|
*/
|
|
348
348
|
static getZodDefaults(t, o) {
|
|
349
|
-
const { fillArrayWithValue: d } = o || {}
|
|
350
|
-
|
|
351
|
-
return
|
|
352
|
-
|
|
349
|
+
const { fillArrayWithValue: d } = o || {}, n = (r) => {
|
|
350
|
+
const l = r._def.schema;
|
|
351
|
+
return l instanceof s.ZodEffects || l._def.typeName === "ZodEffects" ? n(l) : l instanceof s.ZodObject || l._def.typeName === "ZodObject" ? this.getZodDefaults(l, o) : i(l);
|
|
352
|
+
}, i = (r) => {
|
|
353
|
+
if (r instanceof s.ZodEffects || r._def.typeName === "ZodEffects")
|
|
354
|
+
return n(r);
|
|
353
355
|
switch (!0) {
|
|
354
|
-
case (
|
|
355
|
-
return
|
|
356
|
-
case (
|
|
356
|
+
case (r._def.typeName === "ZodDefault" || r instanceof s.ZodDefault):
|
|
357
|
+
return r._def.defaultValue();
|
|
358
|
+
case (r._def.typeName === "ZodOptional" || r instanceof s.ZodOptional):
|
|
357
359
|
return;
|
|
358
|
-
case
|
|
360
|
+
case r._def.typeName === "ZodEffects":
|
|
361
|
+
return n(r);
|
|
362
|
+
case (r._def.typeName === "ZodNullable" || r instanceof s.ZodNullable):
|
|
359
363
|
return null;
|
|
360
|
-
case (
|
|
361
|
-
return d ? [
|
|
362
|
-
case (
|
|
363
|
-
return this.getZodDefaults(
|
|
364
|
-
case (
|
|
365
|
-
return
|
|
366
|
-
case (
|
|
367
|
-
return
|
|
368
|
-
case (
|
|
369
|
-
return
|
|
370
|
-
case (
|
|
371
|
-
return
|
|
372
|
-
case (
|
|
364
|
+
case (r._def.typeName === "ZodArray" || r instanceof s.ZodArray):
|
|
365
|
+
return d ? [i(r.element)] : [];
|
|
366
|
+
case (r._def.typeName === "ZodObject" || r instanceof s.ZodObject):
|
|
367
|
+
return this.getZodDefaults(r, o);
|
|
368
|
+
case (r._def.typeName === "ZodUnion" || r instanceof s.ZodUnion):
|
|
369
|
+
return i(r._def.options[0]);
|
|
370
|
+
case (r._def.typeName === "ZodLiteral" || r instanceof s.ZodLiteral):
|
|
371
|
+
return r._def.value;
|
|
372
|
+
case (r._def.typeName === "ZodDiscriminatedUnion" || r instanceof s.ZodDiscriminatedUnion):
|
|
373
|
+
return i(r._def.options[0]);
|
|
374
|
+
case (r._def.typeName === "ZodEnum" || r instanceof s.ZodEnum):
|
|
375
|
+
return r._def.values[0];
|
|
376
|
+
case (r._def.typeName === "ZodString" || r instanceof s.ZodString):
|
|
373
377
|
return "";
|
|
374
|
-
case (
|
|
378
|
+
case (r._def.typeName === "ZodNumber" || r instanceof s.ZodNumber):
|
|
375
379
|
return 0;
|
|
376
|
-
case (
|
|
380
|
+
case (r._def.typeName === "ZodBoolean" || r instanceof s.ZodBoolean):
|
|
377
381
|
return !1;
|
|
378
|
-
case !("innerType" in
|
|
382
|
+
case !("innerType" in r._def):
|
|
379
383
|
return;
|
|
380
384
|
default:
|
|
381
|
-
return
|
|
385
|
+
return i(r._def.innerType);
|
|
382
386
|
}
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}
|
|
387
|
+
};
|
|
388
|
+
if (t instanceof s.ZodEffects)
|
|
389
|
+
return n(t);
|
|
390
|
+
const u = {};
|
|
391
|
+
return Object.entries(t.shape).map(([r, l]) => {
|
|
392
|
+
u[r] = i(l);
|
|
393
|
+
}), u;
|
|
387
394
|
}
|
|
388
395
|
/**
|
|
389
396
|
* Функция для объединения zod схождений
|
|
@@ -411,8 +418,8 @@ class ce {
|
|
|
411
418
|
* })
|
|
412
419
|
*/
|
|
413
420
|
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 ||
|
|
415
|
-
if (n instanceof s.ZodObject && i instanceof s.ZodObject)
|
|
421
|
+
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 || d._def.typeName === "ZodDiscriminatedUnion" ? d._def.options[0] : d;
|
|
422
|
+
if ((n._def.typeName === "ZodObject" || n instanceof s.ZodObject) && (i._def.typeName === "ZodObject" || i instanceof s.ZodObject))
|
|
416
423
|
return n.merge(i);
|
|
417
424
|
throw new Error(`Cannot merge schema type ${i._def.typeName} to ${n._def.typeName}`);
|
|
418
425
|
}
|
|
@@ -425,7 +432,7 @@ const m = {
|
|
|
425
432
|
INVALID_NAME: () => "Неверно введено имя",
|
|
426
433
|
INVALID_SURNAME: () => "Неверно введена фамилия",
|
|
427
434
|
INVALID_PATRONYMIC: () => "Неверно введено отчество"
|
|
428
|
-
},
|
|
435
|
+
}, I = {
|
|
429
436
|
ONLY_CYRILLIC: /[\u0400-\u04FF\u00CB\u00EB -]/g,
|
|
430
437
|
CHECK_HYPHEN: /^(?:[^-]+(?:-[^-]+){0,4}|[^-]+)$/,
|
|
431
438
|
PATRONYMIC: /^[a-zA-Zа-яА-ЯёЁ]+(?:\s*-\s*[a-zA-Zа-яА-ЯёЁ]+){0,4}(?:\s+[a-zA-Zа-яА-ЯёЁ]+(?:\s*-\s*[a-zA-Zа-яА-ЯёЁ]+){0,4})?$/i
|
|
@@ -434,25 +441,25 @@ const m = {
|
|
|
434
441
|
return { surname: t, name: o, patronymic: n };
|
|
435
442
|
}, S = (e) => {
|
|
436
443
|
const { message: t } = e || {}, { nameOrSurnameEmpty: o, invalidSurname: d, invalidPatronymic: n, invalidName: i } = t || {};
|
|
437
|
-
return s.string().superRefine((u,
|
|
438
|
-
const { name:
|
|
439
|
-
|
|
444
|
+
return s.string().superRefine((u, c) => {
|
|
445
|
+
const { name: r, surname: l, patronymic: f } = ee(u);
|
|
446
|
+
I.ONLY_CYRILLIC.test(u) || c.addIssue({
|
|
440
447
|
code: s.ZodIssueCode.invalid_string,
|
|
441
448
|
validation: "regex",
|
|
442
449
|
message: m.ONLY_CYRILLIC()
|
|
443
|
-
}), (!
|
|
450
|
+
}), (!r || !l) && c.addIssue({
|
|
444
451
|
code: s.ZodIssueCode.invalid_string,
|
|
445
452
|
validation: "regex",
|
|
446
453
|
message: o || m.NAME_OR_SURNAME_NON_EMPTY()
|
|
447
|
-
}),
|
|
454
|
+
}), I.CHECK_HYPHEN.test(r) || c.addIssue({
|
|
448
455
|
code: s.ZodIssueCode.invalid_string,
|
|
449
456
|
validation: "regex",
|
|
450
457
|
message: i || m.INVALID_NAME()
|
|
451
|
-
}),
|
|
458
|
+
}), I.CHECK_HYPHEN.test(l) || c.addIssue({
|
|
452
459
|
code: s.ZodIssueCode.invalid_string,
|
|
453
460
|
validation: "regex",
|
|
454
461
|
message: d || m.INVALID_SURNAME()
|
|
455
|
-
}),
|
|
462
|
+
}), f && (I.PATRONYMIC.test(f) || c.addIssue({
|
|
456
463
|
code: s.ZodIssueCode.invalid_string,
|
|
457
464
|
validation: "regex",
|
|
458
465
|
message: n || m.INVALID_PATRONYMIC()
|
|
@@ -465,7 +472,7 @@ function ne(e) {
|
|
|
465
472
|
}
|
|
466
473
|
const ie = {
|
|
467
474
|
getFioSchema: ne
|
|
468
|
-
},
|
|
475
|
+
}, _e = {
|
|
469
476
|
base: J,
|
|
470
477
|
dadata: ie
|
|
471
478
|
};
|
|
@@ -475,13 +482,13 @@ export {
|
|
|
475
482
|
R as RgxUnicode,
|
|
476
483
|
E as VALIDATION_MESSAGES,
|
|
477
484
|
ce as ZodUtils,
|
|
478
|
-
|
|
485
|
+
a as baseDefaultMessages,
|
|
479
486
|
J as baseValidationSchemas,
|
|
480
487
|
P as formattedDadataFio,
|
|
481
|
-
|
|
488
|
+
re as zodCalendarValidate,
|
|
482
489
|
se as zodDadataFioSchema,
|
|
483
490
|
ue as zodOtpCodeSchema,
|
|
484
|
-
|
|
485
|
-
|
|
491
|
+
ae as zodPhoneSchema,
|
|
492
|
+
_e as zodValidators
|
|
486
493
|
};
|
|
487
494
|
//# sourceMappingURL=validation.js.map
|