@open-formulieren/formio-builder
Version:
An opinionated Formio webform builder for Open Forms
55 lines (54 loc) • 1.57 kB
JavaScript
import { z as e } from "zod";
import { buildCommonSchema as o, jsonSchema as t, optionSchema as m } from "../validation.js";
const f = (a) => e.object({
values: m(a).array().optional(),
openForms: e.object({
dataSrc: e.union([e.literal("manual"), e.literal("variable"), e.literal("referenceLists")]),
// TODO: wire up infernologic type checking
itemsExpression: t.optional(),
service: e.string().optional(),
code: e.string().optional()
})
}).superRefine((s, r) => {
var i, u;
if (((i = s == null ? void 0 : s.openForms) == null ? void 0 : i.dataSrc) === "manual" && ((s == null ? void 0 : s.values) ?? []).length < 1)
r.addIssue({
code: e.ZodIssueCode.too_small,
path: ["values"],
minimum: 1,
inclusive: !0,
type: "number"
});
else if (((u = s == null ? void 0 : s.openForms) == null ? void 0 : u.dataSrc) === "referenceLists") {
const {
service: l,
code: d
} = s.openForms;
l || r.addIssue({
code: e.ZodIssueCode.custom,
path: ["openForms", "service"],
message: a.formatMessage({
id: "7HlMn7",
defaultMessage: [{
type: 0,
value: "You must select a service."
}]
})
}), d || r.addIssue({
code: e.ZodIssueCode.custom,
path: ["openForms", "code"],
message: a.formatMessage({
id: "i/P7yw",
defaultMessage: [{
type: 0,
value: "You must select a table."
}]
})
});
}
}), g = ({
intl: a
}) => o(a).and(f(a));
export {
g as default
};