UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

20 lines (19 loc) 881 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const zod_1 = require("zod"); const validation_1 = require("../../registry/validation"); const licenseplateSchema = zod_1.z .string() .regex(/^[a-zA-Z0-9]{1,3}\-[a-zA-Z0-9]{1,3}\-[a-zA-Z0-9]{1,3}$/) .optional(); // case for when component.multiple=false const singleValueSchema = zod_1.z .object({ multiple: zod_1.z.literal(false) }) .and(zod_1.z.object({ defaultValue: licenseplateSchema })); // case for when component.multiple=true const multipleValueSchema = zod_1.z .object({ multiple: zod_1.z.literal(true) }) .and(zod_1.z.object({ defaultValue: licenseplateSchema.array() })); const defaultValueSchema = singleValueSchema.or(multipleValueSchema); const schema = ({ intl }) => (0, validation_1.buildCommonSchema)(intl).and(defaultValueSchema); exports.default = schema;