import{validateFieldsNatively as e,toNestErrors as r}from"@hookform/resolvers";import{validate as t}from"@typeschema/main";import{appendErrors as o}from"react-hook-form";var s=function(e,r){for(var t={};e.length;){var s=e[0];if(s.path){var a=s.path.join(".");if(t[a]||(t[a]={message:s.message,type:""}),r){var i=t[a].types,n=i&&i[""];t[a]=o(a,r,t,"",n?[].concat(n,s.message):s.message)}e.shift()}}return t},a=function(o,a,i){return void 0===i&&(i={}),function(a,n,m){try{return Promise.resolve(t(o,a)).then(function(t){return m.shouldUseNativeValidation&&e({},m),t.success?{errors:{},values:i.raw?Object.assign({},a):t.data}:{values:{},errors:r(s(t.issues,!m.shouldUseNativeValidation&&"all"===m.criteriaMode),m)}})}catch(e){return Promise.reject(e)}}};export{a as typeschemaResolver};
//# sourceMappingURL=typeschema.module.js.map
