import { ErrorMessage as RHFErrorMessage } from "@hookform/error-message"

import styles from "./error.module.css"

import type { ErrorMessageProps } from "./errorMessage"

export default function ErrorMessage<T>({
  errors,
  name,
}: ErrorMessageProps<T>) {
  return (
    <RHFErrorMessage
      errors={errors}
      name={name}
      render={({ message }) => <p className={styles.message}>{message}</p>}
    />
  )
}
