UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

59 lines (58 loc) 1.84 kB
import { z as e } from "zod"; import { buildCommonSchema as b, buildKeySchema as f } from "../validation.js"; const s = e.coerce.date().optional(), p = e.object({ multiple: e.literal(!1) }).and(e.object({ defaultValue: s })), j = e.object({ multiple: e.literal(!0) }).and(e.object({ defaultValue: s.array() })), V = p.or(j), r = e.object({ mode: e.union([e.literal(void 0), e.literal("")]) }), h = e.object({ mode: e.literal("future"), includeToday: e.boolean() }), x = e.object({ mode: e.literal("past"), includeToday: e.boolean() }), u = e.object({ mode: e.literal("fixedValue") }), c = e.null().or(e.coerce.date()), n = (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() }) }), y = (a) => e.object({ openForms: e.object({ minDate: e.union([r, u, h, n(a)]).optional(), maxDate: e.union([r, u, x, n(a)]).optional() }).optional(), datePicker: e.object({ minDate: c.optional(), maxDate: c.optional() }).optional() }).superRefine((t, m) => { var l, i, d; 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") || (d = t == null ? void 0 : t.datePicker) != null && d[o] || m.addIssue({ code: e.ZodIssueCode.custom, path: ["datePicker", o], message: a.formatMessage({ id: "RiFNuZ", defaultMessage: [{ type: 0, value: "You must specify a date." }] }) }); }), v = ({ intl: a }) => b(a).and(V).and(y(a)); export { v as default };