ant-design-x-vue-next
Version:
Ant Design X for Vue — community continuation aligned with @ant-design/x
36 lines (35 loc) • 1.06 kB
JavaScript
function u(e, i) {
return i.replace(/^\//, "").split("/").reduce((t, s) => t != null ? t[s] : void 0, e);
}
function f(e, i, o) {
const t = i.replace(/^\//, "").split("/"), s = { ...e };
let r = s;
for (let n = 0; n < t.length - 1; n++)
r[t[n]] = r[t[n]] ? { ...r[t[n]] } : {}, r = r[t[n]];
return r[t[t.length - 1]] = o, s;
}
function l(e) {
return typeof e == "string" && e.startsWith("/");
}
function p(e) {
return e !== null && typeof e == "object" && typeof e.path == "string";
}
function c(e, i, o) {
const t = [];
if (!(e != null && e.components))
return { valid: !0, errors: [] };
const s = e.components[i];
if (!s)
return t.push(`Component "${i}" is not defined in catalog`), { valid: !1, errors: t };
const r = s.required || [];
for (const n of r)
n in o || t.push(`Missing required field "${n}" for component "${i}"`);
return { valid: t.length === 0, errors: t };
}
export {
u as getValueByPath,
p as isPathObject,
l as isPathValue,
f as setValueByPath,
c as validateComponentAgainstCatalog
};