@open-formulieren/formio-builder
Version:
An opinionated Formio webform builder for Open Forms
86 lines (85 loc) • 2.98 kB
TypeScript
/**
* Zod schemas for builder form validation.
*
* TODO: check the zodErrorMap implementation & patterns in the SDK for a default error
* map.
*/
import { IntlShape } from 'react-intl';
import { z } from 'zod';
/**
* Construct the localised validation schema for the component.label property.
*
* Component label is (typically) a required text for Form.io components.
*/
export declare const buildLabelSchema: (intl: IntlShape) => z.ZodString;
/**
* Construct the localised validation schema for the component.key property.
*
* The component key is used in the submission data and support lodash.get/set patterns.
* It must allow slug-characters, amended with underscores and dots for nested data
* lookups/setters. It may not end with a dash or dot for nested-data reasons.
*/
export declare const buildKeySchema: (intl: IntlShape) => z.ZodString;
/**
* Construct the localised validation schema shared by (most) Form.io components.
*
* You can use the output of this base schema with the `.and(...)` chain for additional
* component-type specific schema validations that are not/less generic in nature.
*/
export declare const buildCommonSchema: (intl: IntlShape) => z.ZodObject<{
label: z.ZodString;
key: z.ZodString;
}, "strip", z.ZodTypeAny, {
label: string;
key: string;
}, {
label: string;
key: string;
}>;
declare const literalSchema: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
type Literal = z.infer<typeof literalSchema>;
type Json = Literal | {
[key: string]: Json;
} | Json[];
export declare const jsonSchema: z.ZodType<Json>;
export declare const optionSchema: (intl: IntlShape) => z.ZodObject<{
value: z.ZodString;
label: z.ZodString;
openForms: z.ZodOptional<z.ZodObject<{
translations: z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodObject<{
label: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
label?: string | undefined;
}, {
label?: string | undefined;
}>>>;
}, "strip", z.ZodTypeAny, {
translations: Record<string, {
label?: string | undefined;
} | undefined>;
}, {
translations: Record<string, {
label?: string | undefined;
} | undefined>;
}>>;
}, "strip", z.ZodTypeAny, {
label: string;
value: string;
openForms?: {
translations: Record<string, {
label?: string | undefined;
} | undefined>;
} | undefined;
}, {
label: string;
value: string;
openForms?: {
translations: Record<string, {
label?: string | undefined;
} | undefined>;
} | undefined;
}>;
export declare const isInvalidStringIssue: (issue: z.ZodIssueOptionalMessage) => issue is z.ZodInvalidStringIssue;
type ErrorBuilder = (issue: z.ZodIssueOptionalMessage, ctx: z.ErrorMapCtx) => string | void;
export declare const getErrorMap: (builder: ErrorBuilder) => z.ZodErrorMap;
export {};