@open-formulieren/formio-builder
Version:
An opinionated Formio webform builder for Open Forms
43 lines (42 loc) • 1.05 kB
JavaScript
import { defineMessages as u } from "react-intl";
import { z as e } from "zod";
import { LABELS as i } from "../../components/builder/messages.js";
import { buildCommonSchema as m, getErrorMap as d, isInvalidStringIssue as c } from "../validation.js";
import { POSTCODE_REGEX as n } from "./constants.js";
const f = u({
postcode: {
id: "4CuHYk",
defaultMessage: [{
type: 1,
value: "field"
}, {
type: 0,
value: " must be a valid postcode."
}]
}
}), p = (a) => {
const t = e.string({
errorMap: d((o) => {
if (c(o) && o.validation === "regex") {
const s = a.formatMessage(i.defaultValue);
return a.formatMessage(f.postcode, {
field: s
});
}
})
}).regex(new RegExp(n)).optional(), r = e.object({
multiple: e.literal(!1)
}).and(e.object({
defaultValue: t
})), l = e.object({
multiple: e.literal(!0)
}).and(e.object({
defaultValue: t.array()
}));
return r.or(l);
}, V = ({
intl: a
}) => m(a).and(p(a));
export {
V as default
};