MCPcopy Create free account
hub / github.com/react-hook-form/react-hook-form / getValidateError

Function getValidateError

src/logic/getValidateError.ts:5–21  ·  view source on GitHub ↗
(
  result: ValidateResult,
  ref: Ref,
  type = 'validate',
)

Source from the content-addressed store, hash-verified

3import isString from '../utils/isString';
4
5export default function getValidateError(
6 result: ValidateResult,
7 ref: Ref,
8 type = 'validate',
9): FieldError | void {
10 if (
11 isString(result) ||
12 (Array.isArray(result) && result.every(isString)) ||
13 (isBoolean(result) && !result)
14 ) {
15 return {
16 type,
17 message: isString(result) ? result : '',
18 ref,
19 };
20 }
21}

Callers 2

validateField.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected