UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

57 lines (56 loc) 1.78 kB
import { z as e } from "zod"; import { buildCommonSchema as b, buildKeySchema as f } from "../validation.js"; const n = e.coerce.date().optional(), p = e.object({ multiple: e.literal(!1) }).and(e.object({ defaultValue: n })), j = e.object({ multiple: e.literal(!0) }).and(e.object({ defaultValue: n.array() })), V = p.or(j), d = e.object({ mode: e.union([e.literal(void 0), e.literal("")]) }), h = e.object({ mode: e.literal("future") }), x = e.object({ mode: e.literal("past") }), u = e.object({ mode: e.literal("fixedValue") }), c = e.null().or(e.coerce.date()), s = (a) => e.object({ mode: e.literal("relativeToVariable"), operator: e.literal("add").or(e.literal("subtract")), variable: f(a), delta: e.object({ years: e.null().or(e.number().int().gte(0)).optional(), months: e.null().or(e.number().int().gte(0)).optional(), days: e.null().or(e.number().int().gte(0)).optional() }) }), g = (a) => e.object({ openForms: e.object({ minDate: e.union([d, u, h, s(a)]).optional(), maxDate: e.union([d, u, x, s(a)]).optional() }).optional(), datePicker: e.object({ minDate: c.optional(), maxDate: c.optional() }).optional() }).superRefine((t, m) => { var l, i, r; for (const o of ["minDate", "maxDate"]) !(((i = (l = t == null ? void 0 : t.openForms) == null ? void 0 : l[o]) == null ? void 0 : i.mode) === "fixedValue") || (r = t == null ? void 0 : t.datePicker) != null && r[o] || m.addIssue({ code: e.ZodIssueCode.custom, path: ["datePicker", o], message: a.formatMessage({ id: "6Xhq/T", defaultMessage: [{ type: 0, value: "You must specify a datetime." }] }) }); }), v = ({ intl: a }) => b(a).and(V).and(g(a)); export { v as default };