Open History to see the last commit
1import type { FieldErrorDebugCase } from './types'
2β
3export const serverErrorOnUnmountedField = {
4 evaluate: ({ field, error }) => {
5 if (
6 field._isMounted ||
7 error.source.scope !== 'form' ||
8 error.sourceEvent !== 'server'
9 ) {
10 return undefined
11 }
12β
13 const validator =
14 field.form._validatorInstances?.[error.source.validatorIndex]?.definition
15 const hasServerTrigger = validator?.triggers?.includes('server')
16β
17 if (!hasServerTrigger) return undefined
18β
19 return {
20 kind: 'server-error-on-unmounted-field',
21 evidence: {
22 fieldPath: field.name,
23 },
24 }
25 },
26} satisfies FieldErrorDebugCase