We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 81f293f + e6fc67d commit c68b283Copy full SHA for c68b283
1 file changed
src/index.tsx
@@ -1,7 +1,9 @@
1
import * as React from 'react';
2
import { useFormContext } from 'react-hook-form';
3
+import { FieldError } from 'react-hook-form/dist/types';
4
-type ErrorFields = Record<string, { message?: string; type: string }>;
5
+type ErrorFields = Record<string, FieldError>;
6
+type ErrorMessages<Errors> = Partial<Record<keyof Errors, string>>;
7
8
const RHFError = <Errors extends ErrorFields, Name extends keyof Errors>({
9
as,
@@ -12,7 +14,7 @@ const RHFError = <Errors extends ErrorFields, Name extends keyof Errors>({
12
14
as?: React.ReactElement;
13
15
errors?: Errors;
16
name: Name;
- messages?: Record<string, string>;
17
+ messages?: ErrorMessages<Errors>;
18
}) => {
19
const methods = useFormContext();
20
const errors = errorsFromProps || (methods.errors as Errors);
0 commit comments