diff --git a/src/components/FormField/FormField.tsx b/src/components/FormField/FormField.tsx index 8c6f359d..8957c400 100644 --- a/src/components/FormField/FormField.tsx +++ b/src/components/FormField/FormField.tsx @@ -7,7 +7,7 @@ import styles from './FormField.module.css'; type Props = { label?: string; hint?: ReactNode; - errorMessage?: string; + errorMessage?: string | (string | undefined)[]; className?: string; children: ReactNode; }; @@ -16,11 +16,23 @@ const FormField: React.FC = ({ label, className, children, hint, errorMes const mergedClassNames = classNames(cssReset.ventura, className, { [styles.isSpaced]: Boolean(label), }); + + let errorMessages: string[] = []; + if (Array.isArray(errorMessage)) { + errorMessages = errorMessage.filter(Boolean) as string[]; + } else if (errorMessage) { + errorMessages = [errorMessage]; + } + return (
{Boolean(label) && {label}} {children} - {Boolean(errorMessage) && {errorMessage}} + {errorMessages.map((err) => ( + + {err} + + ))} {Boolean(hint) &&
{hint}
}
);