Skip to content

Commit 14a30f4

Browse files
Use FormValue in Form component (#2709)
* Use FormValue in Form component * Update useForm.ts --------- Co-authored-by: Pascal Baljet <pascal@pascalbaljet.nl>
1 parent 3a6bdc9 commit 14a30f4

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

packages/core/src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,8 @@ export type FormComponentProps = Partial<
613613
export type FormComponentMethods = {
614614
clearErrors: (...fields: string[]) => void
615615
resetAndClearErrors: (...fields: string[]) => void
616-
setError(field: string, value: string): void
617-
setError(errors: Record<string, string>): void
616+
setError(field: string, value: ErrorValue): void
617+
setError(errors: Record<string, ErrorValue>): void
618618
reset: (...fields: string[]) => void
619619
submit: () => void
620620
defaults: () => void
@@ -625,7 +625,7 @@ export type FormComponentMethods = {
625625
export type FormComponentonSubmitCompleteArguments = Pick<FormComponentMethods, 'reset' | 'defaults'>
626626

627627
export type FormComponentState = {
628-
errors: Record<string, string>
628+
errors: Record<string, ErrorValue>
629629
hasErrors: boolean
630630
processing: boolean
631631
progress: Progress | null

packages/react/src/useForm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export default function useForm<TForm extends FormDataType<TForm>>(
293293
)
294294

295295
const setError = useCallback(
296-
(fieldOrFields: FormDataKeys<TForm> | FormDataErrors<TForm>, maybeValue?: string) => {
296+
(fieldOrFields: FormDataKeys<TForm> | FormDataErrors<TForm>, maybeValue?: ErrorValue) => {
297297
setErrors((errors) => {
298298
const newErrors = {
299299
...errors,

packages/svelte/src/useForm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default function useForm<TForm extends FormDataType<TForm>>(
7171
const inputData = (typeof rememberKeyOrData === 'string' ? maybeData : rememberKeyOrData) ?? {}
7272
const data: TForm = typeof inputData === 'function' ? inputData() : (inputData as TForm)
7373
const restored = rememberKey
74-
? (router.restore(rememberKey) as { data: TForm; errors: Record<FormDataKeys<TForm>, string> } | null)
74+
? (router.restore(rememberKey) as { data: TForm; errors: Record<FormDataKeys<TForm>, ErrorValue> } | null)
7575
: null
7676
let defaults = cloneDeep(data)
7777
let cancelToken: CancelToken | null = null

packages/vue3/src/useForm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default function useForm<TForm extends FormDataType<TForm>>(
6161
const rememberKey = typeof rememberKeyOrData === 'string' ? rememberKeyOrData : null
6262
const data = (typeof rememberKeyOrData === 'string' ? maybeData : rememberKeyOrData) ?? {}
6363
const restored = rememberKey
64-
? (router.restore(rememberKey) as { data: TForm; errors: Record<FormDataKeys<TForm>, string> })
64+
? (router.restore(rememberKey) as { data: TForm; errors: Record<FormDataKeys<TForm>, ErrorValue> })
6565
: null
6666
let defaults = typeof data === 'function' ? cloneDeep(data()) : cloneDeep(data)
6767
let cancelToken: CancelToken | null = null

0 commit comments

Comments
 (0)