Skip to content

Commit

Permalink
✨ [open-formulieren/open-forms#4420] AddressNL component validation
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stevenbal committed Aug 12, 2024
1 parent 0492542 commit 6b5aa19
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/formio/components/addressNL.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {InputComponentSchema} from '..';
import {ComponentTranslations, ErrorTranslations} from '../i18n';

type Validator = 'required';
type TranslatableKeys = 'label' | 'description' | 'tooltip';
Expand All @@ -13,15 +14,32 @@ export interface AddressData {
secretStreetCity?: string;
}

export interface ComponentValidation {
validate: {pattern: string};
translatedErrors: ErrorTranslations;
}

export interface AddressComponents {
postcode?: ComponentValidation;
city?: ComponentValidation;
}

export type AddressNLInputSchema = InputComponentSchema<AddressData, Validator, TranslatableKeys>;

/**
* @group Form.io components
* @category Concrete types
*/
export interface AddressNLComponentSchema
extends Omit<AddressNLInputSchema, 'hideLabel' | 'placeholder' | 'disabled' | 'validateOn'> {
extends Omit<
AddressNLInputSchema,
'hideLabel' | 'placeholder' | 'disabled' | 'validateOn' | 'openForms'
> {
type: 'addressNL';
deriveAddress: boolean;
layout: 'singleColumn' | 'doubleColumn';
openForms?: {
components?: AddressComponents;
translations?: ComponentTranslations<TranslatableKeys>;
};
}

0 comments on commit 6b5aa19

Please sign in to comment.