@scbt-ecom/ui 0.50.0 → 0.50.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-DJ_i5IU3.js → index-DXLhMM4P.js} +2 -1
- package/dist/{index-DJ_i5IU3.js.map → index-DXLhMM4P.js.map} +1 -1
- package/dist/shared/validation/utils/zodUtils.d.ts +1 -1
- package/dist/ui.js +2 -2
- package/dist/validation.js +110 -110
- package/dist/validation.js.map +1 -1
- package/dist/widget.js +1 -1
- package/package.json +1 -1
|
@@ -36,6 +36,6 @@ export declare class ZodUtils {
|
|
|
36
36
|
* // }
|
|
37
37
|
* // }
|
|
38
38
|
*/
|
|
39
|
-
static getZodDefaults<ZodSchema extends z.AnyZodObject, Schema = z.TypeOf<ZodSchema>>(zodSchema: ZodSchema | z.ZodEffects<ZodSchema>, options?: ZodUtilsGetDefaultsOptions): Schema;
|
|
39
|
+
static getZodDefaults<ZodSchema extends z.AnyZodObject, Schema = z.TypeOf<ZodSchema>>(zodSchema: ZodSchema | z.ZodEffects<ZodSchema> | z.ZodIntersection<ZodSchema, ZodSchema>, options?: ZodUtilsGetDefaultsOptions): Schema;
|
|
40
40
|
}
|
|
41
41
|
export {};
|
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 ve, 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 Kn, r as Xn, e as Wn, C as Yn, s as Jn, K as Qn, L as Zn, N as eo, P as to, a as no, S as oo, t as ro, U as io, b as lo } 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 ve, 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-DXLhMM4P.js";
|
|
2
|
+
import { d as Kn, r as Xn, e as Wn, C as Yn, s as Jn, K as Qn, L as Zn, N as eo, P as to, a as no, S as oo, t as ro, U as io, b as lo } from "./index-DXLhMM4P.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 o, p as
|
|
2
|
-
import { T as
|
|
1
|
+
import { z as o, p as m, i as N, f as T, D as L, s as D } from "./utils-Od0KoTas.js";
|
|
2
|
+
import { T as l } from "./typeGuards-BigW-JS1.js";
|
|
3
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 = {
|
|
4
4
|
REQUIRED: "Поле обязательно к заполнению",
|
|
5
5
|
MIN_LENGTH: "Минимальная длина символов должна быть не менее",
|
|
@@ -42,7 +42,7 @@ const Z = /^[\u0400-\u04FF\u00CB\u00EB -]+$/, A = /^(?:[^-]+(?:-[^-]+){0,4}|[^-]
|
|
|
42
42
|
message: "Неверно введено отчество"
|
|
43
43
|
}));
|
|
44
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 =
|
|
45
|
+
const [d, s, n] = (e == null ? void 0 : e.split(".")) ?? "", i = m(`${d}/${s}/${n}`, "dd/MM/yyyy", /* @__PURE__ */ new Date());
|
|
46
46
|
+n <= 1950 && t.addIssue({
|
|
47
47
|
code: o.ZodIssueCode.custom,
|
|
48
48
|
message: I.INVALID_DATE
|
|
@@ -69,7 +69,7 @@ const Z = /^[\u0400-\u04FF\u00CB\u00EB -]+$/, A = /^(?:[^-]+(?:-[^-]+){0,4}|[^-]
|
|
|
69
69
|
received: "null",
|
|
70
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}`,
|
|
@@ -88,94 +88,94 @@ const Z = /^[\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 = l.isString(e) ? new Date(e) : e;
|
|
92
92
|
return `Выбранная дата должна быть не раньше ${T(t)}`;
|
|
93
93
|
},
|
|
94
94
|
DATE_MAX: (e) => {
|
|
95
|
-
const t =
|
|
95
|
+
const t = l.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: d = L, min: s, max: n, message: i } = e || {};
|
|
101
|
-
return o.string().min(8, (i == null ? void 0 : i.min) ||
|
|
102
|
-
const
|
|
103
|
-
if (u.replace(/[._-]/g, "").length <
|
|
101
|
+
return o.string().min(8, (i == null ? void 0 : i.min) || r.DATE_NON_EMPTY()).superRefine((u, c) => {
|
|
102
|
+
const a = d.replace(/\W/g, "").length;
|
|
103
|
+
if (u.replace(/[._-]/g, "").length < a && c.addIssue({
|
|
104
104
|
code: o.ZodIssueCode.too_small,
|
|
105
|
-
minimum:
|
|
105
|
+
minimum: a,
|
|
106
106
|
type: "date",
|
|
107
107
|
inclusive: !0,
|
|
108
|
-
message: (i == null ? void 0 : i.min) ||
|
|
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
|
-
|
|
114
|
+
c.addIssue({
|
|
115
115
|
code: o.ZodIssueCode.invalid_date,
|
|
116
|
-
message: (i == null ? void 0 : i.invalidDate) ||
|
|
116
|
+
message: (i == null ? void 0 : i.invalidDate) || r.DATE_INVALID_FORMAT()
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
s && _.getTime() < (
|
|
119
|
+
s && _.getTime() < (l.isString(s) ? new Date(s).getTime() : s.getTime()) && c.addIssue({
|
|
120
120
|
code: o.ZodIssueCode.invalid_date,
|
|
121
|
-
message: (i == null ? void 0 : i.min) ||
|
|
122
|
-
}), n && _.getTime() > (
|
|
121
|
+
message: (i == null ? void 0 : i.min) || r.DATE_MIN(s)
|
|
122
|
+
}), n && _.getTime() > (l.isString(n) ? new Date(n).getTime() : n.getTime()) && c.addIssue({
|
|
123
123
|
code: o.ZodIssueCode.invalid_date,
|
|
124
|
-
message: (i == null ? void 0 : i.max) ||
|
|
124
|
+
message: (i == null ? void 0 : i.max) || r.DATE_MAX(n)
|
|
125
125
|
});
|
|
126
126
|
} else {
|
|
127
|
-
const _ =
|
|
128
|
-
N(_) ||
|
|
127
|
+
const _ = m(u, d, /* @__PURE__ */ new Date());
|
|
128
|
+
N(_) || c.addIssue({
|
|
129
129
|
code: o.ZodIssueCode.invalid_date,
|
|
130
|
-
message: (i == null ? void 0 : i.invalidDate) ||
|
|
131
|
-
}), s && _.getTime() < (
|
|
130
|
+
message: (i == null ? void 0 : i.invalidDate) || r.DATE_INVALID_FORMAT()
|
|
131
|
+
}), s && _.getTime() < (l.isString(s) ? new Date(s).getTime() : s.getTime()) && c.addIssue({
|
|
132
132
|
code: o.ZodIssueCode.invalid_date,
|
|
133
|
-
message: (i == null ? void 0 : i.min) ||
|
|
134
|
-
}), n && _.getTime() > (
|
|
133
|
+
message: (i == null ? void 0 : i.min) || r.DATE_MIN(s)
|
|
134
|
+
}), n && _.getTime() > (l.isString(n) ? new Date(n).getTime() : n.getTime()) && c.addIssue({
|
|
135
135
|
code: o.ZodIssueCode.invalid_date,
|
|
136
|
-
message: (i == null ? void 0 : i.max) ||
|
|
136
|
+
message: (i == null ? void 0 : i.max) || r.DATE_MAX(n)
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
}).default("");
|
|
140
140
|
}, y = (e) => {
|
|
141
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,
|
|
143
|
-
if (
|
|
144
|
-
const
|
|
145
|
-
if (u.replace(/[._-]/g, "").length <
|
|
142
|
+
return o.string().transform((u) => u || void 0).superRefine((u, c) => {
|
|
143
|
+
if (l.isString(u) && u.length) {
|
|
144
|
+
const a = d.replace(/\W/g, "").length;
|
|
145
|
+
if (u.replace(/[._-]/g, "").length < a && c.addIssue({
|
|
146
146
|
code: o.ZodIssueCode.too_small,
|
|
147
|
-
minimum:
|
|
147
|
+
minimum: a,
|
|
148
148
|
type: "date",
|
|
149
149
|
inclusive: !0,
|
|
150
|
-
message: (i == null ? void 0 : i.min) ||
|
|
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
|
-
|
|
156
|
+
c.addIssue({
|
|
157
157
|
code: o.ZodIssueCode.invalid_date,
|
|
158
|
-
message: (i == null ? void 0 : i.invalidDate) ||
|
|
158
|
+
message: (i == null ? void 0 : i.invalidDate) || r.DATE_INVALID_FORMAT()
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
-
s && _.getTime() < (
|
|
161
|
+
s && _.getTime() < (l.isString(s) ? new Date(s).getTime() : s.getTime()) && c.addIssue({
|
|
162
162
|
code: o.ZodIssueCode.invalid_date,
|
|
163
|
-
message: (i == null ? void 0 : i.min) ||
|
|
164
|
-
}), n && _.getTime() > (
|
|
163
|
+
message: (i == null ? void 0 : i.min) || r.DATE_MIN(s)
|
|
164
|
+
}), n && _.getTime() > (l.isString(n) ? new Date(n).getTime() : n.getTime()) && c.addIssue({
|
|
165
165
|
code: o.ZodIssueCode.invalid_date,
|
|
166
|
-
message: (i == null ? void 0 : i.max) ||
|
|
166
|
+
message: (i == null ? void 0 : i.max) || r.DATE_MAX(n)
|
|
167
167
|
});
|
|
168
168
|
} else {
|
|
169
|
-
const _ =
|
|
170
|
-
N(_) ||
|
|
169
|
+
const _ = m(u, d, /* @__PURE__ */ new Date());
|
|
170
|
+
N(_) || c.addIssue({
|
|
171
171
|
code: o.ZodIssueCode.invalid_date,
|
|
172
|
-
message: (i == null ? void 0 : i.invalidDate) ||
|
|
173
|
-
}), s && _.getTime() < (
|
|
172
|
+
message: (i == null ? void 0 : i.invalidDate) || r.DATE_INVALID_FORMAT()
|
|
173
|
+
}), s && _.getTime() < (l.isString(s) ? new Date(s).getTime() : s.getTime()) && c.addIssue({
|
|
174
174
|
code: o.ZodIssueCode.invalid_date,
|
|
175
|
-
message: (i == null ? void 0 : i.min) ||
|
|
176
|
-
}), n && _.getTime() > (
|
|
175
|
+
message: (i == null ? void 0 : i.min) || r.DATE_MIN(s)
|
|
176
|
+
}), n && _.getTime() > (l.isString(n) ? new Date(n).getTime() : n.getTime()) && c.addIssue({
|
|
177
177
|
code: o.ZodIssueCode.invalid_date,
|
|
178
|
-
message: (i == null ? void 0 : i.max) ||
|
|
178
|
+
message: (i == null ? void 0 : i.max) || r.DATE_MAX(n)
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
181
|
}
|
|
@@ -186,14 +186,14 @@ function H(e) {
|
|
|
186
186
|
return t ? V(e) : y(e);
|
|
187
187
|
}
|
|
188
188
|
const M = /^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/g, U = (e) => {
|
|
189
|
-
const { message: t, regexp: d = M } = e || {}, s =
|
|
190
|
-
return o.string().min(1, (t == null ? void 0 : t.min) ||
|
|
189
|
+
const { message: t, regexp: d = M } = e || {}, s = l.isString(d) ? new RegExp(d) : d;
|
|
190
|
+
return o.string().min(1, (t == null ? void 0 : t.min) || r.EMAIL_NON_EMPTY()).regex(s, (t == null ? void 0 : t.invalid) || r.EMAIL_INVALID()).default("");
|
|
191
191
|
}, Y = (e) => {
|
|
192
|
-
const { message: t, regexp: d = M } = e || {}, s =
|
|
192
|
+
const { message: t, regexp: d = M } = e || {}, s = l.isString(d) ? new RegExp(d) : d;
|
|
193
193
|
return o.string().refine(
|
|
194
|
-
(n) =>
|
|
194
|
+
(n) => l.isStringEmpty(n) ? !0 : s.test(n),
|
|
195
195
|
{
|
|
196
|
-
message: (t == null ? void 0 : t.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
|
};
|
|
@@ -204,43 +204,43 @@ function w(e) {
|
|
|
204
204
|
const O = (e) => {
|
|
205
205
|
const { min: t, max: d, message: s } = e || {};
|
|
206
206
|
let n = o.coerce.number();
|
|
207
|
-
return t && (n = n.min(t, (s == null ? void 0 : s.min) ||
|
|
207
|
+
return t && (n = n.min(t, (s == null ? void 0 : s.min) || r.MIN_VALUE(t))), d && (n = n.max(d, (s == null ? void 0 : s.min) || r.MAX_VALUE(d))), n.default(0);
|
|
208
208
|
}, F = (e) => O(e).optional().transform((t) => t || void 0);
|
|
209
209
|
function G(e) {
|
|
210
210
|
const { required: t = !0 } = e || {};
|
|
211
211
|
return t ? O(e) : F(e);
|
|
212
212
|
}
|
|
213
213
|
const X = (e) => {
|
|
214
|
-
const { ignoreMask: t = !0, maskSymbols: d = /[()+_ -]/g, message: s } = e || {}, n =
|
|
215
|
-
let i = o.string().superRefine((u,
|
|
216
|
-
const
|
|
217
|
-
["3", "4", "5", "6", "7", "9"].includes(E) ||
|
|
214
|
+
const { ignoreMask: t = !0, maskSymbols: d = /[()+_ -]/g, message: s } = e || {}, n = l.isString(d) ? new RegExp(d) : d;
|
|
215
|
+
let i = o.string().superRefine((u, c) => {
|
|
216
|
+
const a = u.replace(n, ""), E = a.charAt(1);
|
|
217
|
+
["3", "4", "5", "6", "7", "9"].includes(E) || c.addIssue({
|
|
218
218
|
code: o.ZodIssueCode.invalid_string,
|
|
219
219
|
validation: "regex",
|
|
220
|
-
message: (s == null ? void 0 : s.invalidOperator) ||
|
|
221
|
-
}),
|
|
220
|
+
message: (s == null ? void 0 : s.invalidOperator) || r.PHONE_INVALID_OPERATOR()
|
|
221
|
+
}), a.length < 11 && c.addIssue({
|
|
222
222
|
code: o.ZodIssueCode.too_small,
|
|
223
223
|
minimum: 11,
|
|
224
224
|
inclusive: !0,
|
|
225
225
|
type: "string",
|
|
226
|
-
message: (s == null ? void 0 : s.min) ||
|
|
226
|
+
message: (s == null ? void 0 : s.min) || r.PHONE_NON_EMPTY()
|
|
227
227
|
});
|
|
228
228
|
});
|
|
229
229
|
return t && (i = i.transform((u) => u.replace(n, ""))), i.default("");
|
|
230
230
|
}, $ = (e) => {
|
|
231
|
-
const { ignoreMask: t = !0, maskSymbols: d = /[()+_ -]/g, message: s } = e || {}, n =
|
|
232
|
-
let i = o.string().superRefine((u,
|
|
233
|
-
const
|
|
234
|
-
["3", "4", "5", "6", "7", "9"].includes(E) ||
|
|
231
|
+
const { ignoreMask: t = !0, maskSymbols: d = /[()+_ -]/g, message: s } = e || {}, n = l.isString(d) ? new RegExp(d) : d;
|
|
232
|
+
let i = o.string().superRefine((u, c) => {
|
|
233
|
+
const a = u.replace(n, ""), E = a.charAt(1);
|
|
234
|
+
["3", "4", "5", "6", "7", "9"].includes(E) || c.addIssue({
|
|
235
235
|
code: o.ZodIssueCode.invalid_string,
|
|
236
236
|
validation: "regex",
|
|
237
|
-
message: (s == null ? void 0 : s.invalidOperator) ||
|
|
238
|
-
}),
|
|
237
|
+
message: (s == null ? void 0 : s.invalidOperator) || r.PHONE_INVALID_OPERATOR()
|
|
238
|
+
}), a.length < 11 && c.addIssue({
|
|
239
239
|
code: o.ZodIssueCode.too_small,
|
|
240
240
|
minimum: 11,
|
|
241
241
|
inclusive: !0,
|
|
242
242
|
type: "string",
|
|
243
|
-
message: (s == null ? void 0 : s.min) ||
|
|
243
|
+
message: (s == null ? void 0 : s.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);
|
|
@@ -251,12 +251,12 @@ function x(e) {
|
|
|
251
251
|
}
|
|
252
252
|
const b = (e) => {
|
|
253
253
|
var s, n;
|
|
254
|
-
const { message: t } = e || {}, d = o.string().min(1, (t == null ? void 0 : t.single) ||
|
|
254
|
+
const { message: t } = e || {}, d = o.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) ||
|
|
257
|
-
return e != null && e.length ? i.length(e.length, ((s = e.message) == null ? void 0 : s.length) ||
|
|
256
|
+
let i = o.array(d).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, ((s = e.message) == null ? void 0 : s.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) ||
|
|
259
|
+
((n = e.message) == null ? void 0 : n.maxLength) || r.SELECT_MULTIPLE_MAX_LENGTH(e.maxLength)
|
|
260
260
|
)), i.default([]));
|
|
261
261
|
}
|
|
262
262
|
return d;
|
|
@@ -272,33 +272,33 @@ function v(e) {
|
|
|
272
272
|
const p = (e) => {
|
|
273
273
|
const { min: t, max: d, length: s, message: n } = e || {};
|
|
274
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) ||
|
|
275
|
+
return t && (i = i.min(t, { message: (n == null ? void 0 : n.min) || r.MIN_LENGTH(t) })), d && (i = i.max(d, { message: (n == null ? void 0 : n.max) || r.MAX_LENGTH(d) })), s && (i = i.length(s, { message: (n == null ? void 0 : n.length) || r.FIX_LENGTH(s) })), i.refine((u) => !!u.length, { message: (n == null ? void 0 : n.min) || r.NON_EMPTY() }).default("");
|
|
276
276
|
}, z = (e) => {
|
|
277
277
|
const { min: t, max: d, length: s, message: n } = e || {};
|
|
278
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) ||
|
|
279
|
+
return t && (i = i.min(t, { message: (n == null ? void 0 : n.min) || r.MIN_LENGTH(t) })), d && (i = i.max(d, { message: (n == null ? void 0 : n.max) || r.MAX_LENGTH(d) })), s && (i = i.length(s, { message: (n == null ? void 0 : n.length) || r.FIX_LENGTH(s) })), i.optional().transform((u) => u != null && u.length ? u : void 0);
|
|
280
280
|
};
|
|
281
281
|
function B(e) {
|
|
282
282
|
const { required: t = !0, ...d } = e || {};
|
|
283
283
|
return t ? p(d) : z(d);
|
|
284
284
|
}
|
|
285
285
|
const C = (e, t) => {
|
|
286
|
-
const { message: d, ...s } = t || {}, [n, i, ...u] = e.map((
|
|
286
|
+
const { message: d, ...s } = t || {}, [n, i, ...u] = e.map((a) => o.literal(a)), c = d ? typeof d == "function" ? d(e) : d : r.VALUE_OUT_OF_RANGE(e);
|
|
287
287
|
return o.union([n, i, ...u], {
|
|
288
|
-
message:
|
|
288
|
+
message: c,
|
|
289
289
|
...s
|
|
290
|
-
}).nullable().refine(Boolean,
|
|
290
|
+
}).nullable().refine(Boolean, r.NON_EMPTY()).default(null);
|
|
291
291
|
}, k = (e, t) => C(e, t).optional();
|
|
292
292
|
function j(e, t) {
|
|
293
293
|
const { required: d, ...s } = t || {};
|
|
294
294
|
return d ? C(e, s) : k(e, s);
|
|
295
295
|
}
|
|
296
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 =
|
|
298
|
-
return D().min(1, (t == null ? void 0 : t.min) ||
|
|
297
|
+
const { message: t, regexp: d = R } = e || {}, s = l.isString(d) ? new RegExp(d) : d;
|
|
298
|
+
return D().min(1, (t == null ? void 0 : t.min) || r.NON_EMPTY()).regex(s, (t == null ? void 0 : t.invalid) || r.INVALID_URL()).default("");
|
|
299
299
|
}, K = (e) => {
|
|
300
|
-
const { message: t, regexp: d = R } = e || {}, s =
|
|
301
|
-
return D().refine((n) =>
|
|
300
|
+
const { message: t, regexp: d = R } = e || {}, s = l.isString(d) ? new RegExp(d) : d;
|
|
301
|
+
return D().refine((n) => l.isStringEmpty(n) ? !0 : s.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 || {};
|
|
@@ -349,40 +349,40 @@ class ce {
|
|
|
349
349
|
const { fillArrayWithValue: s } = d || {};
|
|
350
350
|
if (t instanceof o.ZodEffects)
|
|
351
351
|
return t.innerType() instanceof o.ZodEffects ? this.getZodDefaults(t.innerType(), d) : this.getZodDefaults(o.ZodObject.create(t.innerType().shape), d);
|
|
352
|
-
const n = (
|
|
352
|
+
const n = (a) => {
|
|
353
353
|
switch (!0) {
|
|
354
|
-
case
|
|
355
|
-
return
|
|
356
|
-
case
|
|
354
|
+
case a instanceof o.ZodDefault:
|
|
355
|
+
return a._def.defaultValue();
|
|
356
|
+
case a instanceof o.ZodOptional:
|
|
357
357
|
return;
|
|
358
|
-
case
|
|
358
|
+
case a instanceof o.ZodNullable:
|
|
359
359
|
return null;
|
|
360
|
-
case
|
|
361
|
-
return s ? [n(
|
|
362
|
-
case
|
|
363
|
-
return this.getZodDefaults(
|
|
364
|
-
case
|
|
365
|
-
return n(
|
|
366
|
-
case
|
|
367
|
-
return
|
|
368
|
-
case
|
|
369
|
-
return n(
|
|
370
|
-
case
|
|
371
|
-
return
|
|
372
|
-
case
|
|
360
|
+
case a instanceof o.ZodArray:
|
|
361
|
+
return s ? [n(a.element)] : [];
|
|
362
|
+
case a instanceof o.ZodObject:
|
|
363
|
+
return this.getZodDefaults(a, d);
|
|
364
|
+
case a instanceof o.ZodUnion:
|
|
365
|
+
return n(a._def.options[0]);
|
|
366
|
+
case a instanceof o.ZodLiteral:
|
|
367
|
+
return a._def.value;
|
|
368
|
+
case a instanceof o.ZodDiscriminatedUnion:
|
|
369
|
+
return n(a._def.options[0]);
|
|
370
|
+
case a instanceof o.ZodEnum:
|
|
371
|
+
return a._def.values[0];
|
|
372
|
+
case a instanceof o.ZodString:
|
|
373
373
|
return "";
|
|
374
|
-
case
|
|
374
|
+
case a instanceof o.ZodNumber:
|
|
375
375
|
return 0;
|
|
376
|
-
case
|
|
376
|
+
case a instanceof o.ZodBoolean:
|
|
377
377
|
return !1;
|
|
378
|
-
case !("innerType" in
|
|
378
|
+
case !("innerType" in a._def):
|
|
379
379
|
return;
|
|
380
380
|
default:
|
|
381
|
-
return n(
|
|
381
|
+
return n(a._def.innerType);
|
|
382
382
|
}
|
|
383
|
-
}, i = {};
|
|
384
|
-
return Object.entries(
|
|
385
|
-
i[
|
|
383
|
+
}, i = {}, u = t instanceof o.ZodIntersection ? t._def.left.merge(t._def.right).shape : t.shape;
|
|
384
|
+
return Object.entries(u).map(([a, E]) => {
|
|
385
|
+
i[a] = n(E);
|
|
386
386
|
}), i;
|
|
387
387
|
}
|
|
388
388
|
}
|
|
@@ -394,7 +394,7 @@ const g = {
|
|
|
394
394
|
INVALID_NAME: () => "Неверно введено имя",
|
|
395
395
|
INVALID_SURNAME: () => "Неверно введена фамилия",
|
|
396
396
|
INVALID_PATRONYMIC: () => "Неверно введено отчество"
|
|
397
|
-
},
|
|
397
|
+
}, f = {
|
|
398
398
|
ONLY_CYRILLIC: /[\u0400-\u04FF\u00CB\u00EB -]/g,
|
|
399
399
|
CHECK_HYPHEN: /^(?:[^-]+(?:-[^-]+){0,4}|[^-]+)$/,
|
|
400
400
|
PATRONYMIC: /^[a-zA-Zа-яА-ЯёЁ]+(?:\s*-\s*[a-zA-Zа-яА-ЯёЁ]+){0,4}(?:\s+[a-zA-Zа-яА-ЯёЁ]+(?:\s*-\s*[a-zA-Zа-яА-ЯёЁ]+){0,4})?$/i
|
|
@@ -403,25 +403,25 @@ const g = {
|
|
|
403
403
|
return { surname: t, name: d, patronymic: n };
|
|
404
404
|
}, S = (e) => {
|
|
405
405
|
const { message: t } = e || {}, { nameOrSurnameEmpty: d, invalidSurname: s, invalidPatronymic: n, invalidName: i } = t || {};
|
|
406
|
-
return o.string().superRefine((u,
|
|
407
|
-
const { name:
|
|
408
|
-
|
|
406
|
+
return o.string().superRefine((u, c) => {
|
|
407
|
+
const { name: a, surname: E, patronymic: _ } = ee(u);
|
|
408
|
+
f.ONLY_CYRILLIC.test(u) || c.addIssue({
|
|
409
409
|
code: o.ZodIssueCode.invalid_string,
|
|
410
410
|
validation: "regex",
|
|
411
411
|
message: g.ONLY_CYRILLIC()
|
|
412
|
-
}), (!
|
|
412
|
+
}), (!a || !E) && c.addIssue({
|
|
413
413
|
code: o.ZodIssueCode.invalid_string,
|
|
414
414
|
validation: "regex",
|
|
415
415
|
message: d || g.NAME_OR_SURNAME_NON_EMPTY()
|
|
416
|
-
}),
|
|
416
|
+
}), f.CHECK_HYPHEN.test(a) || c.addIssue({
|
|
417
417
|
code: o.ZodIssueCode.invalid_string,
|
|
418
418
|
validation: "regex",
|
|
419
419
|
message: i || g.INVALID_NAME()
|
|
420
|
-
}),
|
|
420
|
+
}), f.CHECK_HYPHEN.test(E) || c.addIssue({
|
|
421
421
|
code: o.ZodIssueCode.invalid_string,
|
|
422
422
|
validation: "regex",
|
|
423
423
|
message: s || g.INVALID_SURNAME()
|
|
424
|
-
}), _ && (
|
|
424
|
+
}), _ && (f.PATRONYMIC.test(_) || c.addIssue({
|
|
425
425
|
code: o.ZodIssueCode.invalid_string,
|
|
426
426
|
validation: "regex",
|
|
427
427
|
message: n || g.INVALID_PATRONYMIC()
|
|
@@ -444,7 +444,7 @@ export {
|
|
|
444
444
|
Z as RgxUnicode,
|
|
445
445
|
I as VALIDATION_MESSAGES,
|
|
446
446
|
ce as ZodUtils,
|
|
447
|
-
|
|
447
|
+
r as baseDefaultMessages,
|
|
448
448
|
J as baseValidationSchemas,
|
|
449
449
|
P as formattedDadataFio,
|
|
450
450
|
re as zodCalendarValidate,
|