fix: add hack for root zod validation with hook form

This commit is contained in:
Mythie
2023-09-28 15:32:03 +10:00
parent a219588287
commit a622fd402f
3 changed files with 29 additions and 16 deletions

View File

@ -4,13 +4,17 @@ import { cn } from '@documenso/ui/lib/utils';
export type FormErrorMessageProps = {
className?: string;
error: { message?: string } | undefined;
error: { message?: string } | undefined | unknown;
};
const isErrorWithMessage = (error: unknown): error is { message?: string } => {
return typeof error === 'object' && error !== null && 'message' in error;
};
export const FormErrorMessage = ({ error, className }: FormErrorMessageProps) => {
return (
<AnimatePresence>
{error && (
{isErrorWithMessage(error) && (
<motion.p
initial={{
opacity: 0,