MCPcopy Index your code
hub / github.com/TanStack/form / determineFieldLevelErrorSourceAndValue

Function determineFieldLevelErrorSourceAndValue

packages/form-core/src/utils.ts:514–535  ·  view source on GitHub ↗
({
  formLevelError,
  fieldLevelError,
}: {
  formLevelError: ValidationError
  fieldLevelError: ValidationError
})

Source from the content-addressed store, hash-verified

512 * @private
513 */
514export const determineFieldLevelErrorSourceAndValue = ({
515 formLevelError,
516 fieldLevelError,
517}: {
518 formLevelError: ValidationError
519 fieldLevelError: ValidationError
520}): {
521 newErrorValue: ValidationError
522 newSource: ValidationSource | undefined
523} => {
524 // At field level, we prioritize the field level error
525 if (fieldLevelError) {
526 return { newErrorValue: fieldLevelError, newSource: 'field' }
527 }
528
529 // If there is no field level error, and there is a form level error, we set the form level error
530 if (formLevelError) {
531 return { newErrorValue: formLevelError, newSource: 'form' }
532 }
533
534 return { newErrorValue: undefined, newSource: undefined }
535}
536
537export function createFieldMap<T>(values: Readonly<T>): { [K in keyof T]: K } {
538 const output: { [K in keyof T]: K } = {} as any

Callers 3

validateFieldFnMethod · 0.90
validateFieldAsyncFnMethod · 0.90
utils.spec.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected