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

import Error from "./Error"

import type { ErrorMessageProps } from "./errorMessage"

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