@open-formulieren/formio-builder
Version:
An opinionated Formio webform builder for Open Forms
39 lines (38 loc) • 895 B
JavaScript
import { z as t } from "zod";
import { buildCommonSchema as o } from "../validation.js";
const i = (e) => t.string().refine((m) => /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/.test(m), {
message: e.formatMessage({
id: "klYCow",
defaultMessage: [{
type: 0,
value: "The time must a valid time in the HH:mm format."
}]
})
}), a = (e) => t.union([
i(e),
t.literal(""),
t.undefined(),
// formik (deliberately) turns empty string into undefined
t.null()
]), u = (e) => t.object({
multiple: t.literal(!1)
}).and(t.object({
defaultValue: a(e)
})), c = (e) => t.object({
multiple: t.literal(!0)
}).and(t.object({
defaultValue: a(e).array()
})), n = (e) => t.object({
validate: t.object({
minTime: a(e),
maxTime: a(e)
}).optional()
}), d = ({
intl: e
}) => {
const m = o(e), l = u(e).or(c(e));
return m.and(l).and(n(e));
};
export {
d as default
};