import type { AnyFieldMeta } from "@tanstack/react-form";

type FieldErrorsProps = {
	meta: AnyFieldMeta;
};

export const FieldErrors = ({ meta }: FieldErrorsProps) => {
	if (!meta.isTouched) return null;

	return meta.errors.map((error) => (
		<p
			key={`${error.message}-${error.code ?? "err"}`}
			className="text-sm font-medium text-destructive"
		>
			{error.message}
		</p>
	));
};
