@reformer/core 11.0.0-beta.5 → 11.0.0-beta.7
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.js +124 -124
- package/dist/create-model-B8U-COv-.js +103 -0
- package/dist/en-CjAqn7h0.js +41 -0
- package/dist/form/behaviors/internals.d.ts +9 -0
- package/dist/form/create-form.d.ts +6 -6
- package/dist/form/factories/node-factory.d.ts +16 -16
- package/dist/form/nodes/array-node.d.ts +3 -3
- package/dist/form/nodes/field-node.d.ts +3 -3
- package/dist/form/nodes/group-node.d.ts +7 -7
- package/dist/form/nodes/model-array-node.d.ts +2 -2
- package/dist/form/types/contracts.d.ts +6 -0
- package/dist/form/types/deep-schema.d.ts +5 -5
- package/dist/form/types/validation-schema.d.ts +13 -1
- package/dist/form/validation/operators.d.ts +6 -1
- package/dist/form/validators/validation-error.d.ts +8 -0
- package/dist/i18n/descriptor.d.ts +54 -0
- package/dist/i18n/en.json.d.ts +45 -0
- package/dist/i18n/loader.d.ts +71 -0
- package/dist/i18n/locale-store.d.ts +39 -0
- package/dist/i18n/locale.d.ts +90 -0
- package/dist/i18n/message-format.d.ts +116 -0
- package/dist/i18n/resolve-localized.d.ts +17 -0
- package/dist/i18n/ru.json.d.ts +45 -0
- package/dist/i18n/translator.d.ts +50 -0
- package/dist/i18n/validation-message.d.ts +18 -0
- package/dist/i18n.d.ts +31 -0
- package/dist/i18n.js +303 -0
- package/dist/index-BrNkQj1y.js +105 -0
- package/dist/index.js +548 -601
- package/dist/loader-Dv_Hl7JC.js +216 -0
- package/dist/locale/en.d.ts +2 -0
- package/dist/locale/en.js +5 -0
- package/dist/locale/en.json +42 -0
- package/dist/locale/index.d.ts +18 -0
- package/dist/locale/ru.d.ts +2 -0
- package/dist/locale/ru.js +41 -0
- package/dist/locale/ru.json +42 -0
- package/dist/locale.d.ts +2 -0
- package/dist/locale.js +9 -0
- package/dist/model/create-model.d.ts +17 -3
- package/dist/model/index.d.ts +3 -3
- package/dist/model/model-signals-proxy.d.ts +25 -0
- package/dist/model/types.d.ts +19 -5
- package/dist/model-signals-proxy-2vqS243J.js +250 -0
- package/dist/model.js +18 -16
- package/dist/platforms/react/field-binding/field-adapter.d.ts +87 -0
- package/dist/platforms/react/field-binding/field-handle.d.ts +50 -0
- package/dist/platforms/react/hooks/types.d.ts +6 -3
- package/dist/platforms/react/hooks/useFormControlValue.d.ts +2 -1
- package/dist/platforms/react/i18n/context.d.ts +13 -0
- package/dist/platforms/react/i18n/hooks.d.ts +59 -0
- package/dist/platforms/react/i18n/provider.d.ts +52 -0
- package/dist/platforms/react/index.d.ts +4 -0
- package/dist/{strategy-DA3JwxsR.js → strategy-BXS_gBfz.js} +7 -7
- package/dist/validation-error-B-U3RsV0.js +11 -0
- package/dist/validation.js +1 -1
- package/dist/validators/email.js +5 -8
- package/dist/validators/future-date.js +8 -11
- package/dist/validators/integer.js +4 -7
- package/dist/validators/is-date.js +5 -8
- package/dist/validators/is-number.js +4 -7
- package/dist/validators/max-age.js +8 -11
- package/dist/validators/max-date.js +8 -11
- package/dist/validators/max-length.js +5 -8
- package/dist/validators/max.js +4 -7
- package/dist/validators/min-age.js +8 -11
- package/dist/validators/min-date.js +8 -11
- package/dist/validators/min-length.js +5 -8
- package/dist/validators/min.js +4 -7
- package/dist/validators/multiple-of.js +5 -8
- package/dist/validators/non-negative.js +4 -7
- package/dist/validators/non-zero.js +4 -7
- package/dist/validators/past-date.js +8 -11
- package/dist/validators/pattern.js +5 -8
- package/dist/validators/phone.js +6 -9
- package/dist/validators/required.js +4 -7
- package/dist/validators/url.js +9 -14
- package/dist/validators.js +84 -106
- package/docs/llms/02-quick-start.md +7 -7
- package/docs/llms/03-api-signatures.md +11 -5
- package/docs/llms/05-common-mistakes.md +1 -1
- package/docs/llms/09-formschema.md +12 -12
- package/docs/llms/10-arrays.md +34 -4
- package/docs/llms/14-extended-mistakes.md +1 -1
- package/docs/llms/15-project-structure.md +15 -13
- package/docs/llms/16-ui-components.md +36 -9
- package/docs/llms/17-nonexistent-api.md +16 -2
- package/docs/llms/29-async-preload.md +4 -4
- package/docs/llms/30-type-safety-recipes.md +1 -1
- package/docs/llms/34-i18n.md +272 -0
- package/llms-index.json +1 -1
- package/llms.txt +1925 -175
- package/package.json +22 -3
- package/dist/create-model-Dxh9cfLp.js +0 -97
- package/dist/model-signals-proxy-mV3WGdlO.js +0 -233
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { signal as A, effect as M } from "@preact/signals-core";
|
|
2
|
-
import {
|
|
2
|
+
import { a as W } from "./create-model-B8U-COv-.js";
|
|
3
3
|
import { g as v } from "./signal-node-registry-tiwel-TV.js";
|
|
4
4
|
let g = null;
|
|
5
5
|
function E(e, n) {
|
|
@@ -75,23 +75,23 @@ function z(e) {
|
|
|
75
75
|
return e;
|
|
76
76
|
}
|
|
77
77
|
const x = /* @__PURE__ */ new WeakMap();
|
|
78
|
-
function
|
|
78
|
+
function P(e, n) {
|
|
79
79
|
let t = x.get(e);
|
|
80
80
|
t || x.set(e, t = /* @__PURE__ */ new WeakMap());
|
|
81
81
|
let r = t.get(n);
|
|
82
82
|
return r || t.set(n, r = { fields: /* @__PURE__ */ new Set(), ac: null }), r;
|
|
83
83
|
}
|
|
84
|
-
const
|
|
84
|
+
const T = (e) => {
|
|
85
85
|
for (const n of e.values()) for (const t of n) if (t.severity !== "warning") return !0;
|
|
86
86
|
return !1;
|
|
87
87
|
};
|
|
88
|
-
function
|
|
88
|
+
function V(e) {
|
|
89
89
|
return e.aborted ? Promise.resolve() : new Promise((n) => {
|
|
90
90
|
e.addEventListener("abort", () => n(), { once: !0 });
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
async function C(e, n, t) {
|
|
94
|
-
const r =
|
|
94
|
+
const r = P(e, n);
|
|
95
95
|
r.ac?.abort();
|
|
96
96
|
const o = new AbortController();
|
|
97
97
|
r.ac = o;
|
|
@@ -102,12 +102,12 @@ async function C(e, n, t) {
|
|
|
102
102
|
whenStack: [],
|
|
103
103
|
signal: o.signal
|
|
104
104
|
};
|
|
105
|
-
if (E(a, () => n({ model: e })), a.pending.length && await Promise.race([Promise.all(a.pending),
|
|
105
|
+
if (E(a, () => n({ model: e })), a.pending.length && await Promise.race([Promise.all(a.pending), V(o.signal)]), o.signal.aborted) return !1;
|
|
106
106
|
const i = new Set(a.errors.keys());
|
|
107
107
|
for (const s of r.fields) i.has(s) || v(s)?.setErrors([]);
|
|
108
108
|
for (const s of i) v(s)?.setErrors(a.errors.get(s) ?? []);
|
|
109
109
|
if (t?.touch) for (const s of i) v(s)?.markAsTouched();
|
|
110
|
-
return r.fields = i, !
|
|
110
|
+
return r.fields = i, !T(a.errors);
|
|
111
111
|
}
|
|
112
112
|
function G(e, n, t = {}) {
|
|
113
113
|
const { strategy: r = "submit", debounce: o = 0, liveAfterSubmit: a = "change" } = t, i = A(!1);
|
package/dist/validation.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as s, h as d, c as i, f as l, e as t, v as o, a as c, g as n, b as r } from "./strategy-
|
|
1
|
+
import { d as s, h as d, c as i, f as l, e as t, v as o, a as c, g as n, b as r } from "./strategy-BXS_gBfz.js";
|
|
2
2
|
export {
|
|
3
3
|
s as apply,
|
|
4
4
|
d as createFormValidation,
|
package/dist/validators/email.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
message: e?.message ?? "invalid",
|
|
6
|
-
params: e?.params
|
|
7
|
-
} : null;
|
|
1
|
+
import { v as n } from "../validation-error-B-U3RsV0.js";
|
|
2
|
+
const i = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
3
|
+
function o(t) {
|
|
4
|
+
return (r) => r ? i.test(r) ? null : n("email", t) : null;
|
|
8
5
|
}
|
|
9
6
|
export {
|
|
10
|
-
|
|
7
|
+
o as email
|
|
11
8
|
};
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { p as
|
|
2
|
-
|
|
1
|
+
import { p as e, n as i, g as l } from "../date-utils-dTT_x_Be.js";
|
|
2
|
+
import { v as u } from "../validation-error-B-U3RsV0.js";
|
|
3
|
+
function f(n) {
|
|
3
4
|
return (r) => {
|
|
4
5
|
if (r == null || r === "")
|
|
5
6
|
return null;
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
7
|
+
const t = e(r);
|
|
8
|
+
if (t === null)
|
|
8
9
|
return null;
|
|
9
|
-
const
|
|
10
|
-
return
|
|
11
|
-
code: "date_past",
|
|
12
|
-
message: a?.message ?? "invalid",
|
|
13
|
-
params: a?.params
|
|
14
|
-
} : null;
|
|
10
|
+
const o = i(t), a = l();
|
|
11
|
+
return o < a ? u("date_past", n) : null;
|
|
15
12
|
};
|
|
16
13
|
}
|
|
17
14
|
export {
|
|
18
|
-
|
|
15
|
+
f as futureDate
|
|
19
16
|
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
message: e?.message ?? "invalid",
|
|
5
|
-
params: e?.params
|
|
6
|
-
};
|
|
1
|
+
import { v as t } from "../validation-error-B-U3RsV0.js";
|
|
2
|
+
function e(n) {
|
|
3
|
+
return (r) => r == null || typeof r != "number" || isNaN(r) || Number.isInteger(r) ? null : t("integer", n);
|
|
7
4
|
}
|
|
8
5
|
export {
|
|
9
|
-
|
|
6
|
+
e as integer
|
|
10
7
|
};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { p as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
message: e?.message ?? "invalid",
|
|
6
|
-
params: e?.params
|
|
7
|
-
} : null;
|
|
1
|
+
import { p as t } from "../date-utils-dTT_x_Be.js";
|
|
2
|
+
import { v as i } from "../validation-error-B-U3RsV0.js";
|
|
3
|
+
function l(n) {
|
|
4
|
+
return (r) => r == null || r === "" ? null : t(r) === null ? i("date_invalid", n) : null;
|
|
8
5
|
}
|
|
9
6
|
export {
|
|
10
|
-
|
|
7
|
+
l as isDate
|
|
11
8
|
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
message: e?.message ?? "invalid",
|
|
5
|
-
params: e?.params
|
|
6
|
-
} : null;
|
|
1
|
+
import { v as i } from "../validation-error-B-U3RsV0.js";
|
|
2
|
+
function o(n) {
|
|
3
|
+
return (r) => r == null ? null : typeof r != "number" || isNaN(r) ? i("isNumber", n) : null;
|
|
7
4
|
}
|
|
8
5
|
export {
|
|
9
|
-
|
|
6
|
+
o as isNumber
|
|
10
7
|
};
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { p as
|
|
2
|
-
|
|
1
|
+
import { p as o, c as i } from "../date-utils-dTT_x_Be.js";
|
|
2
|
+
import { v as l } from "../validation-error-B-U3RsV0.js";
|
|
3
|
+
function s(n, a) {
|
|
3
4
|
return (r) => {
|
|
4
5
|
if (r == null || r === "")
|
|
5
6
|
return null;
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
7
|
+
const t = o(r);
|
|
8
|
+
if (t === null)
|
|
8
9
|
return null;
|
|
9
|
-
const
|
|
10
|
-
return
|
|
11
|
-
code: "date_max_age",
|
|
12
|
-
message: a?.message ?? "invalid",
|
|
13
|
-
params: { maxAge: e, currentAge: t, ...a?.params }
|
|
14
|
-
} : null;
|
|
10
|
+
const e = i(t);
|
|
11
|
+
return e > n ? l("date_max_age", a, { maxAge: n, currentAge: e }) : null;
|
|
15
12
|
};
|
|
16
13
|
}
|
|
17
14
|
export {
|
|
18
|
-
|
|
15
|
+
s as maxAge
|
|
19
16
|
};
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { p as
|
|
2
|
-
|
|
1
|
+
import { p as l, n as o } from "../date-utils-dTT_x_Be.js";
|
|
2
|
+
import { v as m } from "../validation-error-B-U3RsV0.js";
|
|
3
|
+
function d(n, a) {
|
|
3
4
|
return (r) => {
|
|
4
5
|
if (r == null || r === "")
|
|
5
6
|
return null;
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
7
|
+
const t = l(r);
|
|
8
|
+
if (t === null)
|
|
8
9
|
return null;
|
|
9
|
-
const
|
|
10
|
-
return
|
|
11
|
-
code: "date_max",
|
|
12
|
-
message: a?.message ?? "invalid",
|
|
13
|
-
params: { maxDate: n, ...a?.params }
|
|
14
|
-
} : null;
|
|
10
|
+
const e = o(t), i = o(n);
|
|
11
|
+
return e > i ? m("date_max", a, { maxDate: n }) : null;
|
|
15
12
|
};
|
|
16
13
|
}
|
|
17
14
|
export {
|
|
18
|
-
|
|
15
|
+
d as maxDate
|
|
19
16
|
};
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { v as l } from "../validation-error-B-U3RsV0.js";
|
|
2
|
+
function u(t, e) {
|
|
2
3
|
return (n) => {
|
|
3
4
|
if (n == null || n === "")
|
|
4
5
|
return null;
|
|
5
|
-
const
|
|
6
|
-
return typeof
|
|
7
|
-
code: "maxLength",
|
|
8
|
-
message: t?.message ?? "invalid",
|
|
9
|
-
params: { maxLength: r, actualLength: e, ...t?.params }
|
|
10
|
-
} : null;
|
|
6
|
+
const r = n.length;
|
|
7
|
+
return typeof r != "number" ? null : r > t ? l("maxLength", e, { maxLength: t, actualLength: r }) : null;
|
|
11
8
|
};
|
|
12
9
|
}
|
|
13
10
|
export {
|
|
14
|
-
|
|
11
|
+
u as maxLength
|
|
15
12
|
};
|
package/dist/validators/max.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
message: a?.message ?? "invalid",
|
|
5
|
-
params: { max: n, actual: r, ...a?.params }
|
|
6
|
-
} : null;
|
|
1
|
+
import { v as i } from "../validation-error-B-U3RsV0.js";
|
|
2
|
+
function u(n, t) {
|
|
3
|
+
return (r) => r == null ? null : r > n ? i("max", t, { max: n, actual: r }) : null;
|
|
7
4
|
}
|
|
8
5
|
export {
|
|
9
|
-
|
|
6
|
+
u as max
|
|
10
7
|
};
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { p as
|
|
2
|
-
|
|
1
|
+
import { p as o, c as a } from "../date-utils-dTT_x_Be.js";
|
|
2
|
+
import { v as l } from "../validation-error-B-U3RsV0.js";
|
|
3
|
+
function s(n, i) {
|
|
3
4
|
return (r) => {
|
|
4
5
|
if (r == null || r === "")
|
|
5
6
|
return null;
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
7
|
+
const t = o(r);
|
|
8
|
+
if (t === null)
|
|
8
9
|
return null;
|
|
9
|
-
const
|
|
10
|
-
return
|
|
11
|
-
code: "date_min_age",
|
|
12
|
-
message: n?.message ?? "invalid",
|
|
13
|
-
params: { minAge: e, currentAge: t, ...n?.params }
|
|
14
|
-
} : null;
|
|
10
|
+
const e = a(t);
|
|
11
|
+
return e < n ? l("date_min_age", i, { minAge: n, currentAge: e }) : null;
|
|
15
12
|
};
|
|
16
13
|
}
|
|
17
14
|
export {
|
|
18
|
-
|
|
15
|
+
s as minAge
|
|
19
16
|
};
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { p as l, n as
|
|
2
|
-
|
|
1
|
+
import { p as l, n as i } from "../date-utils-dTT_x_Be.js";
|
|
2
|
+
import { v as m } from "../validation-error-B-U3RsV0.js";
|
|
3
|
+
function d(r, o) {
|
|
3
4
|
return (n) => {
|
|
4
5
|
if (n == null || n === "")
|
|
5
6
|
return null;
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
7
|
+
const t = l(n);
|
|
8
|
+
if (t === null)
|
|
8
9
|
return null;
|
|
9
|
-
const
|
|
10
|
-
return
|
|
11
|
-
code: "date_min",
|
|
12
|
-
message: e?.message ?? "invalid",
|
|
13
|
-
params: { minDate: r, ...e?.params }
|
|
14
|
-
} : null;
|
|
10
|
+
const e = i(t), a = i(r);
|
|
11
|
+
return e < a ? m("date_min", o, { minDate: r }) : null;
|
|
15
12
|
};
|
|
16
13
|
}
|
|
17
14
|
export {
|
|
18
|
-
|
|
15
|
+
d as minDate
|
|
19
16
|
};
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { v as i } from "../validation-error-B-U3RsV0.js";
|
|
2
|
+
function o(t, e) {
|
|
2
3
|
return (n) => {
|
|
3
4
|
if (n == null || n === "")
|
|
4
5
|
return null;
|
|
5
|
-
const
|
|
6
|
-
return typeof
|
|
7
|
-
code: "minLength",
|
|
8
|
-
message: t?.message ?? "invalid",
|
|
9
|
-
params: { minLength: r, actualLength: e, ...t?.params }
|
|
10
|
-
} : null;
|
|
6
|
+
const r = n.length;
|
|
7
|
+
return typeof r != "number" ? null : r < t ? i("minLength", e, { minLength: t, actualLength: r }) : null;
|
|
11
8
|
};
|
|
12
9
|
}
|
|
13
10
|
export {
|
|
14
|
-
|
|
11
|
+
o as minLength
|
|
15
12
|
};
|
package/dist/validators/min.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
message: i?.message ?? "invalid",
|
|
5
|
-
params: { min: r, actual: n, ...i?.params }
|
|
6
|
-
} : null;
|
|
1
|
+
import { v as t } from "../validation-error-B-U3RsV0.js";
|
|
2
|
+
function u(n, i) {
|
|
3
|
+
return (r) => r == null ? null : r < n ? t("min", i, { min: n, actual: r }) : null;
|
|
7
4
|
}
|
|
8
5
|
export {
|
|
9
|
-
|
|
6
|
+
u as min
|
|
10
7
|
};
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { v as i } from "../validation-error-B-U3RsV0.js";
|
|
2
|
+
function o(n, l) {
|
|
2
3
|
return (t) => {
|
|
3
4
|
if (t == null || typeof t != "number" || isNaN(t)) return null;
|
|
4
|
-
const
|
|
5
|
-
return
|
|
6
|
-
code: "multipleOf",
|
|
7
|
-
message: n?.message ?? "invalid",
|
|
8
|
-
params: { multipleOf: e, ...n?.params }
|
|
9
|
-
};
|
|
5
|
+
const r = Math.abs(t % n);
|
|
6
|
+
return r <= 1e-9 || Math.abs(r - Math.abs(n)) <= 1e-9 ? null : i("multipleOf", l, { multipleOf: n });
|
|
10
7
|
};
|
|
11
8
|
}
|
|
12
9
|
export {
|
|
13
|
-
|
|
10
|
+
o as multipleOf
|
|
14
11
|
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
message: r?.message ?? "invalid",
|
|
5
|
-
params: r?.params
|
|
6
|
-
} : null;
|
|
1
|
+
import { v as t } from "../validation-error-B-U3RsV0.js";
|
|
2
|
+
function o(r) {
|
|
3
|
+
return (n) => n == null || typeof n != "number" || isNaN(n) ? null : n < 0 ? t("nonNegative", r) : null;
|
|
7
4
|
}
|
|
8
5
|
export {
|
|
9
|
-
|
|
6
|
+
o as nonNegative
|
|
10
7
|
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
message: r?.message ?? "invalid",
|
|
5
|
-
params: r?.params
|
|
6
|
-
} : null;
|
|
1
|
+
import { v as o } from "../validation-error-B-U3RsV0.js";
|
|
2
|
+
function i(n) {
|
|
3
|
+
return (r) => r == null || typeof r != "number" || isNaN(r) ? null : r === 0 ? o("nonZero", n) : null;
|
|
7
4
|
}
|
|
8
5
|
export {
|
|
9
|
-
|
|
6
|
+
i as nonZero
|
|
10
7
|
};
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { p as
|
|
2
|
-
|
|
1
|
+
import { p as e, n as i, g as l } from "../date-utils-dTT_x_Be.js";
|
|
2
|
+
import { v as u } from "../validation-error-B-U3RsV0.js";
|
|
3
|
+
function f(n) {
|
|
3
4
|
return (r) => {
|
|
4
5
|
if (r == null || r === "")
|
|
5
6
|
return null;
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
7
|
+
const t = e(r);
|
|
8
|
+
if (t === null)
|
|
8
9
|
return null;
|
|
9
|
-
const
|
|
10
|
-
return
|
|
11
|
-
code: "date_future",
|
|
12
|
-
message: a?.message ?? "invalid",
|
|
13
|
-
params: a?.params
|
|
14
|
-
} : null;
|
|
10
|
+
const o = i(t), a = l();
|
|
11
|
+
return o > a ? u("date_future", n) : null;
|
|
15
12
|
};
|
|
16
13
|
}
|
|
17
14
|
export {
|
|
18
|
-
|
|
15
|
+
f as pastDate
|
|
19
16
|
};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
message: r?.message ?? "",
|
|
6
|
-
params: { pattern: e.source, ...r?.params }
|
|
7
|
-
}) : null;
|
|
1
|
+
import { v as o } from "../validation-error-B-U3RsV0.js";
|
|
2
|
+
function a(r, e) {
|
|
3
|
+
const t = new RegExp(r.source, r.flags);
|
|
4
|
+
return (n) => n ? (t.lastIndex = 0, t.test(n) ? null : o("pattern", e, { pattern: r.source })) : null;
|
|
8
5
|
}
|
|
9
6
|
export {
|
|
10
|
-
|
|
7
|
+
a as pattern
|
|
11
8
|
};
|
package/dist/validators/phone.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { v as o } from "../validation-error-B-U3RsV0.js";
|
|
2
|
+
const e = {
|
|
2
3
|
international: /^\+?[1-9]\d{1,14}$/,
|
|
3
4
|
ru: /^(\+7|7|8)?[\s-]?\(?[489][0-9]{2}\)?[\s-]?[0-9]{3}[\s-]?[0-9]{2}[\s-]?[0-9]{2}$/,
|
|
4
5
|
us: /^(\+?1)?[\s-]?\(?[2-9]\d{2}\)?[\s-]?\d{3}[\s-]?\d{4}$/,
|
|
5
6
|
any: /^\+?\(?[0-9]{1,4}\)?[-\s.]?\(?[0-9]{1,4}\)?[-\s.]?[0-9]{1,9}$/
|
|
6
7
|
};
|
|
7
|
-
function
|
|
8
|
-
const n =
|
|
9
|
-
return (
|
|
10
|
-
code: "phone",
|
|
11
|
-
message: s?.message ?? "invalid",
|
|
12
|
-
params: { format: n, ...s?.params }
|
|
13
|
-
} : null;
|
|
8
|
+
function u(r) {
|
|
9
|
+
const n = r?.format ?? "any", s = e[n];
|
|
10
|
+
return (t) => t ? s.test(t) ? null : o("phone", r, { format: n }) : null;
|
|
14
11
|
}
|
|
15
12
|
export {
|
|
16
|
-
|
|
13
|
+
u as phone
|
|
17
14
|
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
message: e?.message ?? "",
|
|
5
|
-
params: e?.params
|
|
6
|
-
} : null;
|
|
1
|
+
import { v as i } from "../validation-error-B-U3RsV0.js";
|
|
2
|
+
function e(t) {
|
|
3
|
+
return (r) => r == null || r === "" || Array.isArray(r) && r.length === 0 || typeof r == "boolean" && r !== !0 ? i("required", t) : null;
|
|
7
4
|
}
|
|
8
5
|
export {
|
|
9
|
-
|
|
6
|
+
e as required
|
|
10
7
|
};
|
package/dist/validators/url.js
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { v as t } from "../validation-error-B-U3RsV0.js";
|
|
2
|
+
const a = /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/i, c = /^https?:\/\/([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/i;
|
|
3
|
+
function n(o) {
|
|
3
4
|
return (r) => {
|
|
4
5
|
if (!r)
|
|
5
6
|
return null;
|
|
6
7
|
const l = r;
|
|
7
|
-
return (
|
|
8
|
-
(
|
|
9
|
-
) ? {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
params: { allowedProtocols: e.allowedProtocols, ...e?.params }
|
|
13
|
-
} : null : {
|
|
14
|
-
code: "url",
|
|
15
|
-
message: e?.message ?? "invalid",
|
|
16
|
-
params: e?.params
|
|
17
|
-
};
|
|
8
|
+
return (o?.requireProtocol ? c : a).test(l) ? o?.allowedProtocols && o.allowedProtocols.length > 0 && !o.allowedProtocols.some(
|
|
9
|
+
(e) => l.toLowerCase().startsWith(`${e}://`)
|
|
10
|
+
) ? t("url_protocol", o, {
|
|
11
|
+
allowedProtocols: o.allowedProtocols
|
|
12
|
+
}) : null : t("url", o);
|
|
18
13
|
};
|
|
19
14
|
}
|
|
20
15
|
export {
|
|
21
|
-
|
|
16
|
+
n as url
|
|
22
17
|
};
|