Socket
Socket
Sign inDemoInstall

@hookform/resolvers

Package Overview
Dependencies
Maintainers
3
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hookform/resolvers - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

2

class-validator/dist/class-validator.js

@@ -1,2 +0,2 @@

var t,e=require("@hookform/resolvers");function n(){return(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(t||(t={}));var o=new(function(){function e(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return e.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},e.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},e.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},e.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},e.prototype.findTransformMetadatas=function(e,n,o){return this.findMetadatas(this._transformMetadatas,e,n).filter(function(e){return!e.options||!0===e.options.toClassOnly&&!0===e.options.toPlainOnly||(!0===e.options.toClassOnly?o===t.CLASS_TO_CLASS||o===t.PLAIN_TO_CLASS:!0!==e.options.toPlainOnly||o===t.CLASS_TO_PLAIN)})},e.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},e.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},e.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find(function(t){return t.options&&t.options.name===e})},e.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},e.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),n=e&&e.get(void 0),o=this._exposeMetadatas.get(t),r=o&&o.get(void 0);return n&&r||!n&&!r?"none":n?"excludeAll":"exposeAll"},e.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},e.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},e.prototype.getExposedProperties=function(e,n){return this.getExposedMetadatas(e).filter(function(e){return!e.options||!0===e.options.toClassOnly&&!0===e.options.toPlainOnly||(!0===e.options.toClassOnly?n===t.CLASS_TO_CLASS||n===t.PLAIN_TO_CLASS:!0!==e.options.toPlainOnly||n===t.CLASS_TO_PLAIN)}).map(function(t){return t.propertyName})},e.prototype.getExcludedProperties=function(e,n){return this.getExcludedMetadatas(e).filter(function(e){return!e.options||!0===e.options.toClassOnly&&!0===e.options.toPlainOnly||(!0===e.options.toClassOnly?n===t.CLASS_TO_CLASS||n===t.PLAIN_TO_CLASS:!0!==e.options.toPlainOnly||n===t.CLASS_TO_PLAIN)}).map(function(t){return t.propertyName})},e.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},e.prototype.getMetadata=function(t,e){var n,o=t.get(e);o&&(n=Array.from(o.values()).filter(function(t){return void 0!==t.propertyName}));for(var r=[],i=0,a=this.getAncestors(e);i<a.length;i++){var s=t.get(a[i]);if(s){var p=Array.from(s.values()).filter(function(t){return void 0!==t.propertyName});r.push.apply(r,p)}}return r.concat(n||[])},e.prototype.findMetadata=function(t,e,n){var o=t.get(e);if(o){var r=o.get(n);if(r)return r}for(var i=0,a=this.getAncestors(e);i<a.length;i++){var s=t.get(a[i]);if(s){var p=s.get(n);if(p)return p}}},e.prototype.findMetadatas=function(t,e,n){var o,r=t.get(e);r&&(o=r.get(n));for(var i=[],a=0,s=this.getAncestors(e);a<s.length;a++){var p=t.get(s[a]);p&&p.has(n)&&i.push.apply(i,p.get(n))}return i.slice().reverse().concat((o||[]).slice().reverse())},e.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],n=Object.getPrototypeOf(t.prototype.constructor);void 0!==n.prototype;n=Object.getPrototypeOf(n.prototype.constructor))e.push(n);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},e}()),r=function(){function e(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return e.prototype.transform=function(e,n,r,i,a,s){var p,c=this;if(void 0===s&&(s=0),Array.isArray(n)||n instanceof Set){var u=i&&this.transformationType===t.PLAIN_TO_CLASS?function(t){var e=new t;return e instanceof Set||"push"in e?e:[]}(i):[];return n.forEach(function(n,o){var i=e?e[o]:void 0;if(c.options.enableCircularCheck&&c.isCircular(n))c.transformationType===t.CLASS_TO_CLASS&&(u instanceof Set?u.add(n):u.push(n));else{var a=void 0;if("function"!=typeof r&&r&&r.options&&r.options.discriminator&&r.options.discriminator.property&&r.options.discriminator.subTypes){if(c.transformationType===t.PLAIN_TO_CLASS){a=r.options.discriminator.subTypes.find(function(t){return t.name===n[r.options.discriminator.property]});var p=r.typeFunction({newObject:u,object:n,property:void 0});a=void 0===a?p:a.value,r.options.keepDiscriminatorProperty||delete n[r.options.discriminator.property]}c.transformationType===t.CLASS_TO_CLASS&&(a=n.constructor),c.transformationType===t.CLASS_TO_PLAIN&&(n[r.options.discriminator.property]=r.options.discriminator.subTypes.find(function(t){return t.value===n.constructor}).name)}else a=r;var f=c.transform(i,n,a,void 0,n instanceof Map,s+1);u instanceof Set?u.add(f):u.push(f)}}),u}if(r!==String||a){if(r!==Number||a){if(r!==Boolean||a){if((r===Date||n instanceof Date)&&!a)return n instanceof Date?new Date(n.valueOf()):null==n?n:new Date(n);if(("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0).Buffer&&(r===Buffer||n instanceof Buffer)&&!a)return null==n?n:Buffer.from(n);if(null===(p=n)||"object"!=typeof p||"function"!=typeof p.then||a){if(a||null===n||"object"!=typeof n||"function"!=typeof n.then){if("object"==typeof n&&null!==n){r||n.constructor===Object||(r=n.constructor),!r&&e&&(r=e.constructor),this.options.enableCircularCheck&&this.recursionStack.add(n);var f=this.getKeys(r,n,a),l=e||{};e||this.transformationType!==t.PLAIN_TO_CLASS&&this.transformationType!==t.CLASS_TO_CLASS||(l=a?new Map:r?new r:{});for(var d=function(i){if("__proto__"===i||"constructor"===i)return"continue";var p=i,c=i,u=i;if(!h.options.ignoreDecorators&&r)if(h.transformationType===t.PLAIN_TO_CLASS)(f=o.findExposeMetadataByCustomName(r,i))&&(u=f.propertyName,c=f.propertyName);else if(h.transformationType===t.CLASS_TO_PLAIN||h.transformationType===t.CLASS_TO_CLASS){var f;(f=o.findExposeMetadata(r,i))&&f.options&&f.options.name&&(c=f.options.name)}var d=void 0;d=n instanceof Map?n.get(p):n[p]instanceof Function?n[p]():n[p];var y=void 0,v=d instanceof Map;if(r&&a)y=r;else if(r){var g=o.findTypeMetadata(r,u);if(g){var m=g.typeFunction?g.typeFunction({newObject:l,object:n,property:u}):g.reflectedType;g.options&&g.options.discriminator&&g.options.discriminator.property&&g.options.discriminator.subTypes?n[p]instanceof Array?y=g:(h.transformationType===t.PLAIN_TO_CLASS&&(y=void 0===(y=g.options.discriminator.subTypes.find(function(t){if(d&&d instanceof Object&&g.options.discriminator.property in d)return t.name===d[g.options.discriminator.property]}))?m:y.value,g.options.keepDiscriminatorProperty||d&&d instanceof Object&&g.options.discriminator.property in d&&delete d[g.options.discriminator.property]),h.transformationType===t.CLASS_TO_CLASS&&(y=d.constructor),h.transformationType===t.CLASS_TO_PLAIN&&(d[g.options.discriminator.property]=g.options.discriminator.subTypes.find(function(t){return t.value===d.constructor}).name)):y=m,v=v||g.reflectedType===Map}else if(h.options.targetMaps)h.options.targetMaps.filter(function(t){return t.target===r&&!!t.properties[u]}).forEach(function(t){return y=t.properties[u]});else if(h.options.enableImplicitConversion&&h.transformationType===t.PLAIN_TO_CLASS){var S=Reflect.getMetadata("design:type",r.prototype,u);S&&(y=S)}}var O=Array.isArray(n[p])?h.getReflectedType(r,u):void 0,T=e?e[p]:void 0;if(l.constructor.prototype){var A=Object.getOwnPropertyDescriptor(l.constructor.prototype,c);if((h.transformationType===t.PLAIN_TO_CLASS||h.transformationType===t.CLASS_TO_CLASS)&&(A&&!A.set||l[c]instanceof Function))return"continue"}if(h.options.enableCircularCheck&&h.isCircular(d))h.transformationType===t.CLASS_TO_CLASS&&(void 0!==(M=h.applyCustomTransformations(M=d,r,i,n,h.transformationType))||h.options.exposeUnsetFields)&&(l instanceof Map?l.set(c,M):l[c]=M);else{var _=h.transformationType===t.PLAIN_TO_CLASS?c:i,M=void 0;h.transformationType===t.CLASS_TO_PLAIN?(M=h.applyCustomTransformations(M=n[_],r,_,n,h.transformationType),M=h.transform(T,M=n[_]===M?d:M,y,O,v,s+1)):void 0===d&&h.options.exposeDefaultValues?M=l[c]:(M=h.transform(T,d,y,O,v,s+1),M=h.applyCustomTransformations(M,r,_,n,h.transformationType)),(void 0!==M||h.options.exposeUnsetFields)&&(l instanceof Map?l.set(c,M):l[c]=M)}},h=this,y=0,v=f;y<v.length;y++)d(v[y]);return this.options.enableCircularCheck&&this.recursionStack.delete(n),l}return n}return n}return new Promise(function(t,e){n.then(function(e){return t(c.transform(void 0,e,r,void 0,void 0,s+1))},e)})}return null==n?n:Boolean(n)}return null==n?n:Number(n)}return null==n?n:String(n)},e.prototype.applyCustomTransformations=function(t,e,n,r,i){var a=this,s=o.findTransformMetadatas(e,n,this.transformationType);return void 0!==this.options.version&&(s=s.filter(function(t){return!t.options||a.checkVersion(t.options.since,t.options.until)})),(s=s.filter(this.options.groups&&this.options.groups.length?function(t){return!t.options||a.checkGroups(t.options.groups)}:function(t){return!t.options||!t.options.groups||!t.options.groups.length})).forEach(function(e){t=e.transformFn({value:t,key:n,obj:r,type:i,options:a.options})}),t},e.prototype.isCircular=function(t){return this.recursionStack.has(t)},e.prototype.getReflectedType=function(t,e){if(t){var n=o.findTypeMetadata(t,e);return n?n.reflectedType:void 0}},e.prototype.getKeys=function(e,n,r){var i=this,a=o.getStrategy(e);"none"===a&&(a=this.options.strategy||"exposeAll");var s=[];if(("exposeAll"===a||r)&&(s=n instanceof Map?Array.from(n.keys()):Object.keys(n)),r)return s;if(!this.options.ignoreDecorators&&e){var p=o.getExposedProperties(e,this.transformationType);this.transformationType===t.PLAIN_TO_CLASS&&(p=p.map(function(t){var n=o.findExposeMetadata(e,t);return n&&n.options&&n.options.name?n.options.name:t})),s=this.options.excludeExtraneousValues?p:s.concat(p);var c=o.getExcludedProperties(e,this.transformationType);c.length>0&&(s=s.filter(function(t){return!c.includes(t)})),void 0!==this.options.version&&(s=s.filter(function(t){var n=o.findExposeMetadata(e,t);return!n||!n.options||i.checkVersion(n.options.since,n.options.until)})),s=s.filter(this.options.groups&&this.options.groups.length?function(t){var n=o.findExposeMetadata(e,t);return!n||!n.options||i.checkGroups(n.options.groups)}:function(t){var n=o.findExposeMetadata(e,t);return!(n&&n.options&&n.options.groups&&n.options.groups.length)})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(s=s.filter(function(t){return i.options.excludePrefixes.every(function(e){return t.substr(0,e.length)!==e})})),s.filter(function(t,e,n){return n.indexOf(t)===e})},e.prototype.checkVersion=function(t,e){var n=!0;return n&&t&&(n=this.options.version>=t),n&&e&&(n=this.options.version<e),n},e.prototype.checkGroups=function(t){return!t||this.options.groups.some(function(e){return t.includes(e)})},e}(),i={enableCircularCheck:!1,enableImplicitConversion:!1,excludeExtraneousValues:!1,excludePrefixes:void 0,exposeDefaultValues:!1,exposeUnsetFields:!0,groups:void 0,ignoreDecorators:!1,strategy:void 0,targetMaps:void 0,version:void 0},a=function(){return(a=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},s=new(function(){function e(){}return e.prototype.classToPlain=function(e,n){return new r(t.CLASS_TO_PLAIN,a(a({},i),n)).transform(void 0,e,void 0,void 0,void 0,void 0)},e.prototype.classToPlainFromExist=function(e,n,o){return new r(t.CLASS_TO_PLAIN,a(a({},i),o)).transform(n,e,void 0,void 0,void 0,void 0)},e.prototype.plainToClass=function(e,n,o){return new r(t.PLAIN_TO_CLASS,a(a({},i),o)).transform(void 0,n,e,void 0,void 0,void 0)},e.prototype.plainToClassFromExist=function(e,n,o){return new r(t.PLAIN_TO_CLASS,a(a({},i),o)).transform(e,n,void 0,void 0,void 0,void 0)},e.prototype.classToClass=function(e,n){return new r(t.CLASS_TO_CLASS,a(a({},i),n)).transform(void 0,e,void 0,void 0,void 0,void 0)},e.prototype.classToClassFromExist=function(e,n,o){return new r(t.CLASS_TO_CLASS,a(a({},i),o)).transform(n,e,void 0,void 0,void 0,void 0)},e.prototype.serialize=function(t,e){return JSON.stringify(this.classToPlain(t,e))},e.prototype.deserialize=function(t,e,n){var o=JSON.parse(e);return this.plainToClass(t,o,n)},e.prototype.deserializeArray=function(t,e,n){var o=JSON.parse(e);return this.plainToClass(t,o,n)},e}()),p=function(t){this.groups=[],this.each=!1,this.context=void 0,this.type=t.type,this.target=t.target,this.propertyName=t.propertyName,this.constraints=t.constraints,this.constraintCls=t.constraintCls,this.validationTypeOptions=t.validationTypeOptions,t.validationOptions&&(this.message=t.validationOptions.message,this.groups=t.validationOptions.groups,this.always=t.validationOptions.always,this.each=t.validationOptions.each,this.context=t.validationOptions.context)},c=function(){function t(){}return t.prototype.transform=function(t){var e=[];return Object.keys(t.properties).forEach(function(n){t.properties[n].forEach(function(o){e.push(new p({type:o.type,target:t.name,propertyName:n,constraints:o.constraints,validationTypeOptions:o.options,validationOptions:{message:o.message,groups:o.groups,always:o.always,each:o.each}}))})}),e},t}();function u(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function f(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var l=function(){function t(){this.validationMetadatas=[],this.constraintMetadatas=[]}return Object.defineProperty(t.prototype,"hasValidationMetaData",{get:function(){return!!this.validationMetadatas.length},enumerable:!1,configurable:!0}),t.prototype.addValidationSchema=function(t){var e=this;(new c).transform(t).forEach(function(t){return e.addValidationMetadata(t)})},t.prototype.addValidationMetadata=function(t){this.validationMetadatas.push(t)},t.prototype.addConstraintMetadata=function(t){this.constraintMetadatas.push(t)},t.prototype.groupByPropertyName=function(t){var e={};return t.forEach(function(t){e[t.propertyName]||(e[t.propertyName]=[]),e[t.propertyName].push(t)}),e},t.prototype.getTargetValidationMetadatas=function(t,e,n,o,r){var i=function(t){return void 0!==t.always?t.always:(!t.groups||!t.groups.length)&&n},a=function(t){return!(!o||r&&r.length||!t.groups||!t.groups.length)},s=this.validationMetadatas.filter(function(n){return(n.target===t||n.target===e)&&(!!i(n)||!a(n)&&(!(r&&r.length>0)||n.groups&&!!n.groups.find(function(t){return-1!==r.indexOf(t)})))}),p=this.validationMetadatas.filter(function(e){return"string"!=typeof e.target&&e.target!==t&&(!(e.target instanceof Function)||t.prototype instanceof e.target)&&(!!i(e)||!a(e)&&(!(r&&r.length>0)||e.groups&&!!e.groups.find(function(t){return-1!==r.indexOf(t)})))}).filter(function(t){return!s.find(function(e){return e.propertyName===t.propertyName&&e.type===t.type})});return s.concat(p)},t.prototype.getTargetValidatorConstraints=function(t){return this.constraintMetadatas.filter(function(e){return e.target===t})},t}(),d=function(){function t(){}return t.prototype.toString=function(t,e,n){var o=this;void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===n&&(n="");var r=t?"":"",i=t?"":"",a=function(t){return" - property "+r+n+t+i+" has failed the following constraints: "+r+Object.keys(o.constraints).join(", ")+i+" \n"};if(e){var s=Number.isInteger(+this.property)?"["+this.property+"]":(n?".":"")+this.property;return this.constraints?a(s):this.children?this.children.map(function(e){return e.toString(t,!0,""+n+s)}).join(""):""}return"An instance of "+r+(this.target?this.target.constructor.name:"an object")+i+" has failed the validation:\n"+(this.constraints?a(this.property):"")+(this.children?this.children.map(function(e){return e.toString(t,!0,o.property)}).join(""):"")},t}(),h=function(){function t(){}return t.isValid=function(t){var e=this;return"isValid"!==t&&"getMessage"!==t&&-1!==Object.keys(this).map(function(t){return e[t]}).indexOf(t)},t.CUSTOM_VALIDATION="customValidation",t.NESTED_VALIDATION="nestedValidation",t.PROMISE_VALIDATION="promiseValidation",t.CONDITIONAL_VALIDATION="conditionalValidation",t.WHITELIST="whitelistValidation",t.IS_DEFINED="isDefined",t}(),y=function(){function t(){}return t.replaceMessageSpecialTokens=function(t,e){var n;return t instanceof Function?n=t(e):"string"==typeof t&&(n=t),n&&e.constraints instanceof Array&&e.constraints.forEach(function(t,e){n=n.replace(new RegExp("\\$constraint"+(e+1),"g"),function(t){return Array.isArray(t)?t.join(", "):""+t}(t))}),n&&null!=e.value&&"string"==typeof e.value&&(n=n.replace(/\$value/g,e.value)),n&&(n=n.replace(/\$property/g,e.property)),n&&(n=n.replace(/\$target/g,e.targetName)),n},t}(),v=function(){function t(t,e){this.validator=t,this.validatorOptions=e,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=function(){var t=u();return t.classValidatorMetadataStorage||(t.classValidatorMetadataStorage=new l),t.classValidatorMetadataStorage}()}return t.prototype.execute=function(t,e,n){var o,r=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(o=this.validatorOptions)||void 0===o?void 0:o.enableDebugMessages)||console.warn("No metadata found. There is more than once class-validator version installed probably. You need to flatten your dependencies.");var i=this.metadataStorage.getTargetValidationMetadatas(t.constructor,e,this.validatorOptions&&this.validatorOptions.always||!1,this.validatorOptions&&this.validatorOptions.strictGroups||!1,this.validatorOptions?this.validatorOptions.groups:void 0),a=this.metadataStorage.groupByPropertyName(i);if(this.validatorOptions&&this.validatorOptions.forbidUnknownValues&&!i.length){var s=new d;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(s.target=t),s.value=void 0,s.property=void 0,s.children=[],s.constraints={unknownValue:"an unknown value was passed to the validate function"},void n.push(s)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(t,a,n),Object.keys(a).forEach(function(e){var o=t[e],i=a[e].filter(function(t){return t.type===h.IS_DEFINED}),s=a[e].filter(function(t){return t.type!==h.IS_DEFINED&&t.type!==h.WHITELIST});o instanceof Promise&&s.find(function(t){return t.type===h.PROMISE_VALIDATION})?r.awaitingPromises.push(o.then(function(o){r.performValidations(t,o,e,i,s,n)})):r.performValidations(t,o,e,i,s,n)})},t.prototype.whitelist=function(t,e,n){var o=this,r=[];Object.keys(t).forEach(function(t){e[t]&&0!==e[t].length||r.push(t)}),r.length>0&&r.forEach(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?function(e){var r,i=o.generateValidationError(t,t[e],e);i.constraints=((r={})[h.WHITELIST]="property "+e+" should not exist",r),i.children=void 0,n.push(i)}:function(e){return delete t[e]})},t.prototype.stripEmptyErrors=function(t){var e=this;return t.filter(function(t){if(t.children&&(t.children=e.stripEmptyErrors(t.children)),0===Object.keys(t.constraints).length){if(0===t.children.length)return!1;delete t.constraints}return!0})},t.prototype.performValidations=function(t,e,n,o,r,i){var a=r.filter(function(t){return t.type===h.CUSTOM_VALIDATION}),s=r.filter(function(t){return t.type===h.NESTED_VALIDATION}),p=r.filter(function(t){return t.type===h.CONDITIONAL_VALIDATION}),c=this.generateValidationError(t,e,n);i.push(c),this.conditionalValidations(t,e,p)&&(this.customValidations(t,e,o,c),this.mapContexts(t,e,o,c),void 0===e&&this.validatorOptions&&!0===this.validatorOptions.skipUndefinedProperties||null===e&&this.validatorOptions&&!0===this.validatorOptions.skipNullProperties||null==e&&this.validatorOptions&&!0===this.validatorOptions.skipMissingProperties||(this.customValidations(t,e,a,c),this.nestedValidations(e,s,c.children),this.mapContexts(t,e,r,c),this.mapContexts(t,e,a,c)))},t.prototype.generateValidationError=function(t,e,n){var o=new d;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(o.target=t),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(o.value=e),o.property=n,o.children=[],o.constraints={},o},t.prototype.conditionalValidations=function(t,e,n){return n.map(function(n){return n.constraints[0](t,e)}).reduce(function(t,e){return t&&e},!0)},t.prototype.customValidations=function(t,e,n,o){var r=this;n.forEach(function(n){r.metadataStorage.getTargetValidatorConstraints(n.constraintCls).forEach(function(i){if(!(i.async&&r.ignoreAsyncValidations||r.validatorOptions&&r.validatorOptions.stopAtFirstError&&Object.keys(o.constraints||{}).length>0)){var a={targetName:t.constructor?t.constructor.name:void 0,property:n.propertyName,object:t,value:e,constraints:n.constraints};if(n.each&&(e instanceof Array||e instanceof Set||e instanceof Map)){var s,p=((s=e)instanceof Map?Array.from(s.values()):Array.isArray(s)?s:Array.from(s)).map(function(t){return i.instance.validate(t,a)});if(p.some(function(t){return f(t)})){var c=p.map(function(t){return f(t)?t:Promise.resolve(t)}),u=Promise.all(c).then(function(a){if(!a.every(function(t){return t})){var s=r.createValidationError(t,e,n,i),p=s[0];o.constraints[p]=s[1],n.context&&(o.contexts||(o.contexts={}),o.contexts[p]=Object.assign(o.contexts[p]||{},n.context))}});r.awaitingPromises.push(u)}else if(!p.every(function(t){return t})){var l=r.createValidationError(t,e,n,i);o.constraints[l[0]]=l[1]}}else{var d=i.instance.validate(e,a);if(f(d)){var h=d.then(function(a){if(!a){var s=r.createValidationError(t,e,n,i),p=s[0];o.constraints[p]=s[1],n.context&&(o.contexts||(o.contexts={}),o.contexts[p]=Object.assign(o.contexts[p]||{},n.context))}});r.awaitingPromises.push(h)}else if(!d){var y=r.createValidationError(t,e,n,i);o.constraints[y[0]]=y[1]}}}})})},t.prototype.nestedValidations=function(t,e,n){var o=this;void 0!==t&&e.forEach(function(r){var i;if(r.type===h.NESTED_VALIDATION||r.type===h.PROMISE_VALIDATION)if(t instanceof Array||t instanceof Set||t instanceof Map)(t instanceof Set?Array.from(t):t).forEach(function(r,i){o.performValidations(t,r,i.toString(),[],e,n)});else if(t instanceof Object)o.execute(t,"string"==typeof r.target?r.target:r.target.name,n);else{var a=new d;a.value=t,a.property=r.propertyName,a.target=r.target;var s=o.createValidationError(r.target,t,r);a.constraints=((i={})[s[0]]=s[1],i),n.push(a)}})},t.prototype.mapContexts=function(t,e,n,o){var r=this;return n.forEach(function(t){if(t.context){var e=void 0;t.type===h.CUSTOM_VALIDATION&&(e=r.metadataStorage.getTargetValidatorConstraints(t.constraintCls)[0]);var n=r.getConstraintType(t,e);o.constraints[n]&&(o.contexts||(o.contexts={}),o.contexts[n]=Object.assign(o.contexts[n]||{},t.context))}})},t.prototype.createValidationError=function(t,e,n,o){var r=t.constructor?t.constructor.name:void 0,i=this.getConstraintType(n,o),a={targetName:r,property:n.propertyName,object:t,value:e,constraints:n.constraints},s=n.message||"";return n.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||o&&o.instance.defaultMessage instanceof Function&&(s=o.instance.defaultMessage(a)),[i,y.replaceMessageSpecialTokens(s,a)]},t.prototype.getConstraintType=function(t,e){return e&&e.name?e.name:t.type},t}(),g=function(){function t(){}return t.prototype.validate=function(t,e,n){return this.coreValidate(t,e,n)},t.prototype.validateOrReject=function(t,e,n){return o=this,i=function(){var o;return function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,function(r){switch(r.label){case 0:return[4,this.coreValidate(t,e,n)];case 1:return(o=r.sent()).length?[2,Promise.reject(o)]:[2]}})},new((r=void 0)||(r=Promise))(function(t,e){function n(t){try{s(i.next(t))}catch(t){e(t)}}function a(t){try{s(i.throw(t))}catch(t){e(t)}}function s(e){var o;e.done?t(e.value):(o=e.value,o instanceof r?o:new r(function(t){t(o)})).then(n,a)}s((i=i.apply(o,[])).next())});var o,r,i},t.prototype.validateSync=function(t,e,n){var o="string"==typeof t?e:t,r="string"==typeof t?t:void 0,i=new v(this,"string"==typeof t?n:e);i.ignoreAsyncValidations=!0;var a=[];return i.execute(o,r,a),i.stripEmptyErrors(a)},t.prototype.coreValidate=function(t,e,n){var o="string"==typeof t?e:t,r="string"==typeof t?t:void 0,i=new v(this,"string"==typeof t?n:e),a=[];return i.execute(o,r,a),Promise.all(i.awaitingPromises).then(function(){return i.stripEmptyErrors(a)})},t}(),m=new(function(){function t(){this.instances=[]}return t.prototype.get=function(t){var e=this.instances.find(function(e){return e.type===t});return e||(e={type:t,object:new t},this.instances.push(e)),e.object},t}());function S(t){return m.get(t)}var O=function(t){return t.reduce(function(t,e){var o;return n({},t,((o={})[e[0]]=e[1],o))},{})},T=function t(e){var n,o,r;return e.children&&e.children.length>0?O(e.children.map(function(e){return[e.property,t(e)]})):{message:null==(n=Object.entries(null!=(r=e.constraints)?r:{}))||null==(o=n[0])?void 0:o[1]}};exports.classValidatorResolver=function(t,n,o){return void 0===n&&(n={}),void 0===o&&(o={}),function(r,i,a){try{var p=function(t){return 0===t.length?{values:r,errors:{}}:{values:{},errors:e.toNestError(function(t){var e=O(t.map(function(t){return[t.property,T(t)]}));return t.length>0?e:{}}(t),a.fields)}},c=s.plainToClass(t,r,void 0);return Promise.resolve("sync"===o.mode?p((f=n,"string"==typeof(u=c)?S(g).validateSync(u,f,void 0):S(g).validateSync(u,f))):Promise.resolve(function(t,e,n){return"string"==typeof t?S(g).validate(t,e,void 0):S(g).validate(t,e)}(c,n)).then(p))}catch(t){return Promise.reject(t)}var u,f}};
var r=require("@hookform/resolvers"),e=require("class-transformer"),t=require("class-validator"),s=function r(e,t,s,n){return void 0===s&&(s={}),void 0===n&&(n=""),e.reduce(function(e,s){var o=n?n+"."+s.property:s.property;if(s.constraints){var i=Object.keys(s.constraints)[0];e[o]={type:i,message:s.constraints[i]},t&&e[o]&&Object.assign(e[o],{types:s.constraints})}return s.children&&s.children.length&&r(s.children,t,e,o),e},s)};exports.classValidatorResolver=function(n,o,i){return void 0===o&&(o={}),void 0===i&&(i={}),function(a,c,l){try{var u=e.plainToClass(n,a);return Promise.resolve(("sync"===i.mode?t.validateSync:t.validate)(u,o)).then(function(e){return e.length?{values:{},errors:r.toNestError(s(e,"all"===l.criteriaMode),l.fields)}:{values:a,errors:{}}})}catch(r){return Promise.reject(r)}}};
//# sourceMappingURL=class-validator.js.map

@@ -1,2 +0,2 @@

import{toNestError as t}from"@hookform/resolvers";function e(){return(e=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}var n;!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(n||(n={}));var o=new(function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,o){return this.findMetadatas(this._transformMetadatas,t,e).filter(function(t){return!t.options||!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?o===n.CLASS_TO_CLASS||o===n.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||o===n.CLASS_TO_PLAIN)})},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find(function(t){return t.options&&t.options.name===e})},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),n=e&&e.get(void 0),o=this._exposeMetadatas.get(t),r=o&&o.get(void 0);return n&&r||!n&&!r?"none":n?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter(function(t){return!t.options||!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===n.CLASS_TO_CLASS||e===n.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===n.CLASS_TO_PLAIN)}).map(function(t){return t.propertyName})},t.prototype.getExcludedProperties=function(t,e){return this.getExcludedMetadatas(t).filter(function(t){return!t.options||!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===n.CLASS_TO_CLASS||e===n.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===n.CLASS_TO_PLAIN)}).map(function(t){return t.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var n,o=t.get(e);o&&(n=Array.from(o.values()).filter(function(t){return void 0!==t.propertyName}));for(var r=[],i=0,a=this.getAncestors(e);i<a.length;i++){var s=t.get(a[i]);if(s){var p=Array.from(s.values()).filter(function(t){return void 0!==t.propertyName});r.push.apply(r,p)}}return r.concat(n||[])},t.prototype.findMetadata=function(t,e,n){var o=t.get(e);if(o){var r=o.get(n);if(r)return r}for(var i=0,a=this.getAncestors(e);i<a.length;i++){var s=t.get(a[i]);if(s){var p=s.get(n);if(p)return p}}},t.prototype.findMetadatas=function(t,e,n){var o,r=t.get(e);r&&(o=r.get(n));for(var i=[],a=0,s=this.getAncestors(e);a<s.length;a++){var p=t.get(s[a]);p&&p.has(n)&&i.push.apply(i,p.get(n))}return i.slice().reverse().concat((o||[]).slice().reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],n=Object.getPrototypeOf(t.prototype.constructor);void 0!==n.prototype;n=Object.getPrototypeOf(n.prototype.constructor))e.push(n);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}()),r=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,r,i,a,s){var p,c=this;if(void 0===s&&(s=0),Array.isArray(e)||e instanceof Set){var u=i&&this.transformationType===n.PLAIN_TO_CLASS?function(t){var e=new t;return e instanceof Set||"push"in e?e:[]}(i):[];return e.forEach(function(e,o){var i=t?t[o]:void 0;if(c.options.enableCircularCheck&&c.isCircular(e))c.transformationType===n.CLASS_TO_CLASS&&(u instanceof Set?u.add(e):u.push(e));else{var a=void 0;if("function"!=typeof r&&r&&r.options&&r.options.discriminator&&r.options.discriminator.property&&r.options.discriminator.subTypes){if(c.transformationType===n.PLAIN_TO_CLASS){a=r.options.discriminator.subTypes.find(function(t){return t.name===e[r.options.discriminator.property]});var p=r.typeFunction({newObject:u,object:e,property:void 0});a=void 0===a?p:a.value,r.options.keepDiscriminatorProperty||delete e[r.options.discriminator.property]}c.transformationType===n.CLASS_TO_CLASS&&(a=e.constructor),c.transformationType===n.CLASS_TO_PLAIN&&(e[r.options.discriminator.property]=r.options.discriminator.subTypes.find(function(t){return t.value===e.constructor}).name)}else a=r;var f=c.transform(i,e,a,void 0,e instanceof Map,s+1);u instanceof Set?u.add(f):u.push(f)}}),u}if(r!==String||a){if(r!==Number||a){if(r!==Boolean||a){if((r===Date||e instanceof Date)&&!a)return e instanceof Date?new Date(e.valueOf()):null==e?e:new Date(e);if(("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0).Buffer&&(r===Buffer||e instanceof Buffer)&&!a)return null==e?e:Buffer.from(e);if(null===(p=e)||"object"!=typeof p||"function"!=typeof p.then||a){if(a||null===e||"object"!=typeof e||"function"!=typeof e.then){if("object"==typeof e&&null!==e){r||e.constructor===Object||(r=e.constructor),!r&&t&&(r=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var f=this.getKeys(r,e,a),l=t||{};t||this.transformationType!==n.PLAIN_TO_CLASS&&this.transformationType!==n.CLASS_TO_CLASS||(l=a?new Map:r?new r:{});for(var d=function(i){if("__proto__"===i||"constructor"===i)return"continue";var p=i,c=i,u=i;if(!h.options.ignoreDecorators&&r)if(h.transformationType===n.PLAIN_TO_CLASS)(f=o.findExposeMetadataByCustomName(r,i))&&(u=f.propertyName,c=f.propertyName);else if(h.transformationType===n.CLASS_TO_PLAIN||h.transformationType===n.CLASS_TO_CLASS){var f;(f=o.findExposeMetadata(r,i))&&f.options&&f.options.name&&(c=f.options.name)}var d=void 0;d=e instanceof Map?e.get(p):e[p]instanceof Function?e[p]():e[p];var y=void 0,v=d instanceof Map;if(r&&a)y=r;else if(r){var g=o.findTypeMetadata(r,u);if(g){var m=g.typeFunction?g.typeFunction({newObject:l,object:e,property:u}):g.reflectedType;g.options&&g.options.discriminator&&g.options.discriminator.property&&g.options.discriminator.subTypes?e[p]instanceof Array?y=g:(h.transformationType===n.PLAIN_TO_CLASS&&(y=void 0===(y=g.options.discriminator.subTypes.find(function(t){if(d&&d instanceof Object&&g.options.discriminator.property in d)return t.name===d[g.options.discriminator.property]}))?m:y.value,g.options.keepDiscriminatorProperty||d&&d instanceof Object&&g.options.discriminator.property in d&&delete d[g.options.discriminator.property]),h.transformationType===n.CLASS_TO_CLASS&&(y=d.constructor),h.transformationType===n.CLASS_TO_PLAIN&&(d[g.options.discriminator.property]=g.options.discriminator.subTypes.find(function(t){return t.value===d.constructor}).name)):y=m,v=v||g.reflectedType===Map}else if(h.options.targetMaps)h.options.targetMaps.filter(function(t){return t.target===r&&!!t.properties[u]}).forEach(function(t){return y=t.properties[u]});else if(h.options.enableImplicitConversion&&h.transformationType===n.PLAIN_TO_CLASS){var S=Reflect.getMetadata("design:type",r.prototype,u);S&&(y=S)}}var O=Array.isArray(e[p])?h.getReflectedType(r,u):void 0,T=t?t[p]:void 0;if(l.constructor.prototype){var A=Object.getOwnPropertyDescriptor(l.constructor.prototype,c);if((h.transformationType===n.PLAIN_TO_CLASS||h.transformationType===n.CLASS_TO_CLASS)&&(A&&!A.set||l[c]instanceof Function))return"continue"}if(h.options.enableCircularCheck&&h.isCircular(d))h.transformationType===n.CLASS_TO_CLASS&&(void 0!==(M=h.applyCustomTransformations(M=d,r,i,e,h.transformationType))||h.options.exposeUnsetFields)&&(l instanceof Map?l.set(c,M):l[c]=M);else{var _=h.transformationType===n.PLAIN_TO_CLASS?c:i,M=void 0;h.transformationType===n.CLASS_TO_PLAIN?(M=h.applyCustomTransformations(M=e[_],r,_,e,h.transformationType),M=h.transform(T,M=e[_]===M?d:M,y,O,v,s+1)):void 0===d&&h.options.exposeDefaultValues?M=l[c]:(M=h.transform(T,d,y,O,v,s+1),M=h.applyCustomTransformations(M,r,_,e,h.transformationType)),(void 0!==M||h.options.exposeUnsetFields)&&(l instanceof Map?l.set(c,M):l[c]=M)}},h=this,y=0,v=f;y<v.length;y++)d(v[y]);return this.options.enableCircularCheck&&this.recursionStack.delete(e),l}return e}return e}return new Promise(function(t,n){e.then(function(e){return t(c.transform(void 0,e,r,void 0,void 0,s+1))},n)})}return null==e?e:Boolean(e)}return null==e?e:Number(e)}return null==e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,n,r,i){var a=this,s=o.findTransformMetadatas(e,n,this.transformationType);return void 0!==this.options.version&&(s=s.filter(function(t){return!t.options||a.checkVersion(t.options.since,t.options.until)})),(s=s.filter(this.options.groups&&this.options.groups.length?function(t){return!t.options||a.checkGroups(t.options.groups)}:function(t){return!t.options||!t.options.groups||!t.options.groups.length})).forEach(function(e){t=e.transformFn({value:t,key:n,obj:r,type:i,options:a.options})}),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var n=o.findTypeMetadata(t,e);return n?n.reflectedType:void 0}},t.prototype.getKeys=function(t,e,r){var i=this,a=o.getStrategy(t);"none"===a&&(a=this.options.strategy||"exposeAll");var s=[];if(("exposeAll"===a||r)&&(s=e instanceof Map?Array.from(e.keys()):Object.keys(e)),r)return s;if(!this.options.ignoreDecorators&&t){var p=o.getExposedProperties(t,this.transformationType);this.transformationType===n.PLAIN_TO_CLASS&&(p=p.map(function(e){var n=o.findExposeMetadata(t,e);return n&&n.options&&n.options.name?n.options.name:e})),s=this.options.excludeExtraneousValues?p:s.concat(p);var c=o.getExcludedProperties(t,this.transformationType);c.length>0&&(s=s.filter(function(t){return!c.includes(t)})),void 0!==this.options.version&&(s=s.filter(function(e){var n=o.findExposeMetadata(t,e);return!n||!n.options||i.checkVersion(n.options.since,n.options.until)})),s=s.filter(this.options.groups&&this.options.groups.length?function(e){var n=o.findExposeMetadata(t,e);return!n||!n.options||i.checkGroups(n.options.groups)}:function(e){var n=o.findExposeMetadata(t,e);return!(n&&n.options&&n.options.groups&&n.options.groups.length)})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(s=s.filter(function(t){return i.options.excludePrefixes.every(function(e){return t.substr(0,e.length)!==e})})),s.filter(function(t,e,n){return n.indexOf(t)===e})},t.prototype.checkVersion=function(t,e){var n=!0;return n&&t&&(n=this.options.version>=t),n&&e&&(n=this.options.version<e),n},t.prototype.checkGroups=function(t){return!t||this.options.groups.some(function(e){return t.includes(e)})},t}(),i={enableCircularCheck:!1,enableImplicitConversion:!1,excludeExtraneousValues:!1,excludePrefixes:void 0,exposeDefaultValues:!1,exposeUnsetFields:!0,groups:void 0,ignoreDecorators:!1,strategy:void 0,targetMaps:void 0,version:void 0},a=function(){return(a=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},s=new(function(){function t(){}return t.prototype.classToPlain=function(t,e){return new r(n.CLASS_TO_PLAIN,a(a({},i),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,o){return new r(n.CLASS_TO_PLAIN,a(a({},i),o)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToClass=function(t,e,o){return new r(n.PLAIN_TO_CLASS,a(a({},i),o)).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,o){return new r(n.PLAIN_TO_CLASS,a(a({},i),o)).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.classToClass=function(t,e){return new r(n.CLASS_TO_CLASS,a(a({},i),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,o){return new r(n.CLASS_TO_CLASS,a(a({},i),o)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.classToPlain(t,e))},t.prototype.deserialize=function(t,e,n){var o=JSON.parse(e);return this.plainToClass(t,o,n)},t.prototype.deserializeArray=function(t,e,n){var o=JSON.parse(e);return this.plainToClass(t,o,n)},t}()),p=function(t){this.groups=[],this.each=!1,this.context=void 0,this.type=t.type,this.target=t.target,this.propertyName=t.propertyName,this.constraints=t.constraints,this.constraintCls=t.constraintCls,this.validationTypeOptions=t.validationTypeOptions,t.validationOptions&&(this.message=t.validationOptions.message,this.groups=t.validationOptions.groups,this.always=t.validationOptions.always,this.each=t.validationOptions.each,this.context=t.validationOptions.context)},c=function(){function t(){}return t.prototype.transform=function(t){var e=[];return Object.keys(t.properties).forEach(function(n){t.properties[n].forEach(function(o){e.push(new p({type:o.type,target:t.name,propertyName:n,constraints:o.constraints,validationTypeOptions:o.options,validationOptions:{message:o.message,groups:o.groups,always:o.always,each:o.each}}))})}),e},t}();function u(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function f(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var l=function(){function t(){this.validationMetadatas=[],this.constraintMetadatas=[]}return Object.defineProperty(t.prototype,"hasValidationMetaData",{get:function(){return!!this.validationMetadatas.length},enumerable:!1,configurable:!0}),t.prototype.addValidationSchema=function(t){var e=this;(new c).transform(t).forEach(function(t){return e.addValidationMetadata(t)})},t.prototype.addValidationMetadata=function(t){this.validationMetadatas.push(t)},t.prototype.addConstraintMetadata=function(t){this.constraintMetadatas.push(t)},t.prototype.groupByPropertyName=function(t){var e={};return t.forEach(function(t){e[t.propertyName]||(e[t.propertyName]=[]),e[t.propertyName].push(t)}),e},t.prototype.getTargetValidationMetadatas=function(t,e,n,o,r){var i=function(t){return void 0!==t.always?t.always:(!t.groups||!t.groups.length)&&n},a=function(t){return!(!o||r&&r.length||!t.groups||!t.groups.length)},s=this.validationMetadatas.filter(function(n){return(n.target===t||n.target===e)&&(!!i(n)||!a(n)&&(!(r&&r.length>0)||n.groups&&!!n.groups.find(function(t){return-1!==r.indexOf(t)})))}),p=this.validationMetadatas.filter(function(e){return"string"!=typeof e.target&&e.target!==t&&(!(e.target instanceof Function)||t.prototype instanceof e.target)&&(!!i(e)||!a(e)&&(!(r&&r.length>0)||e.groups&&!!e.groups.find(function(t){return-1!==r.indexOf(t)})))}).filter(function(t){return!s.find(function(e){return e.propertyName===t.propertyName&&e.type===t.type})});return s.concat(p)},t.prototype.getTargetValidatorConstraints=function(t){return this.constraintMetadatas.filter(function(e){return e.target===t})},t}(),d=function(){function t(){}return t.prototype.toString=function(t,e,n){var o=this;void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===n&&(n="");var r=t?"":"",i=t?"":"",a=function(t){return" - property "+r+n+t+i+" has failed the following constraints: "+r+Object.keys(o.constraints).join(", ")+i+" \n"};if(e){var s=Number.isInteger(+this.property)?"["+this.property+"]":(n?".":"")+this.property;return this.constraints?a(s):this.children?this.children.map(function(e){return e.toString(t,!0,""+n+s)}).join(""):""}return"An instance of "+r+(this.target?this.target.constructor.name:"an object")+i+" has failed the validation:\n"+(this.constraints?a(this.property):"")+(this.children?this.children.map(function(e){return e.toString(t,!0,o.property)}).join(""):"")},t}(),h=function(){function t(){}return t.isValid=function(t){var e=this;return"isValid"!==t&&"getMessage"!==t&&-1!==Object.keys(this).map(function(t){return e[t]}).indexOf(t)},t.CUSTOM_VALIDATION="customValidation",t.NESTED_VALIDATION="nestedValidation",t.PROMISE_VALIDATION="promiseValidation",t.CONDITIONAL_VALIDATION="conditionalValidation",t.WHITELIST="whitelistValidation",t.IS_DEFINED="isDefined",t}(),y=function(){function t(){}return t.replaceMessageSpecialTokens=function(t,e){var n;return t instanceof Function?n=t(e):"string"==typeof t&&(n=t),n&&e.constraints instanceof Array&&e.constraints.forEach(function(t,e){n=n.replace(new RegExp("\\$constraint"+(e+1),"g"),function(t){return Array.isArray(t)?t.join(", "):""+t}(t))}),n&&null!=e.value&&"string"==typeof e.value&&(n=n.replace(/\$value/g,e.value)),n&&(n=n.replace(/\$property/g,e.property)),n&&(n=n.replace(/\$target/g,e.targetName)),n},t}(),v=function(){function t(t,e){this.validator=t,this.validatorOptions=e,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=function(){var t=u();return t.classValidatorMetadataStorage||(t.classValidatorMetadataStorage=new l),t.classValidatorMetadataStorage}()}return t.prototype.execute=function(t,e,n){var o,r=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(o=this.validatorOptions)||void 0===o?void 0:o.enableDebugMessages)||console.warn("No metadata found. There is more than once class-validator version installed probably. You need to flatten your dependencies.");var i=this.metadataStorage.getTargetValidationMetadatas(t.constructor,e,this.validatorOptions&&this.validatorOptions.always||!1,this.validatorOptions&&this.validatorOptions.strictGroups||!1,this.validatorOptions?this.validatorOptions.groups:void 0),a=this.metadataStorage.groupByPropertyName(i);if(this.validatorOptions&&this.validatorOptions.forbidUnknownValues&&!i.length){var s=new d;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(s.target=t),s.value=void 0,s.property=void 0,s.children=[],s.constraints={unknownValue:"an unknown value was passed to the validate function"},void n.push(s)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(t,a,n),Object.keys(a).forEach(function(e){var o=t[e],i=a[e].filter(function(t){return t.type===h.IS_DEFINED}),s=a[e].filter(function(t){return t.type!==h.IS_DEFINED&&t.type!==h.WHITELIST});o instanceof Promise&&s.find(function(t){return t.type===h.PROMISE_VALIDATION})?r.awaitingPromises.push(o.then(function(o){r.performValidations(t,o,e,i,s,n)})):r.performValidations(t,o,e,i,s,n)})},t.prototype.whitelist=function(t,e,n){var o=this,r=[];Object.keys(t).forEach(function(t){e[t]&&0!==e[t].length||r.push(t)}),r.length>0&&r.forEach(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?function(e){var r,i=o.generateValidationError(t,t[e],e);i.constraints=((r={})[h.WHITELIST]="property "+e+" should not exist",r),i.children=void 0,n.push(i)}:function(e){return delete t[e]})},t.prototype.stripEmptyErrors=function(t){var e=this;return t.filter(function(t){if(t.children&&(t.children=e.stripEmptyErrors(t.children)),0===Object.keys(t.constraints).length){if(0===t.children.length)return!1;delete t.constraints}return!0})},t.prototype.performValidations=function(t,e,n,o,r,i){var a=r.filter(function(t){return t.type===h.CUSTOM_VALIDATION}),s=r.filter(function(t){return t.type===h.NESTED_VALIDATION}),p=r.filter(function(t){return t.type===h.CONDITIONAL_VALIDATION}),c=this.generateValidationError(t,e,n);i.push(c),this.conditionalValidations(t,e,p)&&(this.customValidations(t,e,o,c),this.mapContexts(t,e,o,c),void 0===e&&this.validatorOptions&&!0===this.validatorOptions.skipUndefinedProperties||null===e&&this.validatorOptions&&!0===this.validatorOptions.skipNullProperties||null==e&&this.validatorOptions&&!0===this.validatorOptions.skipMissingProperties||(this.customValidations(t,e,a,c),this.nestedValidations(e,s,c.children),this.mapContexts(t,e,r,c),this.mapContexts(t,e,a,c)))},t.prototype.generateValidationError=function(t,e,n){var o=new d;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(o.target=t),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(o.value=e),o.property=n,o.children=[],o.constraints={},o},t.prototype.conditionalValidations=function(t,e,n){return n.map(function(n){return n.constraints[0](t,e)}).reduce(function(t,e){return t&&e},!0)},t.prototype.customValidations=function(t,e,n,o){var r=this;n.forEach(function(n){r.metadataStorage.getTargetValidatorConstraints(n.constraintCls).forEach(function(i){if(!(i.async&&r.ignoreAsyncValidations||r.validatorOptions&&r.validatorOptions.stopAtFirstError&&Object.keys(o.constraints||{}).length>0)){var a={targetName:t.constructor?t.constructor.name:void 0,property:n.propertyName,object:t,value:e,constraints:n.constraints};if(n.each&&(e instanceof Array||e instanceof Set||e instanceof Map)){var s,p=((s=e)instanceof Map?Array.from(s.values()):Array.isArray(s)?s:Array.from(s)).map(function(t){return i.instance.validate(t,a)});if(p.some(function(t){return f(t)})){var c=p.map(function(t){return f(t)?t:Promise.resolve(t)}),u=Promise.all(c).then(function(a){if(!a.every(function(t){return t})){var s=r.createValidationError(t,e,n,i),p=s[0];o.constraints[p]=s[1],n.context&&(o.contexts||(o.contexts={}),o.contexts[p]=Object.assign(o.contexts[p]||{},n.context))}});r.awaitingPromises.push(u)}else if(!p.every(function(t){return t})){var l=r.createValidationError(t,e,n,i);o.constraints[l[0]]=l[1]}}else{var d=i.instance.validate(e,a);if(f(d)){var h=d.then(function(a){if(!a){var s=r.createValidationError(t,e,n,i),p=s[0];o.constraints[p]=s[1],n.context&&(o.contexts||(o.contexts={}),o.contexts[p]=Object.assign(o.contexts[p]||{},n.context))}});r.awaitingPromises.push(h)}else if(!d){var y=r.createValidationError(t,e,n,i);o.constraints[y[0]]=y[1]}}}})})},t.prototype.nestedValidations=function(t,e,n){var o=this;void 0!==t&&e.forEach(function(r){var i;if(r.type===h.NESTED_VALIDATION||r.type===h.PROMISE_VALIDATION)if(t instanceof Array||t instanceof Set||t instanceof Map)(t instanceof Set?Array.from(t):t).forEach(function(r,i){o.performValidations(t,r,i.toString(),[],e,n)});else if(t instanceof Object)o.execute(t,"string"==typeof r.target?r.target:r.target.name,n);else{var a=new d;a.value=t,a.property=r.propertyName,a.target=r.target;var s=o.createValidationError(r.target,t,r);a.constraints=((i={})[s[0]]=s[1],i),n.push(a)}})},t.prototype.mapContexts=function(t,e,n,o){var r=this;return n.forEach(function(t){if(t.context){var e=void 0;t.type===h.CUSTOM_VALIDATION&&(e=r.metadataStorage.getTargetValidatorConstraints(t.constraintCls)[0]);var n=r.getConstraintType(t,e);o.constraints[n]&&(o.contexts||(o.contexts={}),o.contexts[n]=Object.assign(o.contexts[n]||{},t.context))}})},t.prototype.createValidationError=function(t,e,n,o){var r=t.constructor?t.constructor.name:void 0,i=this.getConstraintType(n,o),a={targetName:r,property:n.propertyName,object:t,value:e,constraints:n.constraints},s=n.message||"";return n.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||o&&o.instance.defaultMessage instanceof Function&&(s=o.instance.defaultMessage(a)),[i,y.replaceMessageSpecialTokens(s,a)]},t.prototype.getConstraintType=function(t,e){return e&&e.name?e.name:t.type},t}(),g=function(){function t(){}return t.prototype.validate=function(t,e,n){return this.coreValidate(t,e,n)},t.prototype.validateOrReject=function(t,e,n){return o=this,i=function(){var o;return function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,function(r){switch(r.label){case 0:return[4,this.coreValidate(t,e,n)];case 1:return(o=r.sent()).length?[2,Promise.reject(o)]:[2]}})},new((r=void 0)||(r=Promise))(function(t,e){function n(t){try{s(i.next(t))}catch(t){e(t)}}function a(t){try{s(i.throw(t))}catch(t){e(t)}}function s(e){var o;e.done?t(e.value):(o=e.value,o instanceof r?o:new r(function(t){t(o)})).then(n,a)}s((i=i.apply(o,[])).next())});var o,r,i},t.prototype.validateSync=function(t,e,n){var o="string"==typeof t?e:t,r="string"==typeof t?t:void 0,i=new v(this,"string"==typeof t?n:e);i.ignoreAsyncValidations=!0;var a=[];return i.execute(o,r,a),i.stripEmptyErrors(a)},t.prototype.coreValidate=function(t,e,n){var o="string"==typeof t?e:t,r="string"==typeof t?t:void 0,i=new v(this,"string"==typeof t?n:e),a=[];return i.execute(o,r,a),Promise.all(i.awaitingPromises).then(function(){return i.stripEmptyErrors(a)})},t}(),m=new(function(){function t(){this.instances=[]}return t.prototype.get=function(t){var e=this.instances.find(function(e){return e.type===t});return e||(e={type:t,object:new t},this.instances.push(e)),e.object},t}());function S(t){return m.get(t)}const O=t=>t.reduce((t,[n,o])=>e({},t,{[n]:o}),{}),T=t=>{var e,n,o;return t.children&&t.children.length>0?O(t.children.map(t=>[t.property,T(t)])):{message:null==(e=Object.entries(null!=(o=t.constraints)?o:{}))||null==(n=e[0])?void 0:n[1]}},A=(e,n={},o={})=>async(r,i,a)=>{const p=s.plainToClass(e,r,void 0),c="sync"===o.mode?(f=n,"string"==typeof(u=p)?S(g).validateSync(u,f,void 0):S(g).validateSync(u,f)):await function(t,e,n){return"string"==typeof t?S(g).validate(t,e,void 0):S(g).validate(t,e)}(p,n);var u,f;return 0===c.length?{values:r,errors:{}}:{values:{},errors:t((t=>{const e=O(t.map(t=>[t.property,T(t)]));return t.length>0?e:{}})(c),a.fields)}};export{A as classValidatorResolver};
import{toNestError as r}from"@hookform/resolvers";import{plainToClass as s}from"class-transformer";import{validateSync as e,validate as t}from"class-validator";const o=(r,s,e={},t="")=>r.reduce((r,e)=>{const n=t?`${t}.${e.property}`:e.property;if(e.constraints){const t=Object.keys(e.constraints)[0];r[n]={type:t,message:e.constraints[t]},s&&r[n]&&Object.assign(r[n],{types:e.constraints})}return e.children&&e.children.length&&o(e.children,s,r,n),r},e),n=(n,c={},a={})=>async(i,l,m)=>{const p=s(n,i),d=await("sync"===a.mode?e:t)(p,c);return d.length?{values:{},errors:r(o(d,"all"===m.criteriaMode),m.fields)}:{values:i,errors:{}}};export{n as classValidatorResolver};
//# sourceMappingURL=class-validator.modern.js.map

@@ -1,2 +0,2 @@

import{toNestError as t}from"@hookform/resolvers";function e(){return(e=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}var n;!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(n||(n={}));var o=new(function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,o){return this.findMetadatas(this._transformMetadatas,t,e).filter(function(t){return!t.options||!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?o===n.CLASS_TO_CLASS||o===n.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||o===n.CLASS_TO_PLAIN)})},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find(function(t){return t.options&&t.options.name===e})},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),n=e&&e.get(void 0),o=this._exposeMetadatas.get(t),r=o&&o.get(void 0);return n&&r||!n&&!r?"none":n?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter(function(t){return!t.options||!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===n.CLASS_TO_CLASS||e===n.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===n.CLASS_TO_PLAIN)}).map(function(t){return t.propertyName})},t.prototype.getExcludedProperties=function(t,e){return this.getExcludedMetadatas(t).filter(function(t){return!t.options||!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===n.CLASS_TO_CLASS||e===n.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===n.CLASS_TO_PLAIN)}).map(function(t){return t.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var n,o=t.get(e);o&&(n=Array.from(o.values()).filter(function(t){return void 0!==t.propertyName}));for(var r=[],i=0,a=this.getAncestors(e);i<a.length;i++){var s=t.get(a[i]);if(s){var p=Array.from(s.values()).filter(function(t){return void 0!==t.propertyName});r.push.apply(r,p)}}return r.concat(n||[])},t.prototype.findMetadata=function(t,e,n){var o=t.get(e);if(o){var r=o.get(n);if(r)return r}for(var i=0,a=this.getAncestors(e);i<a.length;i++){var s=t.get(a[i]);if(s){var p=s.get(n);if(p)return p}}},t.prototype.findMetadatas=function(t,e,n){var o,r=t.get(e);r&&(o=r.get(n));for(var i=[],a=0,s=this.getAncestors(e);a<s.length;a++){var p=t.get(s[a]);p&&p.has(n)&&i.push.apply(i,p.get(n))}return i.slice().reverse().concat((o||[]).slice().reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],n=Object.getPrototypeOf(t.prototype.constructor);void 0!==n.prototype;n=Object.getPrototypeOf(n.prototype.constructor))e.push(n);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}()),r=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,r,i,a,s){var p,c=this;if(void 0===s&&(s=0),Array.isArray(e)||e instanceof Set){var u=i&&this.transformationType===n.PLAIN_TO_CLASS?function(t){var e=new t;return e instanceof Set||"push"in e?e:[]}(i):[];return e.forEach(function(e,o){var i=t?t[o]:void 0;if(c.options.enableCircularCheck&&c.isCircular(e))c.transformationType===n.CLASS_TO_CLASS&&(u instanceof Set?u.add(e):u.push(e));else{var a=void 0;if("function"!=typeof r&&r&&r.options&&r.options.discriminator&&r.options.discriminator.property&&r.options.discriminator.subTypes){if(c.transformationType===n.PLAIN_TO_CLASS){a=r.options.discriminator.subTypes.find(function(t){return t.name===e[r.options.discriminator.property]});var p=r.typeFunction({newObject:u,object:e,property:void 0});a=void 0===a?p:a.value,r.options.keepDiscriminatorProperty||delete e[r.options.discriminator.property]}c.transformationType===n.CLASS_TO_CLASS&&(a=e.constructor),c.transformationType===n.CLASS_TO_PLAIN&&(e[r.options.discriminator.property]=r.options.discriminator.subTypes.find(function(t){return t.value===e.constructor}).name)}else a=r;var f=c.transform(i,e,a,void 0,e instanceof Map,s+1);u instanceof Set?u.add(f):u.push(f)}}),u}if(r!==String||a){if(r!==Number||a){if(r!==Boolean||a){if((r===Date||e instanceof Date)&&!a)return e instanceof Date?new Date(e.valueOf()):null==e?e:new Date(e);if(("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0).Buffer&&(r===Buffer||e instanceof Buffer)&&!a)return null==e?e:Buffer.from(e);if(null===(p=e)||"object"!=typeof p||"function"!=typeof p.then||a){if(a||null===e||"object"!=typeof e||"function"!=typeof e.then){if("object"==typeof e&&null!==e){r||e.constructor===Object||(r=e.constructor),!r&&t&&(r=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var f=this.getKeys(r,e,a),l=t||{};t||this.transformationType!==n.PLAIN_TO_CLASS&&this.transformationType!==n.CLASS_TO_CLASS||(l=a?new Map:r?new r:{});for(var d=function(i){if("__proto__"===i||"constructor"===i)return"continue";var p=i,c=i,u=i;if(!h.options.ignoreDecorators&&r)if(h.transformationType===n.PLAIN_TO_CLASS)(f=o.findExposeMetadataByCustomName(r,i))&&(u=f.propertyName,c=f.propertyName);else if(h.transformationType===n.CLASS_TO_PLAIN||h.transformationType===n.CLASS_TO_CLASS){var f;(f=o.findExposeMetadata(r,i))&&f.options&&f.options.name&&(c=f.options.name)}var d=void 0;d=e instanceof Map?e.get(p):e[p]instanceof Function?e[p]():e[p];var y=void 0,v=d instanceof Map;if(r&&a)y=r;else if(r){var g=o.findTypeMetadata(r,u);if(g){var m=g.typeFunction?g.typeFunction({newObject:l,object:e,property:u}):g.reflectedType;g.options&&g.options.discriminator&&g.options.discriminator.property&&g.options.discriminator.subTypes?e[p]instanceof Array?y=g:(h.transformationType===n.PLAIN_TO_CLASS&&(y=void 0===(y=g.options.discriminator.subTypes.find(function(t){if(d&&d instanceof Object&&g.options.discriminator.property in d)return t.name===d[g.options.discriminator.property]}))?m:y.value,g.options.keepDiscriminatorProperty||d&&d instanceof Object&&g.options.discriminator.property in d&&delete d[g.options.discriminator.property]),h.transformationType===n.CLASS_TO_CLASS&&(y=d.constructor),h.transformationType===n.CLASS_TO_PLAIN&&(d[g.options.discriminator.property]=g.options.discriminator.subTypes.find(function(t){return t.value===d.constructor}).name)):y=m,v=v||g.reflectedType===Map}else if(h.options.targetMaps)h.options.targetMaps.filter(function(t){return t.target===r&&!!t.properties[u]}).forEach(function(t){return y=t.properties[u]});else if(h.options.enableImplicitConversion&&h.transformationType===n.PLAIN_TO_CLASS){var S=Reflect.getMetadata("design:type",r.prototype,u);S&&(y=S)}}var O=Array.isArray(e[p])?h.getReflectedType(r,u):void 0,T=t?t[p]:void 0;if(l.constructor.prototype){var A=Object.getOwnPropertyDescriptor(l.constructor.prototype,c);if((h.transformationType===n.PLAIN_TO_CLASS||h.transformationType===n.CLASS_TO_CLASS)&&(A&&!A.set||l[c]instanceof Function))return"continue"}if(h.options.enableCircularCheck&&h.isCircular(d))h.transformationType===n.CLASS_TO_CLASS&&(void 0!==(M=h.applyCustomTransformations(M=d,r,i,e,h.transformationType))||h.options.exposeUnsetFields)&&(l instanceof Map?l.set(c,M):l[c]=M);else{var _=h.transformationType===n.PLAIN_TO_CLASS?c:i,M=void 0;h.transformationType===n.CLASS_TO_PLAIN?(M=h.applyCustomTransformations(M=e[_],r,_,e,h.transformationType),M=h.transform(T,M=e[_]===M?d:M,y,O,v,s+1)):void 0===d&&h.options.exposeDefaultValues?M=l[c]:(M=h.transform(T,d,y,O,v,s+1),M=h.applyCustomTransformations(M,r,_,e,h.transformationType)),(void 0!==M||h.options.exposeUnsetFields)&&(l instanceof Map?l.set(c,M):l[c]=M)}},h=this,y=0,v=f;y<v.length;y++)d(v[y]);return this.options.enableCircularCheck&&this.recursionStack.delete(e),l}return e}return e}return new Promise(function(t,n){e.then(function(e){return t(c.transform(void 0,e,r,void 0,void 0,s+1))},n)})}return null==e?e:Boolean(e)}return null==e?e:Number(e)}return null==e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,n,r,i){var a=this,s=o.findTransformMetadatas(e,n,this.transformationType);return void 0!==this.options.version&&(s=s.filter(function(t){return!t.options||a.checkVersion(t.options.since,t.options.until)})),(s=s.filter(this.options.groups&&this.options.groups.length?function(t){return!t.options||a.checkGroups(t.options.groups)}:function(t){return!t.options||!t.options.groups||!t.options.groups.length})).forEach(function(e){t=e.transformFn({value:t,key:n,obj:r,type:i,options:a.options})}),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var n=o.findTypeMetadata(t,e);return n?n.reflectedType:void 0}},t.prototype.getKeys=function(t,e,r){var i=this,a=o.getStrategy(t);"none"===a&&(a=this.options.strategy||"exposeAll");var s=[];if(("exposeAll"===a||r)&&(s=e instanceof Map?Array.from(e.keys()):Object.keys(e)),r)return s;if(!this.options.ignoreDecorators&&t){var p=o.getExposedProperties(t,this.transformationType);this.transformationType===n.PLAIN_TO_CLASS&&(p=p.map(function(e){var n=o.findExposeMetadata(t,e);return n&&n.options&&n.options.name?n.options.name:e})),s=this.options.excludeExtraneousValues?p:s.concat(p);var c=o.getExcludedProperties(t,this.transformationType);c.length>0&&(s=s.filter(function(t){return!c.includes(t)})),void 0!==this.options.version&&(s=s.filter(function(e){var n=o.findExposeMetadata(t,e);return!n||!n.options||i.checkVersion(n.options.since,n.options.until)})),s=s.filter(this.options.groups&&this.options.groups.length?function(e){var n=o.findExposeMetadata(t,e);return!n||!n.options||i.checkGroups(n.options.groups)}:function(e){var n=o.findExposeMetadata(t,e);return!(n&&n.options&&n.options.groups&&n.options.groups.length)})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(s=s.filter(function(t){return i.options.excludePrefixes.every(function(e){return t.substr(0,e.length)!==e})})),s.filter(function(t,e,n){return n.indexOf(t)===e})},t.prototype.checkVersion=function(t,e){var n=!0;return n&&t&&(n=this.options.version>=t),n&&e&&(n=this.options.version<e),n},t.prototype.checkGroups=function(t){return!t||this.options.groups.some(function(e){return t.includes(e)})},t}(),i={enableCircularCheck:!1,enableImplicitConversion:!1,excludeExtraneousValues:!1,excludePrefixes:void 0,exposeDefaultValues:!1,exposeUnsetFields:!0,groups:void 0,ignoreDecorators:!1,strategy:void 0,targetMaps:void 0,version:void 0},a=function(){return(a=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},s=new(function(){function t(){}return t.prototype.classToPlain=function(t,e){return new r(n.CLASS_TO_PLAIN,a(a({},i),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,o){return new r(n.CLASS_TO_PLAIN,a(a({},i),o)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToClass=function(t,e,o){return new r(n.PLAIN_TO_CLASS,a(a({},i),o)).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,o){return new r(n.PLAIN_TO_CLASS,a(a({},i),o)).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.classToClass=function(t,e){return new r(n.CLASS_TO_CLASS,a(a({},i),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,o){return new r(n.CLASS_TO_CLASS,a(a({},i),o)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.classToPlain(t,e))},t.prototype.deserialize=function(t,e,n){var o=JSON.parse(e);return this.plainToClass(t,o,n)},t.prototype.deserializeArray=function(t,e,n){var o=JSON.parse(e);return this.plainToClass(t,o,n)},t}()),p=function(t){this.groups=[],this.each=!1,this.context=void 0,this.type=t.type,this.target=t.target,this.propertyName=t.propertyName,this.constraints=t.constraints,this.constraintCls=t.constraintCls,this.validationTypeOptions=t.validationTypeOptions,t.validationOptions&&(this.message=t.validationOptions.message,this.groups=t.validationOptions.groups,this.always=t.validationOptions.always,this.each=t.validationOptions.each,this.context=t.validationOptions.context)},c=function(){function t(){}return t.prototype.transform=function(t){var e=[];return Object.keys(t.properties).forEach(function(n){t.properties[n].forEach(function(o){e.push(new p({type:o.type,target:t.name,propertyName:n,constraints:o.constraints,validationTypeOptions:o.options,validationOptions:{message:o.message,groups:o.groups,always:o.always,each:o.each}}))})}),e},t}();function u(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function f(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var l=function(){function t(){this.validationMetadatas=[],this.constraintMetadatas=[]}return Object.defineProperty(t.prototype,"hasValidationMetaData",{get:function(){return!!this.validationMetadatas.length},enumerable:!1,configurable:!0}),t.prototype.addValidationSchema=function(t){var e=this;(new c).transform(t).forEach(function(t){return e.addValidationMetadata(t)})},t.prototype.addValidationMetadata=function(t){this.validationMetadatas.push(t)},t.prototype.addConstraintMetadata=function(t){this.constraintMetadatas.push(t)},t.prototype.groupByPropertyName=function(t){var e={};return t.forEach(function(t){e[t.propertyName]||(e[t.propertyName]=[]),e[t.propertyName].push(t)}),e},t.prototype.getTargetValidationMetadatas=function(t,e,n,o,r){var i=function(t){return void 0!==t.always?t.always:(!t.groups||!t.groups.length)&&n},a=function(t){return!(!o||r&&r.length||!t.groups||!t.groups.length)},s=this.validationMetadatas.filter(function(n){return(n.target===t||n.target===e)&&(!!i(n)||!a(n)&&(!(r&&r.length>0)||n.groups&&!!n.groups.find(function(t){return-1!==r.indexOf(t)})))}),p=this.validationMetadatas.filter(function(e){return"string"!=typeof e.target&&e.target!==t&&(!(e.target instanceof Function)||t.prototype instanceof e.target)&&(!!i(e)||!a(e)&&(!(r&&r.length>0)||e.groups&&!!e.groups.find(function(t){return-1!==r.indexOf(t)})))}).filter(function(t){return!s.find(function(e){return e.propertyName===t.propertyName&&e.type===t.type})});return s.concat(p)},t.prototype.getTargetValidatorConstraints=function(t){return this.constraintMetadatas.filter(function(e){return e.target===t})},t}(),d=function(){function t(){}return t.prototype.toString=function(t,e,n){var o=this;void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===n&&(n="");var r=t?"":"",i=t?"":"",a=function(t){return" - property "+r+n+t+i+" has failed the following constraints: "+r+Object.keys(o.constraints).join(", ")+i+" \n"};if(e){var s=Number.isInteger(+this.property)?"["+this.property+"]":(n?".":"")+this.property;return this.constraints?a(s):this.children?this.children.map(function(e){return e.toString(t,!0,""+n+s)}).join(""):""}return"An instance of "+r+(this.target?this.target.constructor.name:"an object")+i+" has failed the validation:\n"+(this.constraints?a(this.property):"")+(this.children?this.children.map(function(e){return e.toString(t,!0,o.property)}).join(""):"")},t}(),h=function(){function t(){}return t.isValid=function(t){var e=this;return"isValid"!==t&&"getMessage"!==t&&-1!==Object.keys(this).map(function(t){return e[t]}).indexOf(t)},t.CUSTOM_VALIDATION="customValidation",t.NESTED_VALIDATION="nestedValidation",t.PROMISE_VALIDATION="promiseValidation",t.CONDITIONAL_VALIDATION="conditionalValidation",t.WHITELIST="whitelistValidation",t.IS_DEFINED="isDefined",t}(),y=function(){function t(){}return t.replaceMessageSpecialTokens=function(t,e){var n;return t instanceof Function?n=t(e):"string"==typeof t&&(n=t),n&&e.constraints instanceof Array&&e.constraints.forEach(function(t,e){n=n.replace(new RegExp("\\$constraint"+(e+1),"g"),function(t){return Array.isArray(t)?t.join(", "):""+t}(t))}),n&&null!=e.value&&"string"==typeof e.value&&(n=n.replace(/\$value/g,e.value)),n&&(n=n.replace(/\$property/g,e.property)),n&&(n=n.replace(/\$target/g,e.targetName)),n},t}(),v=function(){function t(t,e){this.validator=t,this.validatorOptions=e,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=function(){var t=u();return t.classValidatorMetadataStorage||(t.classValidatorMetadataStorage=new l),t.classValidatorMetadataStorage}()}return t.prototype.execute=function(t,e,n){var o,r=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(o=this.validatorOptions)||void 0===o?void 0:o.enableDebugMessages)||console.warn("No metadata found. There is more than once class-validator version installed probably. You need to flatten your dependencies.");var i=this.metadataStorage.getTargetValidationMetadatas(t.constructor,e,this.validatorOptions&&this.validatorOptions.always||!1,this.validatorOptions&&this.validatorOptions.strictGroups||!1,this.validatorOptions?this.validatorOptions.groups:void 0),a=this.metadataStorage.groupByPropertyName(i);if(this.validatorOptions&&this.validatorOptions.forbidUnknownValues&&!i.length){var s=new d;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(s.target=t),s.value=void 0,s.property=void 0,s.children=[],s.constraints={unknownValue:"an unknown value was passed to the validate function"},void n.push(s)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(t,a,n),Object.keys(a).forEach(function(e){var o=t[e],i=a[e].filter(function(t){return t.type===h.IS_DEFINED}),s=a[e].filter(function(t){return t.type!==h.IS_DEFINED&&t.type!==h.WHITELIST});o instanceof Promise&&s.find(function(t){return t.type===h.PROMISE_VALIDATION})?r.awaitingPromises.push(o.then(function(o){r.performValidations(t,o,e,i,s,n)})):r.performValidations(t,o,e,i,s,n)})},t.prototype.whitelist=function(t,e,n){var o=this,r=[];Object.keys(t).forEach(function(t){e[t]&&0!==e[t].length||r.push(t)}),r.length>0&&r.forEach(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?function(e){var r,i=o.generateValidationError(t,t[e],e);i.constraints=((r={})[h.WHITELIST]="property "+e+" should not exist",r),i.children=void 0,n.push(i)}:function(e){return delete t[e]})},t.prototype.stripEmptyErrors=function(t){var e=this;return t.filter(function(t){if(t.children&&(t.children=e.stripEmptyErrors(t.children)),0===Object.keys(t.constraints).length){if(0===t.children.length)return!1;delete t.constraints}return!0})},t.prototype.performValidations=function(t,e,n,o,r,i){var a=r.filter(function(t){return t.type===h.CUSTOM_VALIDATION}),s=r.filter(function(t){return t.type===h.NESTED_VALIDATION}),p=r.filter(function(t){return t.type===h.CONDITIONAL_VALIDATION}),c=this.generateValidationError(t,e,n);i.push(c),this.conditionalValidations(t,e,p)&&(this.customValidations(t,e,o,c),this.mapContexts(t,e,o,c),void 0===e&&this.validatorOptions&&!0===this.validatorOptions.skipUndefinedProperties||null===e&&this.validatorOptions&&!0===this.validatorOptions.skipNullProperties||null==e&&this.validatorOptions&&!0===this.validatorOptions.skipMissingProperties||(this.customValidations(t,e,a,c),this.nestedValidations(e,s,c.children),this.mapContexts(t,e,r,c),this.mapContexts(t,e,a,c)))},t.prototype.generateValidationError=function(t,e,n){var o=new d;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(o.target=t),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(o.value=e),o.property=n,o.children=[],o.constraints={},o},t.prototype.conditionalValidations=function(t,e,n){return n.map(function(n){return n.constraints[0](t,e)}).reduce(function(t,e){return t&&e},!0)},t.prototype.customValidations=function(t,e,n,o){var r=this;n.forEach(function(n){r.metadataStorage.getTargetValidatorConstraints(n.constraintCls).forEach(function(i){if(!(i.async&&r.ignoreAsyncValidations||r.validatorOptions&&r.validatorOptions.stopAtFirstError&&Object.keys(o.constraints||{}).length>0)){var a={targetName:t.constructor?t.constructor.name:void 0,property:n.propertyName,object:t,value:e,constraints:n.constraints};if(n.each&&(e instanceof Array||e instanceof Set||e instanceof Map)){var s,p=((s=e)instanceof Map?Array.from(s.values()):Array.isArray(s)?s:Array.from(s)).map(function(t){return i.instance.validate(t,a)});if(p.some(function(t){return f(t)})){var c=p.map(function(t){return f(t)?t:Promise.resolve(t)}),u=Promise.all(c).then(function(a){if(!a.every(function(t){return t})){var s=r.createValidationError(t,e,n,i),p=s[0];o.constraints[p]=s[1],n.context&&(o.contexts||(o.contexts={}),o.contexts[p]=Object.assign(o.contexts[p]||{},n.context))}});r.awaitingPromises.push(u)}else if(!p.every(function(t){return t})){var l=r.createValidationError(t,e,n,i);o.constraints[l[0]]=l[1]}}else{var d=i.instance.validate(e,a);if(f(d)){var h=d.then(function(a){if(!a){var s=r.createValidationError(t,e,n,i),p=s[0];o.constraints[p]=s[1],n.context&&(o.contexts||(o.contexts={}),o.contexts[p]=Object.assign(o.contexts[p]||{},n.context))}});r.awaitingPromises.push(h)}else if(!d){var y=r.createValidationError(t,e,n,i);o.constraints[y[0]]=y[1]}}}})})},t.prototype.nestedValidations=function(t,e,n){var o=this;void 0!==t&&e.forEach(function(r){var i;if(r.type===h.NESTED_VALIDATION||r.type===h.PROMISE_VALIDATION)if(t instanceof Array||t instanceof Set||t instanceof Map)(t instanceof Set?Array.from(t):t).forEach(function(r,i){o.performValidations(t,r,i.toString(),[],e,n)});else if(t instanceof Object)o.execute(t,"string"==typeof r.target?r.target:r.target.name,n);else{var a=new d;a.value=t,a.property=r.propertyName,a.target=r.target;var s=o.createValidationError(r.target,t,r);a.constraints=((i={})[s[0]]=s[1],i),n.push(a)}})},t.prototype.mapContexts=function(t,e,n,o){var r=this;return n.forEach(function(t){if(t.context){var e=void 0;t.type===h.CUSTOM_VALIDATION&&(e=r.metadataStorage.getTargetValidatorConstraints(t.constraintCls)[0]);var n=r.getConstraintType(t,e);o.constraints[n]&&(o.contexts||(o.contexts={}),o.contexts[n]=Object.assign(o.contexts[n]||{},t.context))}})},t.prototype.createValidationError=function(t,e,n,o){var r=t.constructor?t.constructor.name:void 0,i=this.getConstraintType(n,o),a={targetName:r,property:n.propertyName,object:t,value:e,constraints:n.constraints},s=n.message||"";return n.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||o&&o.instance.defaultMessage instanceof Function&&(s=o.instance.defaultMessage(a)),[i,y.replaceMessageSpecialTokens(s,a)]},t.prototype.getConstraintType=function(t,e){return e&&e.name?e.name:t.type},t}(),g=function(){function t(){}return t.prototype.validate=function(t,e,n){return this.coreValidate(t,e,n)},t.prototype.validateOrReject=function(t,e,n){return o=this,i=function(){var o;return function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,function(r){switch(r.label){case 0:return[4,this.coreValidate(t,e,n)];case 1:return(o=r.sent()).length?[2,Promise.reject(o)]:[2]}})},new((r=void 0)||(r=Promise))(function(t,e){function n(t){try{s(i.next(t))}catch(t){e(t)}}function a(t){try{s(i.throw(t))}catch(t){e(t)}}function s(e){var o;e.done?t(e.value):(o=e.value,o instanceof r?o:new r(function(t){t(o)})).then(n,a)}s((i=i.apply(o,[])).next())});var o,r,i},t.prototype.validateSync=function(t,e,n){var o="string"==typeof t?e:t,r="string"==typeof t?t:void 0,i=new v(this,"string"==typeof t?n:e);i.ignoreAsyncValidations=!0;var a=[];return i.execute(o,r,a),i.stripEmptyErrors(a)},t.prototype.coreValidate=function(t,e,n){var o="string"==typeof t?e:t,r="string"==typeof t?t:void 0,i=new v(this,"string"==typeof t?n:e),a=[];return i.execute(o,r,a),Promise.all(i.awaitingPromises).then(function(){return i.stripEmptyErrors(a)})},t}(),m=new(function(){function t(){this.instances=[]}return t.prototype.get=function(t){var e=this.instances.find(function(e){return e.type===t});return e||(e={type:t,object:new t},this.instances.push(e)),e.object},t}());function S(t){return m.get(t)}var O=function(t){return t.reduce(function(t,n){var o;return e({},t,((o={})[n[0]]=n[1],o))},{})},T=function t(e){var n,o,r;return e.children&&e.children.length>0?O(e.children.map(function(e){return[e.property,t(e)]})):{message:null==(n=Object.entries(null!=(r=e.constraints)?r:{}))||null==(o=n[0])?void 0:o[1]}},A=function(e,n,o){return void 0===n&&(n={}),void 0===o&&(o={}),function(r,i,a){try{var p=function(e){return 0===e.length?{values:r,errors:{}}:{values:{},errors:t(function(t){var e=O(t.map(function(t){return[t.property,T(t)]}));return t.length>0?e:{}}(e),a.fields)}},c=s.plainToClass(e,r,void 0);return Promise.resolve("sync"===o.mode?p((f=n,"string"==typeof(u=c)?S(g).validateSync(u,f,void 0):S(g).validateSync(u,f))):Promise.resolve(function(t,e,n){return"string"==typeof t?S(g).validate(t,e,void 0):S(g).validate(t,e)}(c,n)).then(p))}catch(t){return Promise.reject(t)}var u,f}};export{A as classValidatorResolver};
import{toNestError as r}from"@hookform/resolvers";import{plainToClass as e}from"class-transformer";import{validateSync as t,validate as o}from"class-validator";var n=function r(e,t,o,n){return void 0===o&&(o={}),void 0===n&&(n=""),e.reduce(function(e,o){var s=n?n+"."+o.property:o.property;if(o.constraints){var i=Object.keys(o.constraints)[0];e[s]={type:i,message:o.constraints[i]},t&&e[s]&&Object.assign(e[s],{types:o.constraints})}return o.children&&o.children.length&&r(o.children,t,e,s),e},o)},s=function(s,i,c){return void 0===i&&(i={}),void 0===c&&(c={}),function(a,l,u){try{var v=e(s,a);return Promise.resolve(("sync"===c.mode?t:o)(v,i)).then(function(e){return e.length?{values:{},errors:r(n(e,"all"===u.criteriaMode),u.fields)}:{values:a,errors:{}}})}catch(r){return Promise.reject(r)}}};export{s as classValidatorResolver};
//# sourceMappingURL=class-validator.module.js.map

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@hookform/resolvers")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers"],e):e((t||self).hookformResolversClassValidator={},t.hookformResolvers)}(this,function(t,e){function n(){return(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}var o;!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(o||(o={}));var r=new(function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,n){return this.findMetadatas(this._transformMetadatas,t,e).filter(function(t){return!t.options||!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?n===o.CLASS_TO_CLASS||n===o.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||n===o.CLASS_TO_PLAIN)})},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find(function(t){return t.options&&t.options.name===e})},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),n=e&&e.get(void 0),o=this._exposeMetadatas.get(t),r=o&&o.get(void 0);return n&&r||!n&&!r?"none":n?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter(function(t){return!t.options||!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===o.CLASS_TO_CLASS||e===o.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===o.CLASS_TO_PLAIN)}).map(function(t){return t.propertyName})},t.prototype.getExcludedProperties=function(t,e){return this.getExcludedMetadatas(t).filter(function(t){return!t.options||!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===o.CLASS_TO_CLASS||e===o.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===o.CLASS_TO_PLAIN)}).map(function(t){return t.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var n,o=t.get(e);o&&(n=Array.from(o.values()).filter(function(t){return void 0!==t.propertyName}));for(var r=[],i=0,a=this.getAncestors(e);i<a.length;i++){var s=t.get(a[i]);if(s){var p=Array.from(s.values()).filter(function(t){return void 0!==t.propertyName});r.push.apply(r,p)}}return r.concat(n||[])},t.prototype.findMetadata=function(t,e,n){var o=t.get(e);if(o){var r=o.get(n);if(r)return r}for(var i=0,a=this.getAncestors(e);i<a.length;i++){var s=t.get(a[i]);if(s){var p=s.get(n);if(p)return p}}},t.prototype.findMetadatas=function(t,e,n){var o,r=t.get(e);r&&(o=r.get(n));for(var i=[],a=0,s=this.getAncestors(e);a<s.length;a++){var p=t.get(s[a]);p&&p.has(n)&&i.push.apply(i,p.get(n))}return i.slice().reverse().concat((o||[]).slice().reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],n=Object.getPrototypeOf(t.prototype.constructor);void 0!==n.prototype;n=Object.getPrototypeOf(n.prototype.constructor))e.push(n);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}()),i=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,n,i,a,s){var p,c=this;if(void 0===s&&(s=0),Array.isArray(e)||e instanceof Set){var u=i&&this.transformationType===o.PLAIN_TO_CLASS?function(t){var e=new t;return e instanceof Set||"push"in e?e:[]}(i):[];return e.forEach(function(e,r){var i=t?t[r]:void 0;if(c.options.enableCircularCheck&&c.isCircular(e))c.transformationType===o.CLASS_TO_CLASS&&(u instanceof Set?u.add(e):u.push(e));else{var a=void 0;if("function"!=typeof n&&n&&n.options&&n.options.discriminator&&n.options.discriminator.property&&n.options.discriminator.subTypes){if(c.transformationType===o.PLAIN_TO_CLASS){a=n.options.discriminator.subTypes.find(function(t){return t.name===e[n.options.discriminator.property]});var p=n.typeFunction({newObject:u,object:e,property:void 0});a=void 0===a?p:a.value,n.options.keepDiscriminatorProperty||delete e[n.options.discriminator.property]}c.transformationType===o.CLASS_TO_CLASS&&(a=e.constructor),c.transformationType===o.CLASS_TO_PLAIN&&(e[n.options.discriminator.property]=n.options.discriminator.subTypes.find(function(t){return t.value===e.constructor}).name)}else a=n;var f=c.transform(i,e,a,void 0,e instanceof Map,s+1);u instanceof Set?u.add(f):u.push(f)}}),u}if(n!==String||a){if(n!==Number||a){if(n!==Boolean||a){if((n===Date||e instanceof Date)&&!a)return e instanceof Date?new Date(e.valueOf()):null==e?e:new Date(e);if(("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0).Buffer&&(n===Buffer||e instanceof Buffer)&&!a)return null==e?e:Buffer.from(e);if(null===(p=e)||"object"!=typeof p||"function"!=typeof p.then||a){if(a||null===e||"object"!=typeof e||"function"!=typeof e.then){if("object"==typeof e&&null!==e){n||e.constructor===Object||(n=e.constructor),!n&&t&&(n=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var f=this.getKeys(n,e,a),l=t||{};t||this.transformationType!==o.PLAIN_TO_CLASS&&this.transformationType!==o.CLASS_TO_CLASS||(l=a?new Map:n?new n:{});for(var d=function(i){if("__proto__"===i||"constructor"===i)return"continue";var p=i,c=i,u=i;if(!h.options.ignoreDecorators&&n)if(h.transformationType===o.PLAIN_TO_CLASS)(f=r.findExposeMetadataByCustomName(n,i))&&(u=f.propertyName,c=f.propertyName);else if(h.transformationType===o.CLASS_TO_PLAIN||h.transformationType===o.CLASS_TO_CLASS){var f;(f=r.findExposeMetadata(n,i))&&f.options&&f.options.name&&(c=f.options.name)}var d=void 0;d=e instanceof Map?e.get(p):e[p]instanceof Function?e[p]():e[p];var y=void 0,v=d instanceof Map;if(n&&a)y=n;else if(n){var g=r.findTypeMetadata(n,u);if(g){var m=g.typeFunction?g.typeFunction({newObject:l,object:e,property:u}):g.reflectedType;g.options&&g.options.discriminator&&g.options.discriminator.property&&g.options.discriminator.subTypes?e[p]instanceof Array?y=g:(h.transformationType===o.PLAIN_TO_CLASS&&(y=void 0===(y=g.options.discriminator.subTypes.find(function(t){if(d&&d instanceof Object&&g.options.discriminator.property in d)return t.name===d[g.options.discriminator.property]}))?m:y.value,g.options.keepDiscriminatorProperty||d&&d instanceof Object&&g.options.discriminator.property in d&&delete d[g.options.discriminator.property]),h.transformationType===o.CLASS_TO_CLASS&&(y=d.constructor),h.transformationType===o.CLASS_TO_PLAIN&&(d[g.options.discriminator.property]=g.options.discriminator.subTypes.find(function(t){return t.value===d.constructor}).name)):y=m,v=v||g.reflectedType===Map}else if(h.options.targetMaps)h.options.targetMaps.filter(function(t){return t.target===n&&!!t.properties[u]}).forEach(function(t){return y=t.properties[u]});else if(h.options.enableImplicitConversion&&h.transformationType===o.PLAIN_TO_CLASS){var S=Reflect.getMetadata("design:type",n.prototype,u);S&&(y=S)}}var O=Array.isArray(e[p])?h.getReflectedType(n,u):void 0,T=t?t[p]:void 0;if(l.constructor.prototype){var A=Object.getOwnPropertyDescriptor(l.constructor.prototype,c);if((h.transformationType===o.PLAIN_TO_CLASS||h.transformationType===o.CLASS_TO_CLASS)&&(A&&!A.set||l[c]instanceof Function))return"continue"}if(h.options.enableCircularCheck&&h.isCircular(d))h.transformationType===o.CLASS_TO_CLASS&&(void 0!==(M=h.applyCustomTransformations(M=d,n,i,e,h.transformationType))||h.options.exposeUnsetFields)&&(l instanceof Map?l.set(c,M):l[c]=M);else{var _=h.transformationType===o.PLAIN_TO_CLASS?c:i,M=void 0;h.transformationType===o.CLASS_TO_PLAIN?(M=h.applyCustomTransformations(M=e[_],n,_,e,h.transformationType),M=h.transform(T,M=e[_]===M?d:M,y,O,v,s+1)):void 0===d&&h.options.exposeDefaultValues?M=l[c]:(M=h.transform(T,d,y,O,v,s+1),M=h.applyCustomTransformations(M,n,_,e,h.transformationType)),(void 0!==M||h.options.exposeUnsetFields)&&(l instanceof Map?l.set(c,M):l[c]=M)}},h=this,y=0,v=f;y<v.length;y++)d(v[y]);return this.options.enableCircularCheck&&this.recursionStack.delete(e),l}return e}return e}return new Promise(function(t,o){e.then(function(e){return t(c.transform(void 0,e,n,void 0,void 0,s+1))},o)})}return null==e?e:Boolean(e)}return null==e?e:Number(e)}return null==e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,n,o,i){var a=this,s=r.findTransformMetadatas(e,n,this.transformationType);return void 0!==this.options.version&&(s=s.filter(function(t){return!t.options||a.checkVersion(t.options.since,t.options.until)})),(s=s.filter(this.options.groups&&this.options.groups.length?function(t){return!t.options||a.checkGroups(t.options.groups)}:function(t){return!t.options||!t.options.groups||!t.options.groups.length})).forEach(function(e){t=e.transformFn({value:t,key:n,obj:o,type:i,options:a.options})}),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var n=r.findTypeMetadata(t,e);return n?n.reflectedType:void 0}},t.prototype.getKeys=function(t,e,n){var i=this,a=r.getStrategy(t);"none"===a&&(a=this.options.strategy||"exposeAll");var s=[];if(("exposeAll"===a||n)&&(s=e instanceof Map?Array.from(e.keys()):Object.keys(e)),n)return s;if(!this.options.ignoreDecorators&&t){var p=r.getExposedProperties(t,this.transformationType);this.transformationType===o.PLAIN_TO_CLASS&&(p=p.map(function(e){var n=r.findExposeMetadata(t,e);return n&&n.options&&n.options.name?n.options.name:e})),s=this.options.excludeExtraneousValues?p:s.concat(p);var c=r.getExcludedProperties(t,this.transformationType);c.length>0&&(s=s.filter(function(t){return!c.includes(t)})),void 0!==this.options.version&&(s=s.filter(function(e){var n=r.findExposeMetadata(t,e);return!n||!n.options||i.checkVersion(n.options.since,n.options.until)})),s=s.filter(this.options.groups&&this.options.groups.length?function(e){var n=r.findExposeMetadata(t,e);return!n||!n.options||i.checkGroups(n.options.groups)}:function(e){var n=r.findExposeMetadata(t,e);return!(n&&n.options&&n.options.groups&&n.options.groups.length)})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(s=s.filter(function(t){return i.options.excludePrefixes.every(function(e){return t.substr(0,e.length)!==e})})),s.filter(function(t,e,n){return n.indexOf(t)===e})},t.prototype.checkVersion=function(t,e){var n=!0;return n&&t&&(n=this.options.version>=t),n&&e&&(n=this.options.version<e),n},t.prototype.checkGroups=function(t){return!t||this.options.groups.some(function(e){return t.includes(e)})},t}(),a={enableCircularCheck:!1,enableImplicitConversion:!1,excludeExtraneousValues:!1,excludePrefixes:void 0,exposeDefaultValues:!1,exposeUnsetFields:!0,groups:void 0,ignoreDecorators:!1,strategy:void 0,targetMaps:void 0,version:void 0},s=function(){return(s=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},p=new(function(){function t(){}return t.prototype.classToPlain=function(t,e){return new i(o.CLASS_TO_PLAIN,s(s({},a),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,n){return new i(o.CLASS_TO_PLAIN,s(s({},a),n)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToClass=function(t,e,n){return new i(o.PLAIN_TO_CLASS,s(s({},a),n)).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,n){return new i(o.PLAIN_TO_CLASS,s(s({},a),n)).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.classToClass=function(t,e){return new i(o.CLASS_TO_CLASS,s(s({},a),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,n){return new i(o.CLASS_TO_CLASS,s(s({},a),n)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.classToPlain(t,e))},t.prototype.deserialize=function(t,e,n){var o=JSON.parse(e);return this.plainToClass(t,o,n)},t.prototype.deserializeArray=function(t,e,n){var o=JSON.parse(e);return this.plainToClass(t,o,n)},t}()),c=function(t){this.groups=[],this.each=!1,this.context=void 0,this.type=t.type,this.target=t.target,this.propertyName=t.propertyName,this.constraints=t.constraints,this.constraintCls=t.constraintCls,this.validationTypeOptions=t.validationTypeOptions,t.validationOptions&&(this.message=t.validationOptions.message,this.groups=t.validationOptions.groups,this.always=t.validationOptions.always,this.each=t.validationOptions.each,this.context=t.validationOptions.context)},u=function(){function t(){}return t.prototype.transform=function(t){var e=[];return Object.keys(t.properties).forEach(function(n){t.properties[n].forEach(function(o){e.push(new c({type:o.type,target:t.name,propertyName:n,constraints:o.constraints,validationTypeOptions:o.options,validationOptions:{message:o.message,groups:o.groups,always:o.always,each:o.each}}))})}),e},t}();function f(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function l(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var d=function(){function t(){this.validationMetadatas=[],this.constraintMetadatas=[]}return Object.defineProperty(t.prototype,"hasValidationMetaData",{get:function(){return!!this.validationMetadatas.length},enumerable:!1,configurable:!0}),t.prototype.addValidationSchema=function(t){var e=this;(new u).transform(t).forEach(function(t){return e.addValidationMetadata(t)})},t.prototype.addValidationMetadata=function(t){this.validationMetadatas.push(t)},t.prototype.addConstraintMetadata=function(t){this.constraintMetadatas.push(t)},t.prototype.groupByPropertyName=function(t){var e={};return t.forEach(function(t){e[t.propertyName]||(e[t.propertyName]=[]),e[t.propertyName].push(t)}),e},t.prototype.getTargetValidationMetadatas=function(t,e,n,o,r){var i=function(t){return void 0!==t.always?t.always:(!t.groups||!t.groups.length)&&n},a=function(t){return!(!o||r&&r.length||!t.groups||!t.groups.length)},s=this.validationMetadatas.filter(function(n){return(n.target===t||n.target===e)&&(!!i(n)||!a(n)&&(!(r&&r.length>0)||n.groups&&!!n.groups.find(function(t){return-1!==r.indexOf(t)})))}),p=this.validationMetadatas.filter(function(e){return"string"!=typeof e.target&&e.target!==t&&(!(e.target instanceof Function)||t.prototype instanceof e.target)&&(!!i(e)||!a(e)&&(!(r&&r.length>0)||e.groups&&!!e.groups.find(function(t){return-1!==r.indexOf(t)})))}).filter(function(t){return!s.find(function(e){return e.propertyName===t.propertyName&&e.type===t.type})});return s.concat(p)},t.prototype.getTargetValidatorConstraints=function(t){return this.constraintMetadatas.filter(function(e){return e.target===t})},t}(),h=function(){function t(){}return t.prototype.toString=function(t,e,n){var o=this;void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===n&&(n="");var r=t?"":"",i=t?"":"",a=function(t){return" - property "+r+n+t+i+" has failed the following constraints: "+r+Object.keys(o.constraints).join(", ")+i+" \n"};if(e){var s=Number.isInteger(+this.property)?"["+this.property+"]":(n?".":"")+this.property;return this.constraints?a(s):this.children?this.children.map(function(e){return e.toString(t,!0,""+n+s)}).join(""):""}return"An instance of "+r+(this.target?this.target.constructor.name:"an object")+i+" has failed the validation:\n"+(this.constraints?a(this.property):"")+(this.children?this.children.map(function(e){return e.toString(t,!0,o.property)}).join(""):"")},t}(),y=function(){function t(){}return t.isValid=function(t){var e=this;return"isValid"!==t&&"getMessage"!==t&&-1!==Object.keys(this).map(function(t){return e[t]}).indexOf(t)},t.CUSTOM_VALIDATION="customValidation",t.NESTED_VALIDATION="nestedValidation",t.PROMISE_VALIDATION="promiseValidation",t.CONDITIONAL_VALIDATION="conditionalValidation",t.WHITELIST="whitelistValidation",t.IS_DEFINED="isDefined",t}(),v=function(){function t(){}return t.replaceMessageSpecialTokens=function(t,e){var n;return t instanceof Function?n=t(e):"string"==typeof t&&(n=t),n&&e.constraints instanceof Array&&e.constraints.forEach(function(t,e){n=n.replace(new RegExp("\\$constraint"+(e+1),"g"),function(t){return Array.isArray(t)?t.join(", "):""+t}(t))}),n&&null!=e.value&&"string"==typeof e.value&&(n=n.replace(/\$value/g,e.value)),n&&(n=n.replace(/\$property/g,e.property)),n&&(n=n.replace(/\$target/g,e.targetName)),n},t}(),g=function(){function t(t,e){this.validator=t,this.validatorOptions=e,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=function(){var t=f();return t.classValidatorMetadataStorage||(t.classValidatorMetadataStorage=new d),t.classValidatorMetadataStorage}()}return t.prototype.execute=function(t,e,n){var o,r=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(o=this.validatorOptions)||void 0===o?void 0:o.enableDebugMessages)||console.warn("No metadata found. There is more than once class-validator version installed probably. You need to flatten your dependencies.");var i=this.metadataStorage.getTargetValidationMetadatas(t.constructor,e,this.validatorOptions&&this.validatorOptions.always||!1,this.validatorOptions&&this.validatorOptions.strictGroups||!1,this.validatorOptions?this.validatorOptions.groups:void 0),a=this.metadataStorage.groupByPropertyName(i);if(this.validatorOptions&&this.validatorOptions.forbidUnknownValues&&!i.length){var s=new h;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(s.target=t),s.value=void 0,s.property=void 0,s.children=[],s.constraints={unknownValue:"an unknown value was passed to the validate function"},void n.push(s)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(t,a,n),Object.keys(a).forEach(function(e){var o=t[e],i=a[e].filter(function(t){return t.type===y.IS_DEFINED}),s=a[e].filter(function(t){return t.type!==y.IS_DEFINED&&t.type!==y.WHITELIST});o instanceof Promise&&s.find(function(t){return t.type===y.PROMISE_VALIDATION})?r.awaitingPromises.push(o.then(function(o){r.performValidations(t,o,e,i,s,n)})):r.performValidations(t,o,e,i,s,n)})},t.prototype.whitelist=function(t,e,n){var o=this,r=[];Object.keys(t).forEach(function(t){e[t]&&0!==e[t].length||r.push(t)}),r.length>0&&r.forEach(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?function(e){var r,i=o.generateValidationError(t,t[e],e);i.constraints=((r={})[y.WHITELIST]="property "+e+" should not exist",r),i.children=void 0,n.push(i)}:function(e){return delete t[e]})},t.prototype.stripEmptyErrors=function(t){var e=this;return t.filter(function(t){if(t.children&&(t.children=e.stripEmptyErrors(t.children)),0===Object.keys(t.constraints).length){if(0===t.children.length)return!1;delete t.constraints}return!0})},t.prototype.performValidations=function(t,e,n,o,r,i){var a=r.filter(function(t){return t.type===y.CUSTOM_VALIDATION}),s=r.filter(function(t){return t.type===y.NESTED_VALIDATION}),p=r.filter(function(t){return t.type===y.CONDITIONAL_VALIDATION}),c=this.generateValidationError(t,e,n);i.push(c),this.conditionalValidations(t,e,p)&&(this.customValidations(t,e,o,c),this.mapContexts(t,e,o,c),void 0===e&&this.validatorOptions&&!0===this.validatorOptions.skipUndefinedProperties||null===e&&this.validatorOptions&&!0===this.validatorOptions.skipNullProperties||null==e&&this.validatorOptions&&!0===this.validatorOptions.skipMissingProperties||(this.customValidations(t,e,a,c),this.nestedValidations(e,s,c.children),this.mapContexts(t,e,r,c),this.mapContexts(t,e,a,c)))},t.prototype.generateValidationError=function(t,e,n){var o=new h;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(o.target=t),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(o.value=e),o.property=n,o.children=[],o.constraints={},o},t.prototype.conditionalValidations=function(t,e,n){return n.map(function(n){return n.constraints[0](t,e)}).reduce(function(t,e){return t&&e},!0)},t.prototype.customValidations=function(t,e,n,o){var r=this;n.forEach(function(n){r.metadataStorage.getTargetValidatorConstraints(n.constraintCls).forEach(function(i){if(!(i.async&&r.ignoreAsyncValidations||r.validatorOptions&&r.validatorOptions.stopAtFirstError&&Object.keys(o.constraints||{}).length>0)){var a={targetName:t.constructor?t.constructor.name:void 0,property:n.propertyName,object:t,value:e,constraints:n.constraints};if(n.each&&(e instanceof Array||e instanceof Set||e instanceof Map)){var s,p=((s=e)instanceof Map?Array.from(s.values()):Array.isArray(s)?s:Array.from(s)).map(function(t){return i.instance.validate(t,a)});if(p.some(function(t){return l(t)})){var c=p.map(function(t){return l(t)?t:Promise.resolve(t)}),u=Promise.all(c).then(function(a){if(!a.every(function(t){return t})){var s=r.createValidationError(t,e,n,i),p=s[0];o.constraints[p]=s[1],n.context&&(o.contexts||(o.contexts={}),o.contexts[p]=Object.assign(o.contexts[p]||{},n.context))}});r.awaitingPromises.push(u)}else if(!p.every(function(t){return t})){var f=r.createValidationError(t,e,n,i);o.constraints[f[0]]=f[1]}}else{var d=i.instance.validate(e,a);if(l(d)){var h=d.then(function(a){if(!a){var s=r.createValidationError(t,e,n,i),p=s[0];o.constraints[p]=s[1],n.context&&(o.contexts||(o.contexts={}),o.contexts[p]=Object.assign(o.contexts[p]||{},n.context))}});r.awaitingPromises.push(h)}else if(!d){var y=r.createValidationError(t,e,n,i);o.constraints[y[0]]=y[1]}}}})})},t.prototype.nestedValidations=function(t,e,n){var o=this;void 0!==t&&e.forEach(function(r){var i;if(r.type===y.NESTED_VALIDATION||r.type===y.PROMISE_VALIDATION)if(t instanceof Array||t instanceof Set||t instanceof Map)(t instanceof Set?Array.from(t):t).forEach(function(r,i){o.performValidations(t,r,i.toString(),[],e,n)});else if(t instanceof Object)o.execute(t,"string"==typeof r.target?r.target:r.target.name,n);else{var a=new h;a.value=t,a.property=r.propertyName,a.target=r.target;var s=o.createValidationError(r.target,t,r);a.constraints=((i={})[s[0]]=s[1],i),n.push(a)}})},t.prototype.mapContexts=function(t,e,n,o){var r=this;return n.forEach(function(t){if(t.context){var e=void 0;t.type===y.CUSTOM_VALIDATION&&(e=r.metadataStorage.getTargetValidatorConstraints(t.constraintCls)[0]);var n=r.getConstraintType(t,e);o.constraints[n]&&(o.contexts||(o.contexts={}),o.contexts[n]=Object.assign(o.contexts[n]||{},t.context))}})},t.prototype.createValidationError=function(t,e,n,o){var r=t.constructor?t.constructor.name:void 0,i=this.getConstraintType(n,o),a={targetName:r,property:n.propertyName,object:t,value:e,constraints:n.constraints},s=n.message||"";return n.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||o&&o.instance.defaultMessage instanceof Function&&(s=o.instance.defaultMessage(a)),[i,v.replaceMessageSpecialTokens(s,a)]},t.prototype.getConstraintType=function(t,e){return e&&e.name?e.name:t.type},t}(),m=function(){function t(){}return t.prototype.validate=function(t,e,n){return this.coreValidate(t,e,n)},t.prototype.validateOrReject=function(t,e,n){return o=this,i=function(){var o;return function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,function(r){switch(r.label){case 0:return[4,this.coreValidate(t,e,n)];case 1:return(o=r.sent()).length?[2,Promise.reject(o)]:[2]}})},new((r=void 0)||(r=Promise))(function(t,e){function n(t){try{s(i.next(t))}catch(t){e(t)}}function a(t){try{s(i.throw(t))}catch(t){e(t)}}function s(e){var o;e.done?t(e.value):(o=e.value,o instanceof r?o:new r(function(t){t(o)})).then(n,a)}s((i=i.apply(o,[])).next())});var o,r,i},t.prototype.validateSync=function(t,e,n){var o="string"==typeof t?e:t,r="string"==typeof t?t:void 0,i=new g(this,"string"==typeof t?n:e);i.ignoreAsyncValidations=!0;var a=[];return i.execute(o,r,a),i.stripEmptyErrors(a)},t.prototype.coreValidate=function(t,e,n){var o="string"==typeof t?e:t,r="string"==typeof t?t:void 0,i=new g(this,"string"==typeof t?n:e),a=[];return i.execute(o,r,a),Promise.all(i.awaitingPromises).then(function(){return i.stripEmptyErrors(a)})},t}(),S=new(function(){function t(){this.instances=[]}return t.prototype.get=function(t){var e=this.instances.find(function(e){return e.type===t});return e||(e={type:t,object:new t},this.instances.push(e)),e.object},t}());function O(t){return S.get(t)}var T=function(t){return t.reduce(function(t,e){var o;return n({},t,((o={})[e[0]]=e[1],o))},{})},A=function t(e){var n,o,r;return e.children&&e.children.length>0?T(e.children.map(function(e){return[e.property,t(e)]})):{message:null==(n=Object.entries(null!=(r=e.constraints)?r:{}))||null==(o=n[0])?void 0:o[1]}};t.classValidatorResolver=function(t,n,o){return void 0===n&&(n={}),void 0===o&&(o={}),function(r,i,a){try{var s=function(t){return 0===t.length?{values:r,errors:{}}:{values:{},errors:e.toNestError(function(t){var e=T(t.map(function(t){return[t.property,A(t)]}));return t.length>0?e:{}}(t),a.fields)}},c=p.plainToClass(t,r,void 0);return Promise.resolve("sync"===o.mode?s((f=n,"string"==typeof(u=c)?O(m).validateSync(u,f,void 0):O(m).validateSync(u,f))):Promise.resolve(function(t,e,n){return"string"==typeof t?O(m).validate(t,e,void 0):O(m).validate(t,e)}(c,n)).then(s))}catch(t){return Promise.reject(t)}var u,f}}});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@hookform/resolvers"),require("class-transformer"),require("class-validator")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","class-transformer","class-validator"],r):r((e||self).hookformResolversClassValidator={},e.hookformResolvers,e.classTransformer,e.classValidator)}(this,function(e,r,o,s){var t=function e(r,o,s,t){return void 0===s&&(s={}),void 0===t&&(t=""),r.reduce(function(r,s){var n=t?t+"."+s.property:s.property;if(s.constraints){var a=Object.keys(s.constraints)[0];r[n]={type:a,message:s.constraints[a]},o&&r[n]&&Object.assign(r[n],{types:s.constraints})}return s.children&&s.children.length&&e(s.children,o,r,n),r},s)};e.classValidatorResolver=function(e,n,a){return void 0===n&&(n={}),void 0===a&&(a={}),function(i,l,c){try{var d=o.plainToClass(e,i);return Promise.resolve(("sync"===a.mode?s.validateSync:s.validate)(d,n)).then(function(e){return e.length?{values:{},errors:r.toNestError(t(e,"all"===c.criteriaMode),c.fields)}:{values:i,errors:{}}})}catch(e){return Promise.reject(e)}}}});
//# sourceMappingURL=class-validator.umd.js.map

@@ -15,4 +15,6 @@ {

"react-hook-form": ">=6.6.0",
"@hookform/resolvers": ">=2.0.0"
"@hookform/resolvers": ">=2.0.0",
"class-transformer": "^0.4.0",
"class-validator": "^0.12.0"
}
}

@@ -57,2 +57,26 @@ /* eslint-disable no-console, @typescript-eslint/ban-ts-comment */

});
it('should return all the errors from classValidatorResolver when validation fails with `validateAllFieldCriteria` set to true', async () => {
const result = await classValidatorResolver(Schema)(
invalidData,
undefined,
{
fields,
criteriaMode: 'all',
},
);
expect(result).toMatchSnapshot();
});
it('should return all the errors from classValidatorResolver when validation fails with `validateAllFieldCriteria` set to true and `mode: sync`', async () => {
const result = await classValidatorResolver(Schema, undefined, {
mode: 'sync',
})(invalidData, undefined, {
fields,
criteriaMode: 'all',
});
expect(result).toMatchSnapshot();
});
});

@@ -1,33 +0,34 @@

import type { Resolver } from './types';
import { FieldErrors } from 'react-hook-form';
import { toNestError } from '@hookform/resolvers';
import { plainToClass } from 'class-transformer';
import { validate, validateSync, ValidationError } from 'class-validator';
import { toNestError } from '@hookform/resolvers';
import type { Resolver } from './types';
const fromEntries = (entries: [any, any][]) => {
return entries.reduce((prev, [k, v]) => ({ ...prev, [k]: v }), {});
};
const parseErrors = (
errors: ValidationError[],
validateAllFieldCriteria: boolean,
parsedErrors: FieldErrors = {},
path = '',
) => {
return errors.reduce((acc, error) => {
const _path = path ? `${path}.${error.property}` : error.property;
const getErrorMessages = (rawError: ValidationError): any => {
const res =
rawError.children && rawError.children.length > 0
? fromEntries(
rawError.children.map((child) => {
return [child.property, getErrorMessages(child)];
}),
)
: {
message: Object.entries(rawError.constraints ?? {})?.[0]?.[1],
};
if (error.constraints) {
const key = Object.keys(error.constraints)[0];
acc[_path] = {
type: key,
message: error.constraints[key],
};
return res;
};
if (validateAllFieldCriteria && acc[_path]) {
Object.assign(acc[_path], { types: error.constraints });
}
}
const parseErrors = (rawErrors: ValidationError[]) => {
const errors = fromEntries(
rawErrors.map((rawError) => [
rawError.property,
getErrorMessages(rawError),
]),
);
return rawErrors.length > 0 ? errors : {};
if (error.children && error.children.length) {
parseErrors(error.children, validateAllFieldCriteria, acc, _path);
}
return acc;
}, parsedErrors);
};

@@ -41,11 +42,16 @@

const user = plainToClass(schema, values);
const rawErrors =
resolverOptions.mode === 'sync'
? validateSync(user, schemaOptions)
: await validate(user, schemaOptions);
if (rawErrors.length === 0) {
return { values, errors: {} };
}
const errors = toNestError(parseErrors(rawErrors), options.fields);
return { values: {}, errors };
const rawErrors = await (resolverOptions.mode === 'sync'
? validateSync
: validate)(user, schemaOptions);
return rawErrors.length
? {
values: {},
errors: toNestError(
parseErrors(rawErrors, options.criteriaMode === 'all'),
options.fields,
),
}
: { values, errors: {} };
};
{
"name": "@hookform/resolvers",
"amdName": "hookformResolvers",
"version": "2.1.0",
"version": "2.2.0",
"description": "React Hook Form validation resolvers: Yup, Joi, Superstruct, Zod, Vest, Class Validator and etc.",

@@ -6,0 +6,0 @@ "main": "dist/resolvers.js",

@@ -278,19 +278,14 @@ <div align="center">

return (
<div style={{ display: 'grid', placeContent: 'center', height: '90vh' }}>
<form
onSubmit={handleSubmit((data) => console.log(data))}
style={{ display: 'flex', flexDirection: 'column', rowGap: 4 }}
>
<input type="text" {...register('username')} />
{errors.username && <span>{errors.username.message}</span>}
<form onSubmit={handleSubmit((data) => console.log(data))}>
<input type="text" {...register('username')} />
{errors.username && <span>{errors.username.message}</span>}
<input type="text" {...register('email')} />
{errors.email && <span>{errors.email.message}</span>}
<input type="text" {...register('email')} />
{errors.email && <span>{errors.email.message}</span>}
<input type="number" {...register('age', { valueAsNumber: true })} />
{errors.age && <span>{errors.age.message}</span>}
<input type="number" {...register('age', { valueAsNumber: true })} />
{errors.age && <span>{errors.age.message}</span>}
<input type="submit" value="Submit" />
</form>
</div>
<input type="submit" value="Submit" />
</form>
);

@@ -297,0 +292,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc