From 6b5aa1916f6ca269788f59f371923ac37c763e63 Mon Sep 17 00:00:00 2001 From: Steven Bal Date: Tue, 9 Jul 2024 16:28:59 +0200 Subject: [PATCH] :sparkles: [open-formulieren/open-forms#4420] AddressNL component validation updated the addressNL componentschema to include components, where we define the validation for the fields under the addressNL component. It's defined under component to have a similar form as other formio components --- src/formio/components/addressNL.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/formio/components/addressNL.ts b/src/formio/components/addressNL.ts index 86b20ae..b9029b2 100644 --- a/src/formio/components/addressNL.ts +++ b/src/formio/components/addressNL.ts @@ -1,4 +1,5 @@ import {InputComponentSchema} from '..'; +import {ComponentTranslations, ErrorTranslations} from '../i18n'; type Validator = 'required'; type TranslatableKeys = 'label' | 'description' | 'tooltip'; @@ -13,6 +14,16 @@ export interface AddressData { secretStreetCity?: string; } +export interface ComponentValidation { + validate: {pattern: string}; + translatedErrors: ErrorTranslations; +} + +export interface AddressComponents { + postcode?: ComponentValidation; + city?: ComponentValidation; +} + export type AddressNLInputSchema = InputComponentSchema; /** @@ -20,8 +31,15 @@ export type AddressNLInputSchema = InputComponentSchema { + extends Omit< + AddressNLInputSchema, + 'hideLabel' | 'placeholder' | 'disabled' | 'validateOn' | 'openForms' + > { type: 'addressNL'; deriveAddress: boolean; layout: 'singleColumn' | 'doubleColumn'; + openForms?: { + components?: AddressComponents; + translations?: ComponentTranslations; + }; }