@logixjs/form 0.0.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/Error-VvknI9Wj.d.cts +37 -0
- package/dist/Error-VvknI9Wj.d.ts +37 -0
- package/dist/Error.cjs +46 -0
- package/dist/Error.cjs.map +1 -0
- package/dist/Error.d.cts +1 -0
- package/dist/Error.d.ts +1 -0
- package/dist/Error.js +14 -0
- package/dist/Error.js.map +1 -0
- package/dist/Form.cjs +2455 -0
- package/dist/Form.cjs.map +1 -0
- package/dist/Form.d.cts +64 -0
- package/dist/Form.d.ts +64 -0
- package/dist/Form.js +25 -0
- package/dist/Form.js.map +1 -0
- package/dist/FormView-CAg9LVrf.d.cts +17 -0
- package/dist/FormView-CAg9LVrf.d.ts +17 -0
- package/dist/FormView.cjs +61 -0
- package/dist/FormView.cjs.map +1 -0
- package/dist/FormView.d.cts +1 -0
- package/dist/FormView.d.ts +1 -0
- package/dist/FormView.js +8 -0
- package/dist/FormView.js.map +1 -0
- package/dist/Path-DOjMkAS6.d.cts +42 -0
- package/dist/Path-DOjMkAS6.d.ts +42 -0
- package/dist/Path.cjs +132 -0
- package/dist/Path.cjs.map +1 -0
- package/dist/Path.d.cts +1 -0
- package/dist/Path.d.ts +1 -0
- package/dist/Path.js +22 -0
- package/dist/Path.js.map +1 -0
- package/dist/Rule-BOAiSVz9.d.cts +202 -0
- package/dist/Rule-BOAiSVz9.d.ts +202 -0
- package/dist/Rule.cjs +307 -0
- package/dist/Rule.cjs.map +1 -0
- package/dist/Rule.d.cts +2 -0
- package/dist/Rule.d.ts +2 -0
- package/dist/Rule.js +34 -0
- package/dist/Rule.js.map +1 -0
- package/dist/SchemaErrorMapping-Cu5gl7-Z.d.ts +50 -0
- package/dist/SchemaErrorMapping-DOrgLzii.d.cts +50 -0
- package/dist/SchemaErrorMapping.cjs +305 -0
- package/dist/SchemaErrorMapping.cjs.map +1 -0
- package/dist/SchemaErrorMapping.d.cts +2 -0
- package/dist/SchemaErrorMapping.d.ts +2 -0
- package/dist/SchemaErrorMapping.js +17 -0
- package/dist/SchemaErrorMapping.js.map +1 -0
- package/dist/SchemaPathMapping-BCoUW-_q.d.ts +16 -0
- package/dist/SchemaPathMapping-BUq2zm8W.d.cts +20 -0
- package/dist/SchemaPathMapping-BUq2zm8W.d.ts +20 -0
- package/dist/SchemaPathMapping-DJnExqM3.d.cts +16 -0
- package/dist/SchemaPathMapping.cjs +179 -0
- package/dist/SchemaPathMapping.cjs.map +1 -0
- package/dist/SchemaPathMapping.d.cts +2 -0
- package/dist/SchemaPathMapping.d.ts +2 -0
- package/dist/SchemaPathMapping.js +12 -0
- package/dist/SchemaPathMapping.js.map +1 -0
- package/dist/Trait-Bu794ROY.d.cts +49 -0
- package/dist/Trait-Bu794ROY.d.ts +49 -0
- package/dist/Trait.cjs +48 -0
- package/dist/Trait.cjs.map +1 -0
- package/dist/Trait.d.cts +2 -0
- package/dist/Trait.d.ts +2 -0
- package/dist/Trait.js +12 -0
- package/dist/Trait.js.map +1 -0
- package/dist/chunk-5DRI5UGD.js +105 -0
- package/dist/chunk-5DRI5UGD.js.map +1 -0
- package/dist/chunk-AD2ZA7KA.js +23 -0
- package/dist/chunk-AD2ZA7KA.js.map +1 -0
- package/dist/chunk-EOXJRCM6.js +146 -0
- package/dist/chunk-EOXJRCM6.js.map +1 -0
- package/dist/chunk-JZ5FZKPJ.js +71 -0
- package/dist/chunk-JZ5FZKPJ.js.map +1 -0
- package/dist/chunk-LNJJPZAG.js +46 -0
- package/dist/chunk-LNJJPZAG.js.map +1 -0
- package/dist/chunk-NAR5SIFP.js +22 -0
- package/dist/chunk-NAR5SIFP.js.map +1 -0
- package/dist/chunk-OJVEZKU7.js +117 -0
- package/dist/chunk-OJVEZKU7.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-S5JTU2CM.js +31 -0
- package/dist/chunk-S5JTU2CM.js.map +1 -0
- package/dist/chunk-YHDEJ47V.js +1885 -0
- package/dist/chunk-YHDEJ47V.js.map +1 -0
- package/dist/chunk-YVHXLY63.js +315 -0
- package/dist/chunk-YVHXLY63.js.map +1 -0
- package/dist/impl-BfSlyM58.d.ts +225 -0
- package/dist/impl-Ccdm5eDF.d.cts +225 -0
- package/dist/index.cjs +2689 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/react/index.cjs +332 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +43 -0
- package/dist/react/index.d.ts +43 -0
- package/dist/react/index.js +201 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +62 -0
package/dist/Rule.cjs
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/Rule.ts
|
|
21
|
+
var Rule_exports = {};
|
|
22
|
+
__export(Rule_exports, {
|
|
23
|
+
ERROR_VALUE_MAX_BYTES: () => ERROR_VALUE_MAX_BYTES,
|
|
24
|
+
assertErrorValueBudget: () => assertErrorValueBudget,
|
|
25
|
+
field: () => field,
|
|
26
|
+
fields: () => fields,
|
|
27
|
+
list: () => list,
|
|
28
|
+
make: () => make,
|
|
29
|
+
max: () => max,
|
|
30
|
+
maxLength: () => maxLength,
|
|
31
|
+
merge: () => merge,
|
|
32
|
+
min: () => min,
|
|
33
|
+
minLength: () => minLength,
|
|
34
|
+
pattern: () => pattern,
|
|
35
|
+
required: () => required,
|
|
36
|
+
root: () => root
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(Rule_exports);
|
|
39
|
+
|
|
40
|
+
// src/internal/validators/index.ts
|
|
41
|
+
var import_effect = require("effect");
|
|
42
|
+
var ERROR_VALUE_MAX_BYTES = 256;
|
|
43
|
+
var textEncoder = new TextEncoder();
|
|
44
|
+
var jsonByteSize = (value) => {
|
|
45
|
+
const json = JSON.stringify(value);
|
|
46
|
+
return textEncoder.encode(json).length;
|
|
47
|
+
};
|
|
48
|
+
var assertErrorValueBudget = (value, label) => {
|
|
49
|
+
const bytes = jsonByteSize(value);
|
|
50
|
+
if (bytes <= ERROR_VALUE_MAX_BYTES) return value;
|
|
51
|
+
throw new Error(`[Form.validators] ErrorValue for "${label}" must be JSON \u2264${ERROR_VALUE_MAX_BYTES}B (got ${bytes}B)`);
|
|
52
|
+
};
|
|
53
|
+
var errorValue = (label, value) => assertErrorValueBudget(value, label);
|
|
54
|
+
var required = (decl) => {
|
|
55
|
+
const trim = typeof decl === "object" && decl !== null ? Boolean(decl.trim) : true;
|
|
56
|
+
const message = typeof decl === "string" ? decl : typeof decl === "object" && decl !== null && typeof decl.message === "string" ? decl.message : "required";
|
|
57
|
+
const err = errorValue("required", message);
|
|
58
|
+
return (value) => {
|
|
59
|
+
if (value === null || value === void 0) return err;
|
|
60
|
+
if (typeof value === "string") {
|
|
61
|
+
const v = trim ? value.trim() : value;
|
|
62
|
+
return v.length > 0 ? void 0 : err;
|
|
63
|
+
}
|
|
64
|
+
if (Array.isArray(value)) return value.length > 0 ? void 0 : err;
|
|
65
|
+
if (typeof value === "boolean") return value ? void 0 : err;
|
|
66
|
+
return void 0;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
var minLength = (decl) => {
|
|
70
|
+
const min2 = typeof decl === "number" ? decl : decl.min;
|
|
71
|
+
const message = typeof decl === "object" && decl !== null && typeof decl.message === "string" ? decl.message : "minLength";
|
|
72
|
+
const err = errorValue("minLength", message);
|
|
73
|
+
return (value) => {
|
|
74
|
+
if (value === null || value === void 0) return void 0;
|
|
75
|
+
if (typeof value === "string") return value.length >= min2 ? void 0 : err;
|
|
76
|
+
if (Array.isArray(value)) return value.length >= min2 ? void 0 : err;
|
|
77
|
+
return void 0;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
var maxLength = (decl) => {
|
|
81
|
+
const max2 = typeof decl === "number" ? decl : decl.max;
|
|
82
|
+
const message = typeof decl === "object" && decl !== null && typeof decl.message === "string" ? decl.message : "maxLength";
|
|
83
|
+
const err = errorValue("maxLength", message);
|
|
84
|
+
return (value) => {
|
|
85
|
+
if (value === null || value === void 0) return void 0;
|
|
86
|
+
if (typeof value === "string") return value.length <= max2 ? void 0 : err;
|
|
87
|
+
if (Array.isArray(value)) return value.length <= max2 ? void 0 : err;
|
|
88
|
+
return void 0;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
var min = (decl) => {
|
|
92
|
+
const minValue = typeof decl === "number" ? decl : decl.min;
|
|
93
|
+
const message = typeof decl === "object" && decl !== null && typeof decl.message === "string" ? decl.message : "min";
|
|
94
|
+
const err = errorValue("min", message);
|
|
95
|
+
return (value) => {
|
|
96
|
+
if (value === null || value === void 0) return void 0;
|
|
97
|
+
if (typeof value === "number" && Number.isFinite(value)) return value >= minValue ? void 0 : err;
|
|
98
|
+
return void 0;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
var max = (decl) => {
|
|
102
|
+
const maxValue = typeof decl === "number" ? decl : decl.max;
|
|
103
|
+
const message = typeof decl === "object" && decl !== null && typeof decl.message === "string" ? decl.message : "max";
|
|
104
|
+
const err = errorValue("max", message);
|
|
105
|
+
return (value) => {
|
|
106
|
+
if (value === null || value === void 0) return void 0;
|
|
107
|
+
if (typeof value === "number" && Number.isFinite(value)) return value <= maxValue ? void 0 : err;
|
|
108
|
+
return void 0;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
var pattern = (decl) => {
|
|
112
|
+
const re = decl instanceof RegExp ? decl : decl.re;
|
|
113
|
+
const message = typeof decl === "object" && decl !== null && typeof decl.message === "string" ? decl.message : "pattern";
|
|
114
|
+
const err = errorValue("pattern", message);
|
|
115
|
+
return (value) => {
|
|
116
|
+
if (value === null || value === void 0) return void 0;
|
|
117
|
+
if (typeof value !== "string") return void 0;
|
|
118
|
+
return re.test(value) ? void 0 : err;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// src/Rule.ts
|
|
123
|
+
var uniq = (items) => Array.from(new Set(items));
|
|
124
|
+
var normalizeValidateOn = (input) => {
|
|
125
|
+
if (!Array.isArray(input)) return void 0;
|
|
126
|
+
const out = [];
|
|
127
|
+
for (const x of input) {
|
|
128
|
+
if (x === "onChange" || x === "onBlur") out.push(x);
|
|
129
|
+
}
|
|
130
|
+
return uniq(out);
|
|
131
|
+
};
|
|
132
|
+
var normalizeDeps = (input) => {
|
|
133
|
+
if (!Array.isArray(input)) return void 0;
|
|
134
|
+
const out = [];
|
|
135
|
+
for (const x of input) {
|
|
136
|
+
if (typeof x !== "string") continue;
|
|
137
|
+
const v = x.trim();
|
|
138
|
+
if (!v) continue;
|
|
139
|
+
out.push(v);
|
|
140
|
+
}
|
|
141
|
+
return uniq(out);
|
|
142
|
+
};
|
|
143
|
+
var isPlainObject = (value) => Boolean(value) && typeof value === "object" && value !== null && !Array.isArray(value);
|
|
144
|
+
var make = (input) => {
|
|
145
|
+
if (typeof input === "function") {
|
|
146
|
+
return {
|
|
147
|
+
default: {
|
|
148
|
+
deps: [],
|
|
149
|
+
validate: input
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if (!isPlainObject(input)) {
|
|
154
|
+
return {};
|
|
155
|
+
}
|
|
156
|
+
const baseDeps = normalizeDeps(input.deps) ?? [];
|
|
157
|
+
const baseValidateOn = normalizeValidateOn(input.validateOn);
|
|
158
|
+
const byName = /* @__PURE__ */ new Map();
|
|
159
|
+
const addRule = (name, raw) => {
|
|
160
|
+
const ruleName = typeof name === "string" ? name.trim() : "";
|
|
161
|
+
if (!ruleName) return;
|
|
162
|
+
if (byName.has(ruleName)) {
|
|
163
|
+
throw new Error(`[Form.Rule.make] Duplicate rule name "${ruleName}"`);
|
|
164
|
+
}
|
|
165
|
+
if (typeof raw === "function") {
|
|
166
|
+
byName.set(ruleName, {
|
|
167
|
+
deps: baseDeps,
|
|
168
|
+
validate: raw,
|
|
169
|
+
...baseValidateOn !== void 0 ? { validateOn: baseValidateOn } : {}
|
|
170
|
+
});
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (!raw || typeof raw !== "object") return;
|
|
174
|
+
const entry = raw;
|
|
175
|
+
const deps = normalizeDeps(entry.deps) ?? baseDeps;
|
|
176
|
+
const validateOn = normalizeValidateOn(entry.validateOn) ?? baseValidateOn;
|
|
177
|
+
const validate = entry.validate;
|
|
178
|
+
if (typeof validate !== "function") return;
|
|
179
|
+
byName.set(ruleName, {
|
|
180
|
+
...entry,
|
|
181
|
+
deps,
|
|
182
|
+
validate,
|
|
183
|
+
...validateOn !== void 0 ? { validateOn } : {}
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
const requiredDecl = input.required;
|
|
187
|
+
if (requiredDecl !== void 0 && requiredDecl !== false) {
|
|
188
|
+
const validate = required(requiredDecl);
|
|
189
|
+
addRule("required", (value) => validate(value));
|
|
190
|
+
}
|
|
191
|
+
const minLengthDecl = input.minLength;
|
|
192
|
+
if (minLengthDecl !== void 0) {
|
|
193
|
+
const validate = minLength(minLengthDecl);
|
|
194
|
+
addRule("minLength", (value) => validate(value));
|
|
195
|
+
}
|
|
196
|
+
const maxLengthDecl = input.maxLength;
|
|
197
|
+
if (maxLengthDecl !== void 0) {
|
|
198
|
+
const validate = maxLength(maxLengthDecl);
|
|
199
|
+
addRule("maxLength", (value) => validate(value));
|
|
200
|
+
}
|
|
201
|
+
const minDecl = input.min;
|
|
202
|
+
if (minDecl !== void 0) {
|
|
203
|
+
const validate = min(minDecl);
|
|
204
|
+
addRule("min", (value) => validate(value));
|
|
205
|
+
}
|
|
206
|
+
const maxDecl = input.max;
|
|
207
|
+
if (maxDecl !== void 0) {
|
|
208
|
+
const validate = max(maxDecl);
|
|
209
|
+
addRule("max", (value) => validate(value));
|
|
210
|
+
}
|
|
211
|
+
const patternDecl = input.pattern;
|
|
212
|
+
if (patternDecl !== void 0) {
|
|
213
|
+
const validate = pattern(patternDecl);
|
|
214
|
+
addRule("pattern", (value) => validate(value));
|
|
215
|
+
}
|
|
216
|
+
const validateBlock = input.validate;
|
|
217
|
+
if (typeof validateBlock === "function") {
|
|
218
|
+
addRule("validate", validateBlock);
|
|
219
|
+
} else if (isPlainObject(validateBlock)) {
|
|
220
|
+
const names2 = Object.keys(validateBlock).sort((a, b) => a.localeCompare(b));
|
|
221
|
+
for (const name of names2) {
|
|
222
|
+
addRule(name, validateBlock[name]);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const out = {};
|
|
226
|
+
const names = Array.from(byName.keys()).sort((a, b) => a.localeCompare(b));
|
|
227
|
+
for (const name of names) {
|
|
228
|
+
out[name] = byName.get(name);
|
|
229
|
+
}
|
|
230
|
+
return out;
|
|
231
|
+
};
|
|
232
|
+
var merge = (...rules) => {
|
|
233
|
+
const byName = /* @__PURE__ */ new Map();
|
|
234
|
+
const duplicates = /* @__PURE__ */ new Set();
|
|
235
|
+
for (const ruleSet of rules) {
|
|
236
|
+
for (const name of Object.keys(ruleSet)) {
|
|
237
|
+
if (byName.has(name)) duplicates.add(name);
|
|
238
|
+
else byName.set(name, ruleSet[name]);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (duplicates.size > 0) {
|
|
242
|
+
const list2 = Array.from(duplicates).sort((a, b) => a.localeCompare(b)).join(", ");
|
|
243
|
+
throw new Error(`[Form.Rule.merge] Duplicate rule name(s): ${list2}`);
|
|
244
|
+
}
|
|
245
|
+
const merged = {};
|
|
246
|
+
const names = Array.from(byName.keys()).sort((a, b) => a.localeCompare(b));
|
|
247
|
+
for (const name of names) {
|
|
248
|
+
merged[name] = byName.get(name);
|
|
249
|
+
}
|
|
250
|
+
return merged;
|
|
251
|
+
};
|
|
252
|
+
var field = (valuePath, rule, options) => ({
|
|
253
|
+
kind: "field",
|
|
254
|
+
valuePath,
|
|
255
|
+
rule,
|
|
256
|
+
...options?.errorTarget !== void 0 ? { errorTarget: options.errorTarget } : {}
|
|
257
|
+
});
|
|
258
|
+
var root = (rule) => ({
|
|
259
|
+
kind: "root",
|
|
260
|
+
rule
|
|
261
|
+
});
|
|
262
|
+
var list = (listPath, spec) => ({
|
|
263
|
+
kind: "list",
|
|
264
|
+
listPath,
|
|
265
|
+
identity: spec.identity,
|
|
266
|
+
...spec.item !== void 0 ? { item: spec.item } : {},
|
|
267
|
+
...spec.list !== void 0 ? { list: spec.list } : {}
|
|
268
|
+
});
|
|
269
|
+
var fields = (...decls) => {
|
|
270
|
+
const out = {};
|
|
271
|
+
const list2 = [];
|
|
272
|
+
const isDeclArray = (value) => Array.isArray(value);
|
|
273
|
+
for (const item of decls) {
|
|
274
|
+
if (isDeclArray(item)) {
|
|
275
|
+
list2.push(...item);
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
list2.push(item);
|
|
279
|
+
}
|
|
280
|
+
for (const decl of list2) {
|
|
281
|
+
const path = typeof decl?.valuePath === "string" ? decl.valuePath.trim() : "";
|
|
282
|
+
if (!path) continue;
|
|
283
|
+
if (path in out) {
|
|
284
|
+
throw new Error(`[Form.Rule.fields] Duplicate valuePath "${path}"`);
|
|
285
|
+
}
|
|
286
|
+
out[path] = decl.rule;
|
|
287
|
+
}
|
|
288
|
+
return out;
|
|
289
|
+
};
|
|
290
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
291
|
+
0 && (module.exports = {
|
|
292
|
+
ERROR_VALUE_MAX_BYTES,
|
|
293
|
+
assertErrorValueBudget,
|
|
294
|
+
field,
|
|
295
|
+
fields,
|
|
296
|
+
list,
|
|
297
|
+
make,
|
|
298
|
+
max,
|
|
299
|
+
maxLength,
|
|
300
|
+
merge,
|
|
301
|
+
min,
|
|
302
|
+
minLength,
|
|
303
|
+
pattern,
|
|
304
|
+
required,
|
|
305
|
+
root
|
|
306
|
+
});
|
|
307
|
+
//# sourceMappingURL=Rule.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Rule.ts","../src/internal/validators/index.ts"],"sourcesContent":["import type * as Logix from '@logixjs/core'\nimport * as Validators from './internal/validators/index.js'\nimport type { CanonicalPath } from './internal/form/types.js'\n\nexport type AutoValidateOn = 'onChange' | 'onBlur'\n\nexport type RuleValidateOn = ReadonlyArray<AutoValidateOn>\n\nexport type RuleFn<Input, Ctx = unknown> = (input: Input, ctx: Ctx) => unknown | undefined\n\ntype RuleDeps<Input> = Input extends object\n ? CanonicalPath<Input> extends never\n ? string\n : CanonicalPath<Input>\n : string\n\nexport type Rule<Input, Ctx = unknown> = Logix.StateTrait.CheckRule<Input, Ctx> & {\n /**\n * validateOn:\n * - Only affects the auto-validation phase (onChange/onBlur); submit/manual always runs.\n * - If an empty array, auto-validation is disabled (only submit/manual runs).\n */\n readonly validateOn?: RuleValidateOn\n}\n\nexport type RuleSet<Input, Ctx = unknown> = Readonly<Record<string, Rule<Input, Ctx>>>\n\nexport type RuleEntry<Input, Ctx = unknown> =\n | RuleFn<Input, Ctx>\n | (Omit<Rule<Input, Ctx>, 'deps'> & {\n readonly deps?: ReadonlyArray<RuleDeps<Input>>\n })\n\nexport type RuleGroup<Input, Ctx = unknown> = Readonly<{\n readonly deps?: ReadonlyArray<RuleDeps<Input>>\n readonly validateOn?: RuleValidateOn\n readonly validate: Readonly<Record<string, RuleEntry<Input, Ctx>>>\n}>\n\nexport type RuleConfig<Input, Ctx = unknown> = Readonly<{\n readonly deps?: ReadonlyArray<RuleDeps<Input>>\n readonly validateOn?: RuleValidateOn\n\n // RHF-like builtins (expanded at build time into equivalent pure functions)\n readonly required?: Validators.RequiredDecl\n readonly minLength?: Validators.MinLengthDecl\n readonly maxLength?: Validators.MaxLengthDecl\n readonly min?: Validators.MinDecl\n readonly max?: Validators.MaxDecl\n readonly pattern?: Validators.PatternDecl\n\n // RHF-like validate: a function or a named map of functions (RuleEntry form is also allowed to override deps/validateOn)\n readonly validate?: RuleFn<Input, Ctx> | Readonly<Record<string, RuleEntry<Input, Ctx>>>\n}>\n\nexport type RuleInput<Input, Ctx = unknown> = RuleFn<Input, Ctx> | RuleGroup<Input, Ctx> | RuleConfig<Input, Ctx>\n\nconst uniq = <T>(items: ReadonlyArray<T>): ReadonlyArray<T> => Array.from(new Set(items))\n\nconst normalizeValidateOn = (input: unknown): RuleValidateOn | undefined => {\n if (!Array.isArray(input)) return undefined\n const out: Array<AutoValidateOn> = []\n for (const x of input) {\n if (x === 'onChange' || x === 'onBlur') out.push(x)\n }\n return uniq(out)\n}\n\nconst normalizeDeps = (input: unknown): ReadonlyArray<string> | undefined => {\n if (!Array.isArray(input)) return undefined\n const out: Array<string> = []\n for (const x of input) {\n if (typeof x !== 'string') continue\n const v = x.trim()\n if (!v) continue\n out.push(v)\n }\n return uniq(out)\n}\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> =>\n Boolean(value) && typeof value === 'object' && value !== null && !Array.isArray(value)\n\n/**\n * make:\n * - The result must be directly attachable to `StateTrait.node({ check })`.\n * - Does not introduce an extra wrapper (e.g. `{ rules: ... }`).\n */\nexport const make = <Input, Ctx = unknown>(input: RuleInput<Input, Ctx>): RuleSet<Input, Ctx> => {\n if (typeof input === 'function') {\n return {\n default: {\n deps: [],\n validate: input,\n },\n }\n }\n\n if (!isPlainObject(input)) {\n return {}\n }\n\n const baseDeps = normalizeDeps((input as any).deps) ?? []\n const baseValidateOn = normalizeValidateOn((input as any).validateOn)\n\n const byName = new Map<string, Rule<Input, Ctx>>()\n\n const addRule = (name: string, raw: unknown): void => {\n const ruleName = typeof name === 'string' ? name.trim() : ''\n if (!ruleName) return\n if (byName.has(ruleName)) {\n throw new Error(`[Form.Rule.make] Duplicate rule name \"${ruleName}\"`)\n }\n\n if (typeof raw === 'function') {\n byName.set(ruleName, {\n deps: baseDeps,\n validate: raw as any,\n ...(baseValidateOn !== undefined ? { validateOn: baseValidateOn } : {}),\n })\n return\n }\n\n if (!raw || typeof raw !== 'object') return\n const entry = raw as any\n const deps = normalizeDeps(entry.deps) ?? baseDeps\n const validateOn = normalizeValidateOn(entry.validateOn) ?? baseValidateOn\n const validate = entry.validate\n if (typeof validate !== 'function') return\n\n byName.set(ruleName, {\n ...entry,\n deps,\n validate,\n ...(validateOn !== undefined ? { validateOn } : {}),\n })\n }\n\n // RHF-like builtins (if declared, it will be expanded into an equivalent pure function)\n const requiredDecl = (input as any).required as Validators.RequiredDecl | undefined\n if (requiredDecl !== undefined && requiredDecl !== false) {\n const validate = Validators.required(requiredDecl)\n addRule('required', (value: Input) => validate(value))\n }\n\n const minLengthDecl = (input as any).minLength as Validators.MinLengthDecl | undefined\n if (minLengthDecl !== undefined) {\n const validate = Validators.minLength(minLengthDecl)\n addRule('minLength', (value: Input) => validate(value))\n }\n\n const maxLengthDecl = (input as any).maxLength as Validators.MaxLengthDecl | undefined\n if (maxLengthDecl !== undefined) {\n const validate = Validators.maxLength(maxLengthDecl)\n addRule('maxLength', (value: Input) => validate(value))\n }\n\n const minDecl = (input as any).min as Validators.MinDecl | undefined\n if (minDecl !== undefined) {\n const validate = Validators.min(minDecl)\n addRule('min', (value: Input) => validate(value))\n }\n\n const maxDecl = (input as any).max as Validators.MaxDecl | undefined\n if (maxDecl !== undefined) {\n const validate = Validators.max(maxDecl)\n addRule('max', (value: Input) => validate(value))\n }\n\n const patternDecl = (input as any).pattern as Validators.PatternDecl | undefined\n if (patternDecl !== undefined) {\n const validate = Validators.pattern(patternDecl)\n addRule('pattern', (value: Input) => validate(value))\n }\n\n // validate: supports both legacy RuleGroup `{ validate: Record<string, RuleEntry> }`\n // and RHF-style `validate: fn | Record<string, fn>`.\n const validateBlock = (input as any).validate as unknown\n if (typeof validateBlock === 'function') {\n addRule('validate', validateBlock)\n } else if (isPlainObject(validateBlock)) {\n const names = Object.keys(validateBlock).sort((a, b) => a.localeCompare(b))\n for (const name of names) {\n addRule(name, (validateBlock as any)[name])\n }\n }\n\n const out: Record<string, Rule<Input, Ctx>> = {}\n const names = Array.from(byName.keys()).sort((a, b) => a.localeCompare(b))\n for (const name of names) {\n out[name] = byName.get(name)!\n }\n return out\n}\n\nexport const merge = <Input, Ctx = unknown>(...rules: ReadonlyArray<RuleSet<Input, Ctx>>): RuleSet<Input, Ctx> => {\n const byName = new Map<string, Rule<Input, Ctx>>()\n const duplicates = new Set<string>()\n\n for (const ruleSet of rules) {\n for (const name of Object.keys(ruleSet)) {\n if (byName.has(name)) duplicates.add(name)\n else byName.set(name, ruleSet[name]!)\n }\n }\n\n if (duplicates.size > 0) {\n const list = Array.from(duplicates)\n .sort((a, b) => a.localeCompare(b))\n .join(', ')\n throw new Error(`[Form.Rule.merge] Duplicate rule name(s): ${list}`)\n }\n\n const merged: Record<string, Rule<Input, Ctx>> = {}\n const names = Array.from(byName.keys()).sort((a, b) => a.localeCompare(b))\n for (const name of names) {\n merged[name] = byName.get(name)!\n }\n\n return merged\n}\n\nexport type ErrorTarget = '$value' | '$self'\n\nexport type ListIdentityPolicy =\n | Readonly<{ readonly mode: 'trackBy'; readonly trackBy: string }>\n | Readonly<{ readonly mode: 'store' }>\n | Readonly<{ readonly mode: 'index' }>\n\nexport type FieldDecl<Input, Ctx = unknown> = Readonly<{\n readonly kind: 'field'\n readonly valuePath: string\n readonly rule: RuleInput<Input, Ctx>\n readonly errorTarget?: ErrorTarget\n}>\n\nexport type RootDecl<Input, Ctx = unknown> = Readonly<{\n readonly kind: 'root'\n readonly rule: RuleInput<Input, Ctx>\n}>\n\nexport type ListDecl<Item, Ctx = unknown> = Readonly<{\n readonly kind: 'list'\n readonly listPath: string\n readonly identity: ListIdentityPolicy\n readonly item?: RuleInput<Item, Ctx>\n readonly list?: RuleInput<ReadonlyArray<Item>, Ctx>\n}>\n\nexport type RulesDecl<TValues extends object = any> = FieldDecl<any> | RootDecl<TValues> | ListDecl<any>\n\nexport const field = <Input, Ctx = unknown>(\n valuePath: string,\n rule: RuleInput<Input, Ctx>,\n options?: { readonly errorTarget?: ErrorTarget },\n): FieldDecl<Input, Ctx> => ({\n kind: 'field',\n valuePath,\n rule,\n ...(options?.errorTarget !== undefined ? { errorTarget: options.errorTarget } : {}),\n})\n\nexport const root = <Input, Ctx = unknown>(rule: RuleInput<Input, Ctx>): RootDecl<Input, Ctx> => ({\n kind: 'root',\n rule,\n})\n\nexport const list = <Item, Ctx = unknown>(\n listPath: string,\n spec: {\n readonly identity: ListIdentityPolicy\n readonly item?: RuleInput<Item, Ctx>\n readonly list?: RuleInput<ReadonlyArray<Item>, Ctx>\n },\n): ListDecl<Item, Ctx> => ({\n kind: 'list',\n listPath,\n identity: spec.identity,\n ...(spec.item !== undefined ? { item: spec.item } : {}),\n ...(spec.list !== undefined ? { list: spec.list } : {}),\n})\n\nexport const fields = <Input, Ctx = unknown>(\n ...decls: ReadonlyArray<FieldDecl<Input, Ctx> | ReadonlyArray<FieldDecl<Input, Ctx>>>\n): Readonly<Record<string, RuleInput<Input, Ctx>>> => {\n const out: Record<string, RuleInput<Input, Ctx>> = {}\n const list: Array<FieldDecl<Input, Ctx>> = []\n\n const isDeclArray = (value: unknown): value is ReadonlyArray<FieldDecl<Input, Ctx>> => Array.isArray(value)\n\n for (const item of decls) {\n if (isDeclArray(item)) {\n list.push(...item)\n continue\n }\n list.push(item)\n }\n\n for (const decl of list) {\n const path = typeof decl?.valuePath === 'string' ? decl.valuePath.trim() : ''\n if (!path) continue\n if (path in out) {\n throw new Error(`[Form.Rule.fields] Duplicate valuePath \"${path}\"`)\n }\n out[path] = decl.rule\n }\n\n return out\n}\n\nexport {\n ERROR_VALUE_MAX_BYTES,\n assertErrorValueBudget,\n required,\n minLength,\n maxLength,\n min,\n max,\n pattern,\n} from './internal/validators/index.js'\n","import { ParseResult } from 'effect'\n\nexport const ERROR_VALUE_MAX_BYTES = 256\n\nconst textEncoder = new TextEncoder()\n\nconst jsonByteSize = (value: unknown): number => {\n const json = JSON.stringify(value)\n return textEncoder.encode(json).length\n}\n\nconst truncateToJsonByteBudget = (value: string, maxBytes: number): string => {\n if (jsonByteSize(value) <= maxBytes) return value\n\n let lo = 0\n let hi = value.length\n while (lo < hi) {\n const mid = Math.ceil((lo + hi) / 2)\n const slice = value.slice(0, mid)\n if (jsonByteSize(slice) <= maxBytes) lo = mid\n else hi = mid - 1\n }\n return value.slice(0, lo)\n}\n\nexport const assertErrorValueBudget = (value: unknown, label: string): unknown => {\n const bytes = jsonByteSize(value)\n if (bytes <= ERROR_VALUE_MAX_BYTES) return value\n throw new Error(`[Form.validators] ErrorValue for \"${label}\" must be JSON ≤${ERROR_VALUE_MAX_BYTES}B (got ${bytes}B)`)\n}\n\nconst errorValue = (label: string, value: unknown): unknown => assertErrorValueBudget(value, label)\n\nexport type RequiredDecl =\n | boolean\n | string\n | Readonly<{\n readonly message?: string\n readonly trim?: boolean\n }>\n\nexport const required = (decl: RequiredDecl): ((value: unknown) => unknown | undefined) => {\n const trim = typeof decl === 'object' && decl !== null ? Boolean((decl as any).trim) : true\n const message =\n typeof decl === 'string'\n ? decl\n : typeof decl === 'object' && decl !== null && typeof (decl as any).message === 'string'\n ? (decl as any).message\n : 'required'\n\n const err = errorValue('required', message)\n\n return (value: unknown) => {\n if (value === null || value === undefined) return err\n if (typeof value === 'string') {\n const v = trim ? value.trim() : value\n return v.length > 0 ? undefined : err\n }\n if (Array.isArray(value)) return value.length > 0 ? undefined : err\n if (typeof value === 'boolean') return value ? undefined : err\n return undefined\n }\n}\n\nexport type MinLengthDecl =\n | number\n | Readonly<{\n readonly min: number\n readonly message?: string\n }>\n\nexport const minLength = (decl: MinLengthDecl): ((value: unknown) => unknown | undefined) => {\n const min = typeof decl === 'number' ? decl : decl.min\n const message =\n typeof decl === 'object' && decl !== null && typeof decl.message === 'string' ? decl.message : 'minLength'\n const err = errorValue('minLength', message)\n\n return (value: unknown) => {\n if (value === null || value === undefined) return undefined\n if (typeof value === 'string') return value.length >= min ? undefined : err\n if (Array.isArray(value)) return value.length >= min ? undefined : err\n return undefined\n }\n}\n\nexport type MaxLengthDecl =\n | number\n | Readonly<{\n readonly max: number\n readonly message?: string\n }>\n\nexport const maxLength = (decl: MaxLengthDecl): ((value: unknown) => unknown | undefined) => {\n const max = typeof decl === 'number' ? decl : decl.max\n const message =\n typeof decl === 'object' && decl !== null && typeof decl.message === 'string' ? decl.message : 'maxLength'\n const err = errorValue('maxLength', message)\n\n return (value: unknown) => {\n if (value === null || value === undefined) return undefined\n if (typeof value === 'string') return value.length <= max ? undefined : err\n if (Array.isArray(value)) return value.length <= max ? undefined : err\n return undefined\n }\n}\n\nexport type MinDecl =\n | number\n | Readonly<{\n readonly min: number\n readonly message?: string\n }>\n\nexport const min = (decl: MinDecl): ((value: unknown) => unknown | undefined) => {\n const minValue = typeof decl === 'number' ? decl : decl.min\n const message = typeof decl === 'object' && decl !== null && typeof decl.message === 'string' ? decl.message : 'min'\n const err = errorValue('min', message)\n\n return (value: unknown) => {\n if (value === null || value === undefined) return undefined\n if (typeof value === 'number' && Number.isFinite(value)) return value >= minValue ? undefined : err\n return undefined\n }\n}\n\nexport type MaxDecl =\n | number\n | Readonly<{\n readonly max: number\n readonly message?: string\n }>\n\nexport const max = (decl: MaxDecl): ((value: unknown) => unknown | undefined) => {\n const maxValue = typeof decl === 'number' ? decl : decl.max\n const message = typeof decl === 'object' && decl !== null && typeof decl.message === 'string' ? decl.message : 'max'\n const err = errorValue('max', message)\n\n return (value: unknown) => {\n if (value === null || value === undefined) return undefined\n if (typeof value === 'number' && Number.isFinite(value)) return value <= maxValue ? undefined : err\n return undefined\n }\n}\n\nexport type PatternDecl =\n | RegExp\n | Readonly<{\n readonly re: RegExp\n readonly message?: string\n }>\n\nexport const pattern = (decl: PatternDecl): ((value: unknown) => unknown | undefined) => {\n const re = decl instanceof RegExp ? decl : decl.re\n const message =\n typeof decl === 'object' && decl !== null && typeof (decl as any).message === 'string'\n ? (decl as any).message\n : 'pattern'\n const err = errorValue('pattern', message)\n\n return (value: unknown) => {\n if (value === null || value === undefined) return undefined\n if (typeof value !== 'string') return undefined\n return re.test(value) ? undefined : err\n }\n}\n\nexport const schemaErrorMessage = (schemaError: unknown): string => {\n let message: string\n try {\n message = ParseResult.TreeFormatter.formatErrorSync(schemaError as any)\n } catch {\n message = 'schema invalid'\n }\n\n const truncated = truncateToJsonByteBudget(message, ERROR_VALUE_MAX_BYTES)\n return truncated.length > 0 ? truncated : 'schema invalid'\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA4B;AAErB,IAAM,wBAAwB;AAErC,IAAM,cAAc,IAAI,YAAY;AAEpC,IAAM,eAAe,CAAC,UAA2B;AAC/C,QAAM,OAAO,KAAK,UAAU,KAAK;AACjC,SAAO,YAAY,OAAO,IAAI,EAAE;AAClC;AAgBO,IAAM,yBAAyB,CAAC,OAAgB,UAA2B;AAChF,QAAM,QAAQ,aAAa,KAAK;AAChC,MAAI,SAAS,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AChB;AAEA,aAAW,QAAQA,OAAM;AACvB,UAAM,OAAO,OAAO,MAAM,cAAc,WAAW,KAAK,UAAU,KAAK,IAAI;AAC3E,QAAI,CAAC,KAAM;AACX,QAAI,QAAQ,KAAK;AACf,YAAM,IAAI,MAAM,2CAA2C,IAAI,GAAG;AAAA,IACpE;AACA,QAAI,IAAI,IAAI,KAAK;AAAA,EACnB;AAEA,SAAO;AACT;","names":["min","max","names","list"]}
|
package/dist/Rule.d.cts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import '@logixjs/core';
|
|
2
|
+
export { A as AutoValidateOn, w as ERROR_VALUE_MAX_BYTES, E as ErrorTarget, i as FieldDecl, h as ListDecl, L as ListIdentityPolicy, g as RootDecl, m as Rule, p as RuleConfig, j as RuleEntry, l as RuleFn, o as RuleGroup, f as RuleInput, n as RuleSet, k as RuleValidateOn, e as RulesDecl, x as assertErrorValueBudget, s as field, v as fields, u as list, q as make, G as max, B as maxLength, r as merge, D as min, z as minLength, H as pattern, y as required, t as root } from './Rule-BOAiSVz9.cjs';
|
package/dist/Rule.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import '@logixjs/core';
|
|
2
|
+
export { A as AutoValidateOn, w as ERROR_VALUE_MAX_BYTES, E as ErrorTarget, i as FieldDecl, h as ListDecl, L as ListIdentityPolicy, g as RootDecl, m as Rule, p as RuleConfig, j as RuleEntry, l as RuleFn, o as RuleGroup, f as RuleInput, n as RuleSet, k as RuleValidateOn, e as RulesDecl, x as assertErrorValueBudget, s as field, v as fields, u as list, q as make, G as max, B as maxLength, r as merge, D as min, z as minLength, H as pattern, y as required, t as root } from './Rule-BOAiSVz9.js';
|
package/dist/Rule.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ERROR_VALUE_MAX_BYTES,
|
|
3
|
+
assertErrorValueBudget,
|
|
4
|
+
field,
|
|
5
|
+
fields,
|
|
6
|
+
list,
|
|
7
|
+
make,
|
|
8
|
+
max,
|
|
9
|
+
maxLength,
|
|
10
|
+
merge,
|
|
11
|
+
min,
|
|
12
|
+
minLength,
|
|
13
|
+
pattern,
|
|
14
|
+
required,
|
|
15
|
+
root
|
|
16
|
+
} from "./chunk-YVHXLY63.js";
|
|
17
|
+
import "./chunk-PZ5AY32C.js";
|
|
18
|
+
export {
|
|
19
|
+
ERROR_VALUE_MAX_BYTES,
|
|
20
|
+
assertErrorValueBudget,
|
|
21
|
+
field,
|
|
22
|
+
fields,
|
|
23
|
+
list,
|
|
24
|
+
make,
|
|
25
|
+
max,
|
|
26
|
+
maxLength,
|
|
27
|
+
merge,
|
|
28
|
+
min,
|
|
29
|
+
minLength,
|
|
30
|
+
pattern,
|
|
31
|
+
required,
|
|
32
|
+
root
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=Rule.js.map
|
package/dist/Rule.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { S as SchemaError, a as SchemaPathMappingOptions, F as FieldPath } from './SchemaPathMapping-BUq2zm8W.js';
|
|
2
|
+
|
|
3
|
+
interface SchemaErrorMappingOptions extends SchemaPathMappingOptions {
|
|
4
|
+
/**
|
|
5
|
+
* toLeaf: converts a schemaError into a leaf value that can be written into the error tree.
|
|
6
|
+
* - Default: write the raw schemaError as-is.
|
|
7
|
+
*/
|
|
8
|
+
readonly toLeaf?: (schemaError: SchemaError) => unknown;
|
|
9
|
+
}
|
|
10
|
+
type SchemaErrorWrite = {
|
|
11
|
+
/**
|
|
12
|
+
* fieldPath: the field path without the `errors.` prefix (domain-facing).
|
|
13
|
+
*/
|
|
14
|
+
readonly fieldPath: FieldPath;
|
|
15
|
+
/**
|
|
16
|
+
* errorPath: the actual path written into state (with the `errors.` prefix).
|
|
17
|
+
*/
|
|
18
|
+
readonly errorPath: string;
|
|
19
|
+
readonly error: unknown;
|
|
20
|
+
};
|
|
21
|
+
declare const toSchemaErrorWrites: (schemaError: SchemaError, options?: SchemaErrorMappingOptions) => ReadonlyArray<SchemaErrorWrite>;
|
|
22
|
+
/**
|
|
23
|
+
* toSchemaErrorTree:
|
|
24
|
+
* - Produces a subtree that can be written directly to `errors.$schema` (without the `errors.$schema` prefix).
|
|
25
|
+
*/
|
|
26
|
+
declare const toSchemaErrorTree: (schemaError: SchemaError, options?: SchemaErrorMappingOptions) => unknown;
|
|
27
|
+
/**
|
|
28
|
+
* applySchemaErrorToState:
|
|
29
|
+
* - Maps a SchemaError and writes it back into state.errors.$schema.*.
|
|
30
|
+
* - Does not clear stale errors that are no longer matched (the caller should clear them within a more explicit scope).
|
|
31
|
+
*/
|
|
32
|
+
declare const applySchemaErrorToState: (state: unknown, schemaError: SchemaError, options?: SchemaErrorMappingOptions) => unknown;
|
|
33
|
+
|
|
34
|
+
declare const SchemaErrorMapping: {
|
|
35
|
+
readonly applySchemaErrorToState: (state: unknown, schemaError: SchemaError, options?: SchemaErrorMappingOptions) => unknown;
|
|
36
|
+
readonly toSchemaErrorTree: (schemaError: SchemaError, options?: SchemaErrorMappingOptions) => unknown;
|
|
37
|
+
readonly toSchemaErrorWrites: (schemaError: SchemaError, options?: SchemaErrorMappingOptions) => ReadonlyArray<SchemaErrorWrite>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
declare const SchemaErrorMapping$1_SchemaErrorMapping: typeof SchemaErrorMapping;
|
|
41
|
+
type SchemaErrorMapping$1_SchemaErrorMappingOptions = SchemaErrorMappingOptions;
|
|
42
|
+
type SchemaErrorMapping$1_SchemaErrorWrite = SchemaErrorWrite;
|
|
43
|
+
declare const SchemaErrorMapping$1_applySchemaErrorToState: typeof applySchemaErrorToState;
|
|
44
|
+
declare const SchemaErrorMapping$1_toSchemaErrorTree: typeof toSchemaErrorTree;
|
|
45
|
+
declare const SchemaErrorMapping$1_toSchemaErrorWrites: typeof toSchemaErrorWrites;
|
|
46
|
+
declare namespace SchemaErrorMapping$1 {
|
|
47
|
+
export { SchemaErrorMapping$1_SchemaErrorMapping as SchemaErrorMapping, type SchemaErrorMapping$1_SchemaErrorMappingOptions as SchemaErrorMappingOptions, type SchemaErrorMapping$1_SchemaErrorWrite as SchemaErrorWrite, SchemaErrorMapping$1_applySchemaErrorToState as applySchemaErrorToState, SchemaErrorMapping$1_toSchemaErrorTree as toSchemaErrorTree, SchemaErrorMapping$1_toSchemaErrorWrites as toSchemaErrorWrites };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { SchemaErrorMapping$1 as S, applySchemaErrorToState as a, toSchemaErrorWrites as b, SchemaErrorMapping as c, type SchemaErrorMappingOptions as d, type SchemaErrorWrite as e, toSchemaErrorTree as t };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { S as SchemaError, a as SchemaPathMappingOptions, F as FieldPath } from './SchemaPathMapping-BUq2zm8W.cjs';
|
|
2
|
+
|
|
3
|
+
interface SchemaErrorMappingOptions extends SchemaPathMappingOptions {
|
|
4
|
+
/**
|
|
5
|
+
* toLeaf: converts a schemaError into a leaf value that can be written into the error tree.
|
|
6
|
+
* - Default: write the raw schemaError as-is.
|
|
7
|
+
*/
|
|
8
|
+
readonly toLeaf?: (schemaError: SchemaError) => unknown;
|
|
9
|
+
}
|
|
10
|
+
type SchemaErrorWrite = {
|
|
11
|
+
/**
|
|
12
|
+
* fieldPath: the field path without the `errors.` prefix (domain-facing).
|
|
13
|
+
*/
|
|
14
|
+
readonly fieldPath: FieldPath;
|
|
15
|
+
/**
|
|
16
|
+
* errorPath: the actual path written into state (with the `errors.` prefix).
|
|
17
|
+
*/
|
|
18
|
+
readonly errorPath: string;
|
|
19
|
+
readonly error: unknown;
|
|
20
|
+
};
|
|
21
|
+
declare const toSchemaErrorWrites: (schemaError: SchemaError, options?: SchemaErrorMappingOptions) => ReadonlyArray<SchemaErrorWrite>;
|
|
22
|
+
/**
|
|
23
|
+
* toSchemaErrorTree:
|
|
24
|
+
* - Produces a subtree that can be written directly to `errors.$schema` (without the `errors.$schema` prefix).
|
|
25
|
+
*/
|
|
26
|
+
declare const toSchemaErrorTree: (schemaError: SchemaError, options?: SchemaErrorMappingOptions) => unknown;
|
|
27
|
+
/**
|
|
28
|
+
* applySchemaErrorToState:
|
|
29
|
+
* - Maps a SchemaError and writes it back into state.errors.$schema.*.
|
|
30
|
+
* - Does not clear stale errors that are no longer matched (the caller should clear them within a more explicit scope).
|
|
31
|
+
*/
|
|
32
|
+
declare const applySchemaErrorToState: (state: unknown, schemaError: SchemaError, options?: SchemaErrorMappingOptions) => unknown;
|
|
33
|
+
|
|
34
|
+
declare const SchemaErrorMapping: {
|
|
35
|
+
readonly applySchemaErrorToState: (state: unknown, schemaError: SchemaError, options?: SchemaErrorMappingOptions) => unknown;
|
|
36
|
+
readonly toSchemaErrorTree: (schemaError: SchemaError, options?: SchemaErrorMappingOptions) => unknown;
|
|
37
|
+
readonly toSchemaErrorWrites: (schemaError: SchemaError, options?: SchemaErrorMappingOptions) => ReadonlyArray<SchemaErrorWrite>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
declare const SchemaErrorMapping$1_SchemaErrorMapping: typeof SchemaErrorMapping;
|
|
41
|
+
type SchemaErrorMapping$1_SchemaErrorMappingOptions = SchemaErrorMappingOptions;
|
|
42
|
+
type SchemaErrorMapping$1_SchemaErrorWrite = SchemaErrorWrite;
|
|
43
|
+
declare const SchemaErrorMapping$1_applySchemaErrorToState: typeof applySchemaErrorToState;
|
|
44
|
+
declare const SchemaErrorMapping$1_toSchemaErrorTree: typeof toSchemaErrorTree;
|
|
45
|
+
declare const SchemaErrorMapping$1_toSchemaErrorWrites: typeof toSchemaErrorWrites;
|
|
46
|
+
declare namespace SchemaErrorMapping$1 {
|
|
47
|
+
export { SchemaErrorMapping$1_SchemaErrorMapping as SchemaErrorMapping, type SchemaErrorMapping$1_SchemaErrorMappingOptions as SchemaErrorMappingOptions, type SchemaErrorMapping$1_SchemaErrorWrite as SchemaErrorWrite, SchemaErrorMapping$1_applySchemaErrorToState as applySchemaErrorToState, SchemaErrorMapping$1_toSchemaErrorTree as toSchemaErrorTree, SchemaErrorMapping$1_toSchemaErrorWrites as toSchemaErrorWrites };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { SchemaErrorMapping$1 as S, applySchemaErrorToState as a, toSchemaErrorWrites as b, SchemaErrorMapping as c, type SchemaErrorMappingOptions as d, type SchemaErrorWrite as e, toSchemaErrorTree as t };
|