@hookform/resolvers
Version:
React Hook Form validation resolvers: Yup, Joi, Superstruct, Zod, Vest, Class Validator, io-ts, Nope, computed-types, TypeBox, arktype and Typanion
3 lines (2 loc) • 1.06 kB
JavaScript
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react-hook-form"),require("@hookform/resolvers"),require("@sinclair/typebox/value")):"function"==typeof define&&define.amd?define(["exports","react-hook-form","@hookform/resolvers","@sinclair/typebox/value"],r):r((e||self).hookformResolversTypebox={},e.ReactHookForm,e.hookformResolvers,e.value)}(this,function(e,r,o,t){var s=function(e,o){for(var t={};e.length;){var s=e[0],a=s.type,i=s.message,l=s.path.substring(1).replace(/\//g,".");if(t[l]||(t[l]={message:i,type:""+a}),o){var n=t[l].types,f=n&&n[""+a];t[l]=r.appendErrors(l,o,t,""+a,f?[].concat(f,s.message):s.message)}e.shift()}return t};e.typeboxResolver=function(e){return function(r,a,i){try{var l=Array.from(t.Value.Errors(e,r));return i.shouldUseNativeValidation&&o.validateFieldsNatively({},i),Promise.resolve(l.length?{values:{},errors:o.toNestError(s(l,!i.shouldUseNativeValidation&&"all"===i.criteriaMode),i)}:{errors:{},values:r})}catch(e){return Promise.reject(e)}}}});
//# sourceMappingURL=typebox.umd.js.map