|
1 | 1 | import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers'; |
2 | 2 | import { |
3 | 3 | FieldError, |
4 | | - FieldErrors, |
5 | 4 | FieldValues, |
6 | 5 | Resolver, |
7 | 6 | ResolverError, |
@@ -105,7 +104,9 @@ function parseZod4Issues( |
105 | 104 |
|
106 | 105 | if (error.code === 'invalid_union') { |
107 | 106 | error.errors.forEach((unionError) => |
108 | | - unionError.forEach((e) => zodErrors.push(e)), |
| 107 | + unionError.forEach((e) => |
| 108 | + zodErrors.push({ ...e, path: [...error.path, ...e.path] }), |
| 109 | + ), |
109 | 110 | ); |
110 | 111 | } |
111 | 112 |
|
@@ -254,7 +255,7 @@ export function zodResolver<Input extends FieldValues, Context, Output>( |
254 | 255 | validateFieldsNatively({}, options); |
255 | 256 |
|
256 | 257 | return { |
257 | | - errors: {} as FieldErrors, |
| 258 | + errors: {}, |
258 | 259 | values: resolverOptions.raw ? Object.assign({}, values) : data, |
259 | 260 | } satisfies ResolverSuccess<Output | Input>; |
260 | 261 | } catch (error) { |
@@ -288,7 +289,7 @@ export function zodResolver<Input extends FieldValues, Context, Output>( |
288 | 289 | validateFieldsNatively({}, options); |
289 | 290 |
|
290 | 291 | return { |
291 | | - errors: {} as FieldErrors, |
| 292 | + errors: {}, |
292 | 293 | values: resolverOptions.raw ? Object.assign({}, values) : data, |
293 | 294 | } satisfies ResolverSuccess<Output | Input>; |
294 | 295 | } catch (error) { |
|
0 commit comments