@reformer/core 2.0.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/behaviors/compute-from.d.ts +2 -0
- package/dist/behaviors/compute-from.js +31 -0
- package/dist/behaviors/copy-from.d.ts +2 -0
- package/dist/behaviors/copy-from.js +29 -0
- package/dist/behaviors/enable-when.d.ts +2 -0
- package/dist/behaviors/enable-when.js +25 -0
- package/dist/behaviors/reset-when.d.ts +2 -0
- package/dist/behaviors/reset-when.js +24 -0
- package/dist/behaviors/revalidate-when.d.ts +2 -0
- package/dist/behaviors/revalidate-when.js +18 -0
- package/dist/behaviors/sync-fields.d.ts +2 -0
- package/dist/behaviors/sync-fields.js +41 -0
- package/dist/behaviors/transform-value.d.ts +2 -0
- package/dist/behaviors/transform-value.js +45 -0
- package/dist/behaviors/watch-field.d.ts +2 -0
- package/dist/behaviors/watch-field.js +21 -0
- package/dist/behaviors.js +26 -19
- package/dist/core/behavior/behavior-context.d.ts +27 -13
- package/dist/core/behavior/behavior-registry.d.ts +15 -27
- package/dist/core/behavior/behaviors/compute-from.d.ts +50 -21
- package/dist/core/behavior/behaviors/copy-from.d.ts +39 -14
- package/dist/core/behavior/behaviors/enable-when.d.ts +88 -19
- package/dist/core/behavior/behaviors/reset-when.d.ts +31 -18
- package/dist/core/behavior/behaviors/revalidate-when.d.ts +40 -17
- package/dist/core/behavior/behaviors/sync-fields.d.ts +34 -14
- package/dist/core/behavior/behaviors/transform-value.d.ts +116 -44
- package/dist/core/behavior/behaviors/watch-field.d.ts +66 -21
- package/dist/core/behavior/compose-behavior.d.ts +2 -12
- package/dist/core/behavior/index.d.ts +0 -1
- package/dist/core/behavior/types.d.ts +2 -8
- package/dist/core/factories/node-factory.d.ts +6 -29
- package/dist/core/nodes/array-node.d.ts +42 -22
- package/dist/core/nodes/field-node.d.ts +51 -26
- package/dist/core/nodes/form-node.d.ts +18 -20
- package/dist/core/nodes/group-node.d.ts +26 -22
- package/dist/core/types/deep-schema.d.ts +2 -12
- package/dist/core/types/field-path.d.ts +1 -1
- package/dist/core/types/form-context.d.ts +27 -27
- package/dist/core/types/{group-node-proxy.d.ts → form-proxy.d.ts} +12 -42
- package/dist/core/types/index.d.ts +52 -6
- package/dist/core/types/validation-schema.d.ts +3 -12
- package/dist/core/utils/abstract-registry.d.ts +74 -0
- package/dist/core/utils/aggregate-signals.d.ts +71 -0
- package/dist/core/utils/create-form.d.ts +3 -20
- package/dist/core/utils/error-handler.d.ts +1 -18
- package/dist/core/utils/field-path-navigator.d.ts +1 -1
- package/dist/core/utils/field-path.d.ts +23 -11
- package/dist/core/utils/form-observer.d.ts +176 -0
- package/dist/core/utils/form-proxy-builder.d.ts +25 -0
- package/dist/core/utils/form-submitter.d.ts +121 -0
- package/dist/core/utils/index.d.ts +9 -2
- package/dist/core/utils/registry-helpers.d.ts +0 -7
- package/dist/core/utils/safe-effect.d.ts +73 -0
- package/dist/core/utils/status-machine.d.ts +153 -0
- package/dist/core/utils/type-guards.d.ts +5 -23
- package/dist/core/utils/unique-id.d.ts +53 -0
- package/dist/core/validation/core/apply-when.d.ts +3 -9
- package/dist/core/validation/core/apply.d.ts +2 -13
- package/dist/core/validation/core/validate-async.d.ts +2 -8
- package/dist/core/validation/core/validate-tree.d.ts +0 -6
- package/dist/core/validation/core/validate.d.ts +1 -7
- package/dist/core/validation/index.d.ts +8 -2
- package/dist/core/validation/validate-form.d.ts +1 -38
- package/dist/core/validation/validation-applicator.d.ts +2 -21
- package/dist/core/validation/validation-context.d.ts +59 -43
- package/dist/core/validation/validation-registry.d.ts +11 -25
- package/dist/core/validation/validators/array-validators.d.ts +2 -12
- package/dist/core/validation/validators/date-utils.d.ts +26 -0
- package/dist/core/validation/validators/email.d.ts +2 -9
- package/dist/core/validation/validators/future-date.d.ts +35 -0
- package/dist/core/validation/validators/index.d.ts +7 -1
- package/dist/core/validation/validators/is-date.d.ts +36 -0
- package/dist/core/validation/validators/max-age.d.ts +36 -0
- package/dist/core/validation/validators/max-date.d.ts +36 -0
- package/dist/core/validation/validators/max-length.d.ts +3 -10
- package/dist/core/validation/validators/max.d.ts +3 -10
- package/dist/core/validation/validators/min-age.d.ts +36 -0
- package/dist/core/validation/validators/min-date.d.ts +36 -0
- package/dist/core/validation/validators/min-length.d.ts +3 -10
- package/dist/core/validation/validators/min.d.ts +3 -10
- package/dist/core/validation/validators/number.d.ts +2 -9
- package/dist/core/validation/validators/past-date.d.ts +35 -0
- package/dist/core/validation/validators/pattern.d.ts +2 -9
- package/dist/core/validation/validators/phone.d.ts +2 -9
- package/dist/core/validation/validators/required.d.ts +2 -9
- package/dist/core/validation/validators/url.d.ts +2 -9
- package/dist/date-utils-xUWFslTj.js +29 -0
- package/dist/field-path-DuKdGcIE.js +66 -0
- package/dist/hooks/types.d.ts +1 -1
- package/dist/hooks/useArrayLength.d.ts +31 -0
- package/dist/hooks/useFormControl.d.ts +4 -4
- package/dist/hooks/useFormControlValue.d.ts +2 -2
- package/dist/hooks/useHiddenCondition.d.ts +25 -0
- package/dist/hooks/useSignalSubscription.d.ts +1 -1
- package/dist/index-D25LsbRm.js +73 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1171 -786
- package/dist/registry-helpers-Bv_BJ1s-.js +615 -0
- package/dist/safe-effect-Dh8uw81c.js +20 -0
- package/dist/validate-C3XiA_zf.js +10 -0
- package/dist/validators/email.d.ts +2 -0
- package/dist/validators/email.js +13 -0
- package/dist/validators/future-date.d.ts +2 -0
- package/dist/validators/future-date.js +20 -0
- package/dist/validators/is-date.d.ts +2 -0
- package/dist/validators/is-date.js +12 -0
- package/dist/validators/max-age.d.ts +2 -0
- package/dist/validators/max-age.js +20 -0
- package/dist/validators/max-date.d.ts +2 -0
- package/dist/validators/max-date.js +20 -0
- package/dist/validators/max-length.d.ts +2 -0
- package/dist/validators/max-length.js +11 -0
- package/dist/validators/max.d.ts +2 -0
- package/dist/validators/max.js +11 -0
- package/dist/validators/min-age.d.ts +2 -0
- package/dist/validators/min-age.js +20 -0
- package/dist/validators/min-date.d.ts +2 -0
- package/dist/validators/min-date.js +20 -0
- package/dist/validators/min-length.d.ts +2 -0
- package/dist/validators/min-length.js +11 -0
- package/dist/validators/min.d.ts +2 -0
- package/dist/validators/min.js +11 -0
- package/dist/validators/number.d.ts +2 -0
- package/dist/validators/number.js +35 -0
- package/dist/validators/past-date.d.ts +2 -0
- package/dist/validators/past-date.js +20 -0
- package/dist/validators/pattern.d.ts +2 -0
- package/dist/validators/pattern.js +11 -0
- package/dist/validators/phone.d.ts +2 -0
- package/dist/validators/phone.js +35 -0
- package/dist/validators/required.d.ts +2 -0
- package/dist/validators/required.js +15 -0
- package/dist/validators/url.d.ts +2 -0
- package/dist/validators/url.js +19 -0
- package/dist/validators-BGsNOgT1.js +207 -0
- package/dist/validators.js +54 -29
- package/llms.txt +7885 -318
- package/package.json +83 -8
- package/dist/behaviors-DzYL8kY_.js +0 -499
- package/dist/core/behavior/create-field-path.d.ts +0 -7
- package/dist/core/context/form-context-impl.d.ts +0 -29
- package/dist/core/utils/debounce.d.ts +0 -160
- package/dist/core/utils/resources.d.ts +0 -41
- package/dist/core/validation/field-path.d.ts +0 -7
- package/dist/core/validation/validators/date.d.ts +0 -38
- package/dist/registry-helpers-BRxAr6nG.js +0 -490
- package/dist/validators-gXoHPdqM.js +0 -418
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { v as m } from "../validate-C3XiA_zf.js";
|
|
2
|
+
import { p as c, c as o } from "../date-utils-xUWFslTj.js";
|
|
3
|
+
function l(a, e, n) {
|
|
4
|
+
a && m(a, (r) => {
|
|
5
|
+
if (r == null || r === "")
|
|
6
|
+
return null;
|
|
7
|
+
const t = c(r);
|
|
8
|
+
if (t === null)
|
|
9
|
+
return null;
|
|
10
|
+
const s = o(t);
|
|
11
|
+
return s > e ? {
|
|
12
|
+
code: "date_max_age",
|
|
13
|
+
message: n?.message || `Максимальный возраст: ${e} лет`,
|
|
14
|
+
params: { maxAge: e, currentAge: s, ...n?.params }
|
|
15
|
+
} : null;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
l as maxAge
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { v as i } from "../validate-C3XiA_zf.js";
|
|
2
|
+
import { p as l, n as m } from "../date-utils-xUWFslTj.js";
|
|
3
|
+
function c(a, e, n) {
|
|
4
|
+
a && i(a, (r) => {
|
|
5
|
+
if (r == null || r === "")
|
|
6
|
+
return null;
|
|
7
|
+
const t = l(r);
|
|
8
|
+
if (t === null)
|
|
9
|
+
return null;
|
|
10
|
+
const s = m(t), o = m(e);
|
|
11
|
+
return s > o ? {
|
|
12
|
+
code: "date_max",
|
|
13
|
+
message: n?.message || `Дата должна быть не позднее ${o.toLocaleDateString()}`,
|
|
14
|
+
params: { maxDate: e, ...n?.params }
|
|
15
|
+
} : null;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
c as maxDate
|
|
20
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { v as a } from "../validate-C3XiA_zf.js";
|
|
2
|
+
function m(e, r, n) {
|
|
3
|
+
e && a(e, (t) => t && t.length > r ? {
|
|
4
|
+
code: "maxLength",
|
|
5
|
+
message: n?.message || `Максимальная длина: ${r} символов`,
|
|
6
|
+
params: { maxLength: r, actualLength: t.length, ...n?.params }
|
|
7
|
+
} : null);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
m as maxLength
|
|
11
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { v as a } from "../validate-C3XiA_zf.js";
|
|
2
|
+
function e(m, n, t) {
|
|
3
|
+
m && a(m, (r) => r == null ? null : r > n ? {
|
|
4
|
+
code: "max",
|
|
5
|
+
message: t?.message || `Максимальное значение: ${n}`,
|
|
6
|
+
params: { max: n, actual: r, ...t?.params }
|
|
7
|
+
} : null);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
e as max
|
|
11
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { v as m } from "../validate-C3XiA_zf.js";
|
|
2
|
+
import { p as c, c as i } from "../date-utils-xUWFslTj.js";
|
|
3
|
+
function l(n, e, t) {
|
|
4
|
+
n && m(n, (r) => {
|
|
5
|
+
if (r == null || r === "")
|
|
6
|
+
return null;
|
|
7
|
+
const a = c(r);
|
|
8
|
+
if (a === null)
|
|
9
|
+
return null;
|
|
10
|
+
const s = i(a);
|
|
11
|
+
return s < e ? {
|
|
12
|
+
code: "date_min_age",
|
|
13
|
+
message: t?.message || `Минимальный возраст: ${e} лет`,
|
|
14
|
+
params: { minAge: e, currentAge: s, ...t?.params }
|
|
15
|
+
} : null;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
l as minAge
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { v as s } from "../validate-C3XiA_zf.js";
|
|
2
|
+
import { p as l, n as o } from "../date-utils-xUWFslTj.js";
|
|
3
|
+
function c(n, e, a) {
|
|
4
|
+
n && s(n, (r) => {
|
|
5
|
+
if (r == null || r === "")
|
|
6
|
+
return null;
|
|
7
|
+
const t = l(r);
|
|
8
|
+
if (t === null)
|
|
9
|
+
return null;
|
|
10
|
+
const m = o(t), i = o(e);
|
|
11
|
+
return m < i ? {
|
|
12
|
+
code: "date_min",
|
|
13
|
+
message: a?.message || `Дата должна быть не ранее ${i.toLocaleDateString()}`,
|
|
14
|
+
params: { minDate: e, ...a?.params }
|
|
15
|
+
} : null;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
c as minDate
|
|
20
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { v as a } from "../validate-C3XiA_zf.js";
|
|
2
|
+
function m(e, r, n) {
|
|
3
|
+
e && a(e, (t) => t && t.length < r ? {
|
|
4
|
+
code: "minLength",
|
|
5
|
+
message: n?.message || `Минимальная длина: ${r} символов`,
|
|
6
|
+
params: { minLength: r, actualLength: t.length, ...n?.params }
|
|
7
|
+
} : null);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
m as minLength
|
|
11
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { v as i } from "../validate-C3XiA_zf.js";
|
|
2
|
+
function a(m, n, t) {
|
|
3
|
+
m && i(m, (r) => r == null ? null : r < n ? {
|
|
4
|
+
code: "min",
|
|
5
|
+
message: t?.message || `Минимальное значение: ${n}`,
|
|
6
|
+
params: { min: n, actual: r, ...t?.params }
|
|
7
|
+
} : null);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
a as min
|
|
11
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { v as a } from "../validate-C3XiA_zf.js";
|
|
2
|
+
function g(r, e) {
|
|
3
|
+
r && a(r, (m) => m == null ? null : typeof m != "number" || isNaN(m) ? {
|
|
4
|
+
code: "number",
|
|
5
|
+
message: e?.message || "Значение должно быть числом",
|
|
6
|
+
params: e?.params
|
|
7
|
+
} : e?.integer && !Number.isInteger(m) ? {
|
|
8
|
+
code: "number_integer",
|
|
9
|
+
message: e?.message || "Значение должно быть целым числом",
|
|
10
|
+
params: e?.params
|
|
11
|
+
} : e?.min !== void 0 && m < e.min ? {
|
|
12
|
+
code: "number_min",
|
|
13
|
+
message: e?.message || `Значение должно быть не менее ${e.min}`,
|
|
14
|
+
params: { min: e.min, ...e?.params }
|
|
15
|
+
} : e?.max !== void 0 && m > e.max ? {
|
|
16
|
+
code: "number_max",
|
|
17
|
+
message: e?.message || `Значение должно быть не более ${e.max}`,
|
|
18
|
+
params: { max: e.max, ...e?.params }
|
|
19
|
+
} : e?.multipleOf !== void 0 && m % e.multipleOf !== 0 ? {
|
|
20
|
+
code: "number_multiple",
|
|
21
|
+
message: e?.message || `Значение должно быть кратно ${e.multipleOf}`,
|
|
22
|
+
params: { multipleOf: e.multipleOf, ...e?.params }
|
|
23
|
+
} : e?.allowNegative === !1 && m < 0 ? {
|
|
24
|
+
code: "number_negative",
|
|
25
|
+
message: e?.message || "Отрицательные числа не допускаются",
|
|
26
|
+
params: e?.params
|
|
27
|
+
} : e?.allowZero === !1 && m === 0 ? {
|
|
28
|
+
code: "number_zero",
|
|
29
|
+
message: e?.message || "Ноль не допускается",
|
|
30
|
+
params: e?.params
|
|
31
|
+
} : null);
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
g as number
|
|
35
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { v as o } from "../validate-C3XiA_zf.js";
|
|
2
|
+
import { p as u, n as l, g as m } from "../date-utils-xUWFslTj.js";
|
|
3
|
+
function d(a, e) {
|
|
4
|
+
a && o(a, (r) => {
|
|
5
|
+
if (r == null || r === "")
|
|
6
|
+
return null;
|
|
7
|
+
const t = u(r);
|
|
8
|
+
if (t === null)
|
|
9
|
+
return null;
|
|
10
|
+
const n = l(t), s = m();
|
|
11
|
+
return n > s ? {
|
|
12
|
+
code: "date_future",
|
|
13
|
+
message: e?.message || "Дата не может быть в будущем",
|
|
14
|
+
params: e?.params
|
|
15
|
+
} : null;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
d as pastDate
|
|
20
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { v as n } from "../validate-C3XiA_zf.js";
|
|
2
|
+
function u(r, t, e) {
|
|
3
|
+
r && n(r, (a) => a ? t.test(a) ? null : {
|
|
4
|
+
code: "pattern",
|
|
5
|
+
message: e?.message || "Значение не соответствует требуемому формату",
|
|
6
|
+
params: { pattern: t.source, ...e?.params }
|
|
7
|
+
} : null);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
u as pattern
|
|
11
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { v as o } from "../validate-C3XiA_zf.js";
|
|
2
|
+
function f(n, s) {
|
|
3
|
+
if (!n) return;
|
|
4
|
+
const r = s?.format || "any", t = {
|
|
5
|
+
// Международный формат: +1234567890 или +1 234 567 8900
|
|
6
|
+
international: /^\+?[1-9]\d{1,14}$/,
|
|
7
|
+
// Российский формат: +7 (XXX) XXX-XX-XX, 8 (XXX) XXX-XX-XX, и вариации
|
|
8
|
+
ru: /^(\+7|7|8)?[\s-]?\(?[489][0-9]{2}\)?[\s-]?[0-9]{3}[\s-]?[0-9]{2}[\s-]?[0-9]{2}$/,
|
|
9
|
+
// US формат: (123) 456-7890, 123-456-7890, 1234567890
|
|
10
|
+
us: /^(\+?1)?[\s-]?\(?[2-9]\d{2}\)?[\s-]?\d{3}[\s-]?\d{4}$/,
|
|
11
|
+
// Любой формат: минимум 10 цифр с возможными разделителями
|
|
12
|
+
any: /^[+]?[(]?[0-9]{1,4}[)]?[-\s.]?[(]?[0-9]{1,4}[)]?[-\s.]?[0-9]{1,9}$/
|
|
13
|
+
};
|
|
14
|
+
o(n, (e) => {
|
|
15
|
+
if (!e)
|
|
16
|
+
return null;
|
|
17
|
+
if (!t[r].test(e)) {
|
|
18
|
+
const a = {
|
|
19
|
+
international: "Введите телефон в международном формате (например, +1234567890)",
|
|
20
|
+
ru: "Введите российский номер телефона (например, +7 900 123-45-67)",
|
|
21
|
+
us: "Введите американский номер телефона (например, (123) 456-7890)",
|
|
22
|
+
any: "Неверный формат телефона"
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
code: "phone",
|
|
26
|
+
message: s?.message || a[r],
|
|
27
|
+
params: { format: r, ...s?.params }
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
f as phone
|
|
35
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { v as m } from "../validate-C3XiA_zf.js";
|
|
2
|
+
function u(a, e) {
|
|
3
|
+
a && m(a, (r) => r == null || r === "" ? {
|
|
4
|
+
code: "required",
|
|
5
|
+
message: e?.message || "Поле обязательно для заполнения",
|
|
6
|
+
params: e?.params
|
|
7
|
+
} : typeof r == "boolean" && r !== !0 ? {
|
|
8
|
+
code: "required",
|
|
9
|
+
message: e?.message || "Поле обязательно для заполнения",
|
|
10
|
+
params: e?.params
|
|
11
|
+
} : null);
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
u as required
|
|
15
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { v as s } from "../validate-C3XiA_zf.js";
|
|
2
|
+
function m(e, r) {
|
|
3
|
+
if (!e) return;
|
|
4
|
+
const l = /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/i, t = /^https?:\/\/([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/i;
|
|
5
|
+
s(e, (o) => o ? (r?.requireProtocol ? t : l).test(o) ? r?.allowedProtocols && r.allowedProtocols.length > 0 && !r.allowedProtocols.some(
|
|
6
|
+
(a) => o.toLowerCase().startsWith(`${a}://`)
|
|
7
|
+
) ? {
|
|
8
|
+
code: "url_protocol",
|
|
9
|
+
message: r?.message || `URL должен использовать один из протоколов: ${r.allowedProtocols.join(", ")}`,
|
|
10
|
+
params: { allowedProtocols: r.allowedProtocols, ...r?.params }
|
|
11
|
+
} : null : {
|
|
12
|
+
code: "url",
|
|
13
|
+
message: r?.message || "Неверный формат URL",
|
|
14
|
+
params: r?.params
|
|
15
|
+
} : null);
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
m as url
|
|
19
|
+
};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { g as a, V as u } from "./registry-helpers-Bv_BJ1s-.js";
|
|
2
|
+
import { e as m, t as y, c, a as _ } from "./field-path-DuKdGcIE.js";
|
|
3
|
+
import { v as N } from "./validate-C3XiA_zf.js";
|
|
4
|
+
import { required as C } from "./validators/required.js";
|
|
5
|
+
import { min as P } from "./validators/min.js";
|
|
6
|
+
import { max as F } from "./validators/max.js";
|
|
7
|
+
import { minLength as d } from "./validators/min-length.js";
|
|
8
|
+
import { maxLength as b } from "./validators/max-length.js";
|
|
9
|
+
import { email as B } from "./validators/email.js";
|
|
10
|
+
import { pattern as T } from "./validators/pattern.js";
|
|
11
|
+
import { url as I } from "./validators/url.js";
|
|
12
|
+
import { phone as R } from "./validators/phone.js";
|
|
13
|
+
import { number as w } from "./validators/number.js";
|
|
14
|
+
import { isDate as D } from "./validators/is-date.js";
|
|
15
|
+
import { minDate as j } from "./validators/min-date.js";
|
|
16
|
+
import { maxDate as k } from "./validators/max-date.js";
|
|
17
|
+
import { pastDate as E } from "./validators/past-date.js";
|
|
18
|
+
import { futureDate as K } from "./validators/future-date.js";
|
|
19
|
+
import { minAge as L } from "./validators/min-age.js";
|
|
20
|
+
import { maxAge as G } from "./validators/max-age.js";
|
|
21
|
+
function M(t, r, i) {
|
|
22
|
+
const e = m(t);
|
|
23
|
+
a().registerAsync(e, r, i);
|
|
24
|
+
}
|
|
25
|
+
function q(t, r) {
|
|
26
|
+
a().registerTree(t, r);
|
|
27
|
+
}
|
|
28
|
+
function z(t, r) {
|
|
29
|
+
if (!Array.isArray(t) && !Array.isArray(r) && t && !("__key" in t) && !("__path" in t)) {
|
|
30
|
+
r(t);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const i = (Array.isArray(t) ? t : [t]).filter(
|
|
34
|
+
Boolean
|
|
35
|
+
), e = Array.isArray(r) ? r : [r];
|
|
36
|
+
for (const n of i) {
|
|
37
|
+
const o = y(n);
|
|
38
|
+
for (const p of e)
|
|
39
|
+
p(o);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function S(t, r, i) {
|
|
43
|
+
const e = m(t);
|
|
44
|
+
a().enterCondition(e, r);
|
|
45
|
+
try {
|
|
46
|
+
const n = c();
|
|
47
|
+
i(n);
|
|
48
|
+
} finally {
|
|
49
|
+
a().exitCondition();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function U(t, r) {
|
|
53
|
+
t && d(t, 1, {
|
|
54
|
+
message: r?.message || "Массив не должен быть пустым",
|
|
55
|
+
params: { minLength: 1, ...r?.params }
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function W(t, r) {
|
|
59
|
+
if (!t) return;
|
|
60
|
+
const i = m(t);
|
|
61
|
+
a().registerArrayItemValidation(i, r);
|
|
62
|
+
}
|
|
63
|
+
function s(t) {
|
|
64
|
+
return t == null ? !1 : typeof t == "object" && "value" in t && "setValue" in t && "getValue" in t && "validate" in t;
|
|
65
|
+
}
|
|
66
|
+
function g(t) {
|
|
67
|
+
return t == null ? !1 : s(t) && "validators" in t && "asyncValidators" in t && // FieldNode имеет markAsTouched метод
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
|
+
typeof t.markAsTouched == "function" && // У FieldNode нет fields или items
|
|
70
|
+
!("fields" in t) && !("items" in t);
|
|
71
|
+
}
|
|
72
|
+
function h(t) {
|
|
73
|
+
return t == null ? !1 : s(t) && "applyValidationSchema" in t && "applyBehaviorSchema" in t && "getFieldByPath" in t && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode)
|
|
74
|
+
!("items" in t) && !("push" in t) && !("removeAt" in t);
|
|
75
|
+
}
|
|
76
|
+
function A(t) {
|
|
77
|
+
return t == null ? !1 : s(t) && "items" in t && "length" in t && "push" in t && "removeAt" in t && "at" in t && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
+
typeof t.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
+
typeof t.removeAt == "function";
|
|
80
|
+
}
|
|
81
|
+
function yt(t) {
|
|
82
|
+
return g(t) ? "FieldNode" : h(t) ? "GroupNode" : A(t) ? "ArrayNode" : s(t) ? "FormNode" : "Unknown";
|
|
83
|
+
}
|
|
84
|
+
function f(t) {
|
|
85
|
+
return g(t) ? [t] : h(t) ? Array.from(t.getAllFields()).flatMap(f) : A(t) ? t.map((r) => f(r)).flat() : [];
|
|
86
|
+
}
|
|
87
|
+
async function H(t, r) {
|
|
88
|
+
const i = new u();
|
|
89
|
+
i.beginRegistration();
|
|
90
|
+
let e = [], n = !1;
|
|
91
|
+
try {
|
|
92
|
+
const o = c();
|
|
93
|
+
r(o), e = i.getCurrentContext()?.getValidators() || [], i.cancelRegistration(), n = !0, t.clearErrors();
|
|
94
|
+
const x = f(t);
|
|
95
|
+
return await Promise.allSettled(x.map((V) => V.validate())), e.length > 0 && await t.applyContextualValidators(e), t.valid.value;
|
|
96
|
+
} catch (o) {
|
|
97
|
+
throw n || i.cancelRegistration(), o;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
class l {
|
|
101
|
+
_form;
|
|
102
|
+
/**
|
|
103
|
+
* Форма с типизированным Proxy-доступом к полям
|
|
104
|
+
*/
|
|
105
|
+
form;
|
|
106
|
+
constructor(r) {
|
|
107
|
+
this._form = r, this.form = r._proxyInstance || r.getProxy();
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Безопасно установить значение поля по строковому пути
|
|
111
|
+
* Автоматически использует emitEvent: false для предотвращения циклов
|
|
112
|
+
*/
|
|
113
|
+
setFieldValue(r, i) {
|
|
114
|
+
const e = this._form.getFieldByPath(r);
|
|
115
|
+
e && s(e) && e.setValue(i, { emitEvent: !1 });
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Получить поле формы по строковому пути
|
|
119
|
+
*/
|
|
120
|
+
getFieldByPath(r) {
|
|
121
|
+
return this._form.getFieldByPath(r);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
class J extends l {
|
|
125
|
+
control;
|
|
126
|
+
constructor(r, i, e) {
|
|
127
|
+
super(r), this.control = e;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Получить текущее значение поля (внутренний метод для validation-applicator)
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
133
|
+
value() {
|
|
134
|
+
return this.control.value.value;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
class Q extends l {
|
|
138
|
+
constructor(r) {
|
|
139
|
+
super(r);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
class dt extends l {
|
|
143
|
+
arrayValue;
|
|
144
|
+
constructor(r, i, e) {
|
|
145
|
+
super(r), this.arrayValue = e;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Получить текущее значение массива (для валидатора)
|
|
149
|
+
* @internal
|
|
150
|
+
*/
|
|
151
|
+
value() {
|
|
152
|
+
return this.arrayValue;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const gt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
156
|
+
__proto__: null,
|
|
157
|
+
TreeValidationContextImpl: Q,
|
|
158
|
+
ValidationContextImpl: J,
|
|
159
|
+
ValidationRegistry: u,
|
|
160
|
+
apply: z,
|
|
161
|
+
applyWhen: S,
|
|
162
|
+
createFieldPath: c,
|
|
163
|
+
email: B,
|
|
164
|
+
extractKey: _,
|
|
165
|
+
extractPath: m,
|
|
166
|
+
futureDate: K,
|
|
167
|
+
isDate: D,
|
|
168
|
+
max: F,
|
|
169
|
+
maxAge: G,
|
|
170
|
+
maxDate: k,
|
|
171
|
+
maxLength: b,
|
|
172
|
+
min: P,
|
|
173
|
+
minAge: L,
|
|
174
|
+
minDate: j,
|
|
175
|
+
minLength: d,
|
|
176
|
+
notEmpty: U,
|
|
177
|
+
number: w,
|
|
178
|
+
pastDate: E,
|
|
179
|
+
pattern: T,
|
|
180
|
+
phone: R,
|
|
181
|
+
required: C,
|
|
182
|
+
toFieldPath: y,
|
|
183
|
+
url: I,
|
|
184
|
+
validate: N,
|
|
185
|
+
validateAsync: M,
|
|
186
|
+
validateForm: H,
|
|
187
|
+
validateItems: W,
|
|
188
|
+
validateTree: q
|
|
189
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
190
|
+
export {
|
|
191
|
+
dt as A,
|
|
192
|
+
Q as T,
|
|
193
|
+
J as V,
|
|
194
|
+
A as a,
|
|
195
|
+
gt as b,
|
|
196
|
+
s as c,
|
|
197
|
+
h as d,
|
|
198
|
+
M as e,
|
|
199
|
+
q as f,
|
|
200
|
+
yt as g,
|
|
201
|
+
z as h,
|
|
202
|
+
g as i,
|
|
203
|
+
S as j,
|
|
204
|
+
W as k,
|
|
205
|
+
U as n,
|
|
206
|
+
H as v
|
|
207
|
+
};
|
package/dist/validators.js
CHANGED
|
@@ -1,31 +1,56 @@
|
|
|
1
|
-
import { T as
|
|
2
|
-
import {
|
|
1
|
+
import { T as r, V as a, h as o, j as m, b as p, n as x, e as f, v as i, k as s, f as n } from "./validators-BGsNOgT1.js";
|
|
2
|
+
import { v as d } from "./validate-C3XiA_zf.js";
|
|
3
|
+
import { required as v } from "./validators/required.js";
|
|
4
|
+
import { min as y } from "./validators/min.js";
|
|
5
|
+
import { max as g } from "./validators/max.js";
|
|
6
|
+
import { minLength as V } from "./validators/min-length.js";
|
|
7
|
+
import { maxLength as F } from "./validators/max-length.js";
|
|
8
|
+
import { email as P } from "./validators/email.js";
|
|
9
|
+
import { pattern as b } from "./validators/pattern.js";
|
|
10
|
+
import { url as L } from "./validators/url.js";
|
|
11
|
+
import { phone as k } from "./validators/phone.js";
|
|
12
|
+
import { number as E } from "./validators/number.js";
|
|
13
|
+
import { isDate as R } from "./validators/is-date.js";
|
|
14
|
+
import { minDate as w } from "./validators/min-date.js";
|
|
15
|
+
import { maxDate as B } from "./validators/max-date.js";
|
|
16
|
+
import { pastDate as H } from "./validators/past-date.js";
|
|
17
|
+
import { futureDate as M } from "./validators/future-date.js";
|
|
18
|
+
import { minAge as O } from "./validators/min-age.js";
|
|
19
|
+
import { maxAge as S } from "./validators/max-age.js";
|
|
20
|
+
import { c as X, a as Y, e as Z, t as _ } from "./field-path-DuKdGcIE.js";
|
|
21
|
+
import { V as ee } from "./registry-helpers-Bv_BJ1s-.js";
|
|
3
22
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
y as
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
r as TreeValidationContextImpl,
|
|
24
|
+
a as ValidationContextImpl,
|
|
25
|
+
ee as ValidationRegistry,
|
|
26
|
+
o as apply,
|
|
27
|
+
m as applyWhen,
|
|
28
|
+
X as createFieldPath,
|
|
29
|
+
p as default,
|
|
30
|
+
P as email,
|
|
31
|
+
Y as extractKey,
|
|
32
|
+
Z as extractPath,
|
|
33
|
+
M as futureDate,
|
|
34
|
+
R as isDate,
|
|
35
|
+
g as max,
|
|
36
|
+
S as maxAge,
|
|
37
|
+
B as maxDate,
|
|
38
|
+
F as maxLength,
|
|
39
|
+
y as min,
|
|
40
|
+
O as minAge,
|
|
41
|
+
w as minDate,
|
|
42
|
+
V as minLength,
|
|
43
|
+
x as notEmpty,
|
|
44
|
+
E as number,
|
|
45
|
+
H as pastDate,
|
|
46
|
+
b as pattern,
|
|
47
|
+
k as phone,
|
|
48
|
+
v as required,
|
|
49
|
+
_ as toFieldPath,
|
|
50
|
+
L as url,
|
|
51
|
+
d as validate,
|
|
52
|
+
f as validateAsync,
|
|
53
|
+
i as validateForm,
|
|
54
|
+
s as validateItems,
|
|
55
|
+
n as validateTree
|
|
31
56
|
};
|