UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

23 lines (22 loc) 901 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const zod_1 = require("zod"); const validation_1 = require("../../registry/validation"); // undefined (optional) for unspecified, otherwise a finite numeric value. Note that // null would be nicer, but formio's schema does not support null for validate.min, // validate.max or defaultValue const numberSchema = zod_1.z.number().finite().optional(); const defaultValueSchema = zod_1.z.object({ defaultValue: numberSchema.or(zod_1.z.null()), }); const numberSpecific = zod_1.z.object({ decimalLimit: zod_1.z.number().int().min(0).max(10).optional(), validate: zod_1.z .object({ min: numberSchema, max: numberSchema, }) .optional(), }); const schema = ({ intl }) => (0, validation_1.buildCommonSchema)(intl).and(defaultValueSchema).and(numberSpecific); exports.default = schema;