(name, error, options)
| 1265 | }; |
| 1266 | |
| 1267 | const setError: UseFormSetError<TFieldValues> = (name, error, options) => { |
| 1268 | const ref = (get(_fields, name, { _f: {} })._f || {}).ref; |
| 1269 | const currentError = get(_formState.errors, name) || {}; |
| 1270 | |
| 1271 | const { ref: currentRef, message, type, ...restOfErrorTree } = currentError; |
| 1272 | |
| 1273 | set(_formState.errors, name, { |
| 1274 | ...restOfErrorTree, |
| 1275 | ...error, |
| 1276 | ref, |
| 1277 | }); |
| 1278 | |
| 1279 | _subjects.state.next({ |
| 1280 | name, |
| 1281 | errors: _formState.errors, |
| 1282 | isValid: false, |
| 1283 | }); |
| 1284 | |
| 1285 | options && options.shouldFocus && ref && ref.focus && ref.focus(); |
| 1286 | }; |
| 1287 | |
| 1288 | const watch: UseFormWatch<TFieldValues> = ( |
| 1289 | name?: |
no outgoing calls
searching dependent graphs…