UNPKG

rhf-error-util

Version:

Lightweight utility hook for safely accessing errors in react-hook-form (nested or flat)

2 lines (1 loc) 251 B
var f=t=>{for(let n in t)return!1;return!0},i=(t,n)=>{if(f(t))return;if(!n.includes("."))return t==null?void 0:t[n];let e=n.split(".");if(!(e[0]in t))return;let r=t[e[0]];e.shift();for(let o of e)r=r==null?void 0:r[o];return r};export{i as getError};