@dudeofawesome/hookform-resolvers
Version:
React Hook Form validation resolvers: Yup, Joi, Superstruct, Zod, Vest, Class Validator, io-ts, Nope, computed-types, TypeBox, arktype, Typanion, Effect-TS and VineJS
3 lines (2 loc) • 1.02 kB
JavaScript
import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{plainToClass as t}from"class-transformer";import{validateSync as o,validate as n}from"class-validator";var s=function(r,e,t,o){return void 0===t&&(t={}),void 0===o&&(o=""),r.reduce(function(r,t){var n=o?o+"."+t.property:t.property;if(t.constraints){var i=Object.keys(t.constraints)[0];r[n]={type:i,message:t.constraints[i]};var a=r[n];e&&a&&Object.assign(a,{types:t.constraints})}return t.children&&t.children.length&&s(t.children,e,r,n),r},t)},i=function(i,a,c){return void 0===a&&(a={}),void 0===c&&(c={}),function(l,u,v){try{var d=a.validator,m=t(i,l,a.transformer);return Promise.resolve(("sync"===c.mode?o:n)(m,d)).then(function(t){return t.length?{values:{},errors:r(s(t,!v.shouldUseNativeValidation&&"all"===v.criteriaMode),v)}:(v.shouldUseNativeValidation&&e({},v),{values:c.rawValues?l:m,errors:{}})})}catch(r){return Promise.reject(r)}}};export{i as classValidatorResolver};
//# sourceMappingURL=class-validator.module.js.map