Files
wdi-dashboard/node_modules/@hookform/resolvers/joi/dist/joi.module.js
2024-08-16 15:06:52 +05:30

3 lines
1.1 KiB
JavaScript

import{appendErrors as e}from"react-hook-form";import{toNestErrors as r,validateFieldsNatively as t}from"@hookform/resolvers";var n=function(n,o,a){return void 0===o&&(o={abortEarly:!1}),void 0===a&&(a={}),function(i,s,u){try{var c=function(){return l.error?{values:{},errors:r((n=l.error,o=!u.shouldUseNativeValidation&&"all"===u.criteriaMode,n.details.length?n.details.reduce(function(r,t){var n=t.path.join(".");if(r[n]||(r[n]={message:t.message,type:t.type}),o){var a=r[n].types,i=a&&a[t.type];r[n]=e(n,o,r,t.type,i?[].concat(i,t.message):t.message)}return r},{}):{}),u)}:(u.shouldUseNativeValidation&&t({},u),{errors:{},values:l.value});var n,o},v=Object.assign({},o,{context:s}),l={},f=function(){if("sync"===a.mode)l=n.validate(i,v);else{var e=function(e,r){try{var t=e()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(function(){return Promise.resolve(n.validateAsync(i,v)).then(function(e){l.value=e})},function(e){l.error=e});if(e&&e.then)return e.then(function(){})}}();return Promise.resolve(f&&f.then?f.then(c):c())}catch(e){return Promise.reject(e)}}};export{n as joiResolver};
//# sourceMappingURL=joi.module.js.map