UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

21 lines (20 loc) 908 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 currencySchema = zod_1.z.number().finite().optional(); const defaultValueSchema = zod_1.z.object({ defaultValue: currencySchema.or(zod_1.z.null()) }); const currencySpecific = zod_1.z.object({ decimalLimit: zod_1.z.number().int().min(0).max(10).optional(), validate: zod_1.z .object({ min: currencySchema, max: currencySchema, }) .optional(), }); const schema = ({ intl }) => (0, validation_1.buildCommonSchema)(intl).and(defaultValueSchema).and(currencySpecific); exports.default = schema;