Skip to content

Commit c92a7d2

Browse files
committed
RruForm: feat: only validate field name on registering
1 parent d94e667 commit c92a7d2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/form/hooks/useField.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ export const useField = (name: string, onProgrammaticValue?: (serializedValue: a
2929
const [isTouched, setIsTouched] = useState<boolean>(false);
3030
const watchResult = useWatch({ name: name });
3131

32-
if (name && name.split('.').filter((p) => /^\d+$/.test(p)).length > 0) {
33-
console.error(
34-
`Field name "${name}" cannot include a numeric part. Try to prefix the numeric part with some string.`
35-
);
36-
}
37-
3832
useEffect(() => {
3933
if (isRegistered.current && onProgrammaticValue) {
4034
onProgrammaticValue(watchResult);
@@ -47,6 +41,12 @@ export const useField = (name: string, onProgrammaticValue?: (serializedValue: a
4741
return;
4842
}
4943

44+
if (name && name.split('.').filter((p) => /^\d+$/.test(p)).length > 0) {
45+
console.error(
46+
`Field name "${name}" cannot include a numeric part. Try to prefix the numeric part with some string.`
47+
);
48+
}
49+
5050
const initialValue = formContext.formState.defaultValues
5151
? resolveObjectAttribute(name, formContext.formState.defaultValues)
5252
: undefined;

0 commit comments

Comments
 (0)