@decaf-ts/decorator-validation 1.11.11 → 1.11.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +1 -1
  2. package/dist/decorator-validation.cjs +1 -1
  3. package/dist/decorator-validation.cjs.map +1 -1
  4. package/dist/decorator-validation.js +1 -1
  5. package/dist/decorator-validation.js.map +1 -1
  6. package/lib/esm/index.d.ts +1 -1
  7. package/lib/esm/index.js +1 -1
  8. package/lib/esm/model/Model.d.ts +0 -103
  9. package/lib/esm/model/Model.js +11 -250
  10. package/lib/esm/model/Model.js.map +1 -1
  11. package/lib/esm/model/ModelRegistry.d.ts +181 -0
  12. package/lib/esm/model/ModelRegistry.js +291 -0
  13. package/lib/esm/model/ModelRegistry.js.map +1 -0
  14. package/lib/esm/model/index.d.ts +1 -0
  15. package/lib/esm/model/index.js +1 -0
  16. package/lib/esm/model/index.js.map +1 -1
  17. package/lib/esm/model/validation.d.ts +1 -1
  18. package/lib/esm/model/validation.js +5 -5
  19. package/lib/esm/model/validation.js.map +1 -1
  20. package/lib/esm/overrides/Metadata.d.ts +4 -1
  21. package/lib/esm/overrides/overrides.js +49 -0
  22. package/lib/esm/overrides/overrides.js.map +1 -1
  23. package/lib/esm/overrides/types.d.ts +1 -1
  24. package/lib/esm/utils/constants.d.ts +1 -0
  25. package/lib/esm/utils/constants.js +1 -0
  26. package/lib/esm/utils/constants.js.map +1 -1
  27. package/lib/esm/utils/index.d.ts +1 -0
  28. package/lib/esm/utils/index.js +1 -0
  29. package/lib/esm/utils/index.js.map +1 -1
  30. package/lib/esm/utils/serialization.d.ts +0 -41
  31. package/lib/esm/utils/serialization.js +1 -72
  32. package/lib/esm/utils/serialization.js.map +1 -1
  33. package/lib/esm/utils/serializers.d.ts +41 -0
  34. package/lib/esm/utils/serializers.js +73 -0
  35. package/lib/esm/utils/serializers.js.map +1 -0
  36. package/lib/esm/validation/Validation.js +1 -1
  37. package/lib/esm/validation/Validation.js.map +1 -1
  38. package/lib/esm/validation/Validators/constants.d.ts +1 -0
  39. package/lib/esm/validation/Validators/constants.js +1 -0
  40. package/lib/esm/validation/Validators/constants.js.map +1 -1
  41. package/lib/esm/validation/Validators/utils.js +1 -1
  42. package/lib/esm/validation/Validators/utils.js.map +1 -1
  43. package/lib/index.cjs +1 -1
  44. package/lib/index.d.ts +1 -1
  45. package/lib/model/Model.cjs +14 -255
  46. package/lib/model/Model.d.ts +0 -103
  47. package/lib/model/Model.js.map +1 -1
  48. package/lib/model/ModelRegistry.cjs +296 -0
  49. package/lib/model/ModelRegistry.d.ts +181 -0
  50. package/lib/model/ModelRegistry.js.map +1 -0
  51. package/lib/model/index.cjs +1 -0
  52. package/lib/model/index.d.ts +1 -0
  53. package/lib/model/index.js.map +1 -1
  54. package/lib/model/validation.cjs +5 -5
  55. package/lib/model/validation.d.ts +1 -1
  56. package/lib/model/validation.js.map +1 -1
  57. package/lib/overrides/Metadata.d.ts +4 -1
  58. package/lib/overrides/overrides.cjs +49 -0
  59. package/lib/overrides/overrides.js.map +1 -1
  60. package/lib/overrides/types.d.ts +1 -1
  61. package/lib/utils/constants.cjs +2 -1
  62. package/lib/utils/constants.d.ts +1 -0
  63. package/lib/utils/constants.js.map +1 -1
  64. package/lib/utils/index.cjs +1 -0
  65. package/lib/utils/index.d.ts +1 -0
  66. package/lib/utils/index.js.map +1 -1
  67. package/lib/utils/serialization.cjs +2 -74
  68. package/lib/utils/serialization.d.ts +0 -41
  69. package/lib/utils/serialization.js.map +1 -1
  70. package/lib/utils/serializers.cjs +77 -0
  71. package/lib/utils/serializers.d.ts +41 -0
  72. package/lib/utils/serializers.js.map +1 -0
  73. package/lib/validation/Validation.cjs +4 -4
  74. package/lib/validation/Validation.js.map +1 -1
  75. package/lib/validation/Validators/constants.cjs +1 -0
  76. package/lib/validation/Validators/constants.d.ts +1 -0
  77. package/lib/validation/Validators/constants.js.map +1 -1
  78. package/lib/validation/Validators/utils.cjs +6 -6
  79. package/lib/validation/Validators/utils.js.map +1 -1
  80. package/package.json +1 -1
package/README.md CHANGED
@@ -33,7 +33,7 @@ A TypeScript decorator-driven validation and model framework. It lets you:
33
33
 
34
34
  Documentation available [here](https://decaf-ts.github.io/decorator-validation/)
35
35
 
36
- Minimal size: 13.3 KB kb gzipped
36
+ Minimal size: 13.6 KB kb gzipped
37
37
 
38
38
 
39
39
  # Decorator Validation – Detailed Description
@@ -1,2 +1,2 @@
1
- var e,t;e=this,t=function(e,t,r,a){"use strict";var s;e.ModelKeys=void 0,(s=e.ModelKeys||(e.ModelKeys={})).DESCRIPTION="description",s.TYPE="design:type",s.MODEL="model",s.ANCHOR="__model",s.CONSTRUCTION="constructed-by",s.ATTRIBUTE="__attributes",s.HASHING="hashing",s.SERIALIZATION="serialization",s.DECORATORS="decorators",s.CONSTRUCTOR="__original";const i="json";class n{constructor(){}preSerialize(r,...a){const s=Object.assign({},r);let i;try{i=t.Metadata.modelName(r.constructor)}catch(e){i=void 0}return s[e.ModelKeys.ANCHOR]=i||r.constructor.name,s}deserialize(t,...r){const a=JSON.parse(t),s=a[e.ModelKeys.ANCHOR];if(!s)throw Error("Could not find class reference in serialized model");return ce.build(a,s)}serialize(e,...t){return JSON.stringify(this.preSerialize(e))}}class o{static{this.current=i}static{this.cache={json:new n}}constructor(){}static get(e){if(e in this.cache)return this.cache[e];throw Error("No serialization method registered under "+e)}static register(e,t,r=!1){if(e in this.cache)throw Error(`Serialization method ${e} already registered`);this.cache[e]=new t,r&&(this.current=e)}static serialize(e,t,...r){return t?this.get(t).serialize(e,...r):this.get(this.current).serialize(e,...r)}static deserialize(e,t,...r){return t?this.get(t).deserialize(e,...r):this.get(this.current).deserialize(e,...r)}static setDefault(e){this.current=this.get(e)}}class c{constructor(e){for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&e[t]&&Object.defineProperty(this,t,{enumerable:!0,configurable:!1,value:e[t],writable:!1})}toString(){const e=this;return Object.keys(e).filter((t=>Object.prototype.hasOwnProperty.call(e,t)&&"function"!=typeof e[t])).reduce(((t,r)=>{let a=Object.keys(e[r]).reduce(((t,a)=>(t?t+="\n"+e[r][a]:t=e[r][a],t)),void 0);return a&&(a=`${r} - ${a}`,t?t+="\n"+a:t=a),t}),"")}}const d={EQUALS:"equals",DIFF:"different",LESS_THAN:"lessThan",LESS_THAN_OR_EQUAL:"lessThanOrEqual",GREATER_THAN:"greaterThan",GREATER_THAN_OR_EQUAL:"greaterThanOrEqual"},u={REFLECT:"validation",DATE:"date",EMAIL:"email",FORMAT:"format",LIST:"list",MAX:"max",MAX_LENGTH:"maxlength",MIN:"min",MIN_LENGTH:"minlength",PASSWORD:"password",PATTERN:"pattern",REQUIRED:"required",STEP:"step",TYPE:"type",UNIQUE:"unique",URL:"url",VALIDATOR:"validator",ENUM:"enum",...d},l=["January","February","March","April","May","June","July","August","September","October","November","December"],f=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],h={REQUIRED:"This field is required",MIN:"The minimum value is {0}",MAX:"The maximum value is {0}",MIN_LENGTH:"The minimum length is {0}",MAX_LENGTH:"The maximum length is {0}",PATTERN:"The value does not match the pattern",EMAIL:"The value is not a valid email",URL:"The value is not a valid URL",TYPE:"Invalid type. Expected {0}, received {1}",STEP:"Invalid value. Not a step of {0}",DATE:"Invalid value. not a valid Date",DEFAULT:"There is an Error",PASSWORD:"Must be at least 8 characters and contain one of number, lower and upper case letters, and special character (@$!%*?&_-.,)",LIST:"Invalid list of {0}",MODEL_NOT_FOUND:"No model registered under {0}",EQUALS:"This field must be equal to field {0}",DIFF:"This field must be different from field {0}",LESS_THAN:"This field must be less than field {0}",LESS_THAN_OR_EQUAL:"This field must be less than or equal to field {0}",GREATER_THAN:"This field must be greater than field {0}",GREATER_THAN_OR_EQUAL:"This field must be greater than or equal to field {0}",UNIQUE:"Duplicate found, this field must be unique.",ENUM:"Value is not allowed. Must be one of {0}"},g={EMAIL:/[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?/,URL:/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i,PASSWORD:{CHAR8_ONE_OF_EACH:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&_\-.,])[A-Za-z\d@$!%*?&_\-.,]{8,}$/g}};function p(e,...t){return e.replace(/{(\d+)}/g,((e,r)=>void 0!==t[r]?t[r].toString():"undefined"))}const m=p,y={INVALID_PATH:"Invalid path argument. Expected non-empty string but received: '{0}'",CONTEXT_NOT_OBJECT_COMPARISON:"Unable to access parent at level {0} for path '{1}': current context is not an object",PROPERTY_INVALID:"Failed to resolve path {0}: property '{1}' is invalid or does not exist.",PROPERTY_NOT_EXIST:"Failed to resolve path: property '{0}' does not exist.",UNSUPPORTED_TYPES_COMPARISON:"Unsupported types for comparison: '{0}' and '{1}'",NULL_OR_UNDEFINED_COMPARISON:"Comparison failed due to null or undefined value",INVALID_DATE_COMPARISON:"Invalid Date objects are not comparable",TYPE_MISMATCH_COMPARISON:"Cannot compare values of different types: {0} and {1}.",NAN_COMPARISON:"Comparison not supported for NaN values"},E=Symbol("_parent"),T=Symbol("isAsync");function b(e,t){let r=t;r.match(/hh/)?r=r.replace("hh","(?<hour>\\d{2})"):r.match(/h/)?r=r.replace("h","(?<hour>\\d{1,2})"):r.match(/HH/)?r=r.replace("HH","(?<hour>\\d{2})"):r.match(/H/)&&(r=r.replace("H","(?<hour>\\d{1,2})")),r.match(/mm/)?r=r.replace("mm","(?<minutes>\\d{2})"):r.match(/m/)&&(r=r.replace("m","(?<minutes>\\d{1,2})")),r.match(/ss/)?r=r.replace("ss","(?<seconds>\\d{2})"):r.match(/s/)&&(r=r.replace("s","(?<seconds>\\d{1,2})")),r.match(/dd/)?r=r.replace("dd","(?<day>\\d{2})"):r.match(/d/)&&(r=r.replace("d","(?<day>\\d{1,2})")),r.match(/EEEE/)?r=r.replace("EEEE","(?<dayofweek>\\w+)"):r.match(/EEEE/)&&(r=r.replace("EEE","(?<dayofweek>\\w+)")),r.match(/yyyy/)?r=r.replace("yyyy","(?<year>\\d{4})"):r.match(/yy/)&&(r=r.replace("yy","(?<year>\\d{2})")),r.match(/MMMM/)?r=r.replace("MMMM","(?<monthname>\\w+)"):r.match(/MMM/)&&(r=r.replace("MMM","(?<monthnamesmall>\\w+)")),r.match(/MM/)?r=r.replace("MM","(?<month>\\d{2})"):r.match(/M/)&&(r=r.replace("M","(?<month>\\d{1,2})")),r=r.replace("S","(?<milis>\\d{1,3})").replace("aaa","(?<ampm>\\w{2})");const a=RegExp(r,"g").exec(e);if(!a||!a.groups)return new Date(e);const s=e=>{if(!e)return 0;const t=parseInt(e);return isNaN(t)?0:t},i=s(a.groups.year),n=s(a.groups.day),o=a.groups.ampm;let c=s(a.groups.hour);o&&(c="PM"===o?c+12:c);const d=s(a.groups.minutes),u=s(a.groups.seconds),f=s(a.groups.milis),h=a.groups.monthname,g=a.groups.monthnamesmall;let p=a.groups.month;if(h)p=l.indexOf(h);else if(g){const t=l.find((e=>e.toLowerCase().startsWith(g.toLowerCase())));if(!t)return new Date(e);p=l.indexOf(t)}else p=s(""+p);return new Date(i,p-1,n,c,d,u,f)}function M(e,t){if(e)return Object.defineProperty(e,"toISOString",{enumerable:!1,configurable:!1,value:new Proxy(e.toISOString,{apply:(e,r)=>O(r,t)})}),Object.defineProperty(e,"toString",{enumerable:!1,configurable:!1,value:new Proxy(e.toISOString,{apply:(e,r)=>O(r,t)})}),e}function A(e){return e&&"[object Date]"===Object.prototype.toString.call(e)&&!Number.isNaN(e)}function N(e){return 10>e?"0"+e:e.toString()}function O(e,t="yyyy/MM/dd"){const r=e.getDate(),a=e.getMonth(),s=e.getFullYear(),i=e.getHours(),n=e.getMinutes(),o=e.getSeconds(),c=e.getMilliseconds(),d=i%12,u=N(d),h=N(i),g=N(n),p=N(o),m=12>i?"AM":"PM",y=f[e.getDay()],E=y.substr(0,3),T=N(r),b=a+1,M=N(b),A=l[a],O=A.substr(0,3),_=s+"",S=_.substr(2,2);return(t=t.replace("hh",u).replace("h",d.toString()).replace("HH",h).replace("H",i.toString()).replace("mm",g).replace("m",n.toString()).replace("ss",p).replace("s",o.toString()).replace("S",c.toString()).replace("dd",T).replace("d",r.toString()).replace("EEEE",y).replace("EEE",E).replace("yyyy",_).replace("yy",S).replace("aaa",m)).indexOf("MMM")>-1?t.replace("MMMM",A).replace("MMM",O):t.replace("MM",M).replace("M",b.toString())}function _(e,t){let r;if(t){if(t instanceof Date)try{r=b(O(t,e),e)}catch(r){throw Error(m("Could not convert date {0} to format: {1}",t.toString(),e))}else if("string"==typeof t)r=b(t,e);else if("number"==typeof t)r=b(O(new Date(t),e),e);else{if(!A(t))throw Error("Invalid value provided "+t);try{r=b(O(new Date(t),e),e)}catch(r){throw Error(m("Could not convert date {0} to format: {1}",t,e))}}return M(r,e)}}function S(e,t,...r){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return e===t;if(typeof e!=typeof t)return!1;if(Number.isNaN(e)&&Number.isNaN(t))return!0;if("object"!=typeof e)return e===t;if(e instanceof Date&&t instanceof Date)return!(!isNaN(e.getTime())||!isNaN(t.getTime()))||e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.toString()===t.toString();if(e instanceof Error&&t instanceof Error)return e.name===t.name&&e.message===t.message;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a++)if(!S(e[a],t[a],...r))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[a,s]of e)if(!t.has(a)||!S(s,t.get(a),...r))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(e.byteLength!==t.byteLength)return!1;if(e.byteOffset!==t.byteOffset)return!1;if(e.buffer.byteLength!==t.buffer.byteLength)return!1;const r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);for(let e=0;e<r.length;e++)if(r[e]!==a[e])return!1;return!0}const a=Object.keys(e).filter((e=>!r.includes(e))),s=Object.keys(t).filter((e=>!r.includes(e)));if(a.length!==s.length)return!1;for(const i of a){if(!s.includes(i))return!1;if(!S(e[i],t[i],...r))return!1}const i=Object.getOwnPropertySymbols(e).filter((e=>!r.includes(e.toString()))),n=Object.getOwnPropertySymbols(t).filter((e=>!r.includes(e.toString())));if(i.length!==n.length)return!1;for(const a of i){if(!n.includes(a))return!1;if(!S(e[a],t[a],...r))return!1}return Object.getPrototypeOf(e)===Object.getPrototypeOf(t)}function R(e){e+="";let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return t.toString()}function v(e){const t=(e,t)=>{const r=a(t);return"string"==typeof r?a((e||"")+a(t)):0|(e=((e=e||0)<<5)-e+r)},r=R,a=e=>void 0===e?"":-1!==["string","number","symbol"].indexOf(typeof e)?r(e.toString()):e instanceof Date?r(e.getTime()):Array.isArray(e)?e.reduce(t,void 0):Object.values(e).reduce(t,void 0),s=Object.values(e).reduce(t,0);return("number"==typeof s?Math.abs(s):s).toString()}const P="default";class L{static{this.current=P}static{this.cache={default:v}}constructor(){}static get(e){if(e in this.cache)return this.cache[e];throw Error("No hashing method registered under "+e)}static register(e,t,r=!1){if(e in this.cache)throw Error(`Hashing method ${e} already registered`);this.cache[e]=t,r&&(this.current=e)}static hash(e,t,...r){return t?this.get(t)(e,...r):this.get(this.current)(e,...r)}static setDefault(e){this.current=this.get(e)}}const D=e=>e[E],w=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw Error(m(y.PROPERTY_NOT_EXIST,t));return e[t]};class I{static create(e,t){const{getValue:r,getParent:a,ignoreUndefined:s,ignoreNull:i}={getParent:D,getValue:w,ignoreNull:!1,ignoreUndefined:!1,...t};return new Proxy({},{get:(t,n)=>"getValueFromPath"===n?t=>{const n=I.parsePath(t);let o=e;for(let e=0;e<n.length;e++){const c=n[e];if(".."!==c){if(o=r(o,c),!s&&void 0===o)throw Error(m(y.PROPERTY_INVALID,t,c));if(!i&&null===o)throw Error(m(y.PROPERTY_INVALID,t,c))}else{const r=a(o);if(!r||"object"!=typeof r)throw Error(m(y.CONTEXT_NOT_OBJECT_COMPARISON,e+1,t));o=r}}return o}:t[n]})}static parsePath(e){if("string"!=typeof e||!e.trim())throw Error(m(y.INVALID_PATH,e));return e.match(/(\.\.|[^/.]+)/g)||[]}}const V=e=>null===e?"null":e instanceof Date?"Date":Number.isNaN(e)?"NaN":e===1/0?"Infinity":e===-1/0?"-Infinity":Array.isArray(e)?"array":typeof e,j=e=>void 0===e||e instanceof Date||"bigint"==typeof e||"number"==typeof e&&Number.isFinite(e);function U(e,t){if(j(e)&&j(t))return!0;throw new TypeError(m(y.UNSUPPORTED_TYPES_COMPARISON,V(e),V(t)))}function C(e,t){if([null,void 0].includes(e)||[null,void 0].includes(t))throw Error(y.NULL_OR_UNDEFINED_COMPARISON);const r=typeof e,a=typeof t;if(r!==a){if("bigint"===r&&"number"===a)return t>Number(e);if("number"===r&&"bigint"===a)return Number(t)>e;throw new TypeError(m(y.TYPE_MISMATCH_COMPARISON,r,a))}if("number"===r&&"number"===a||"bigint"===r&&"bigint"===a){if(Number.isNaN(e)||Number.isNaN(t))throw new TypeError(y.NAN_COMPARISON);return t>e}if(e instanceof Date&&t instanceof Date){if(isNaN(e.getTime())||isNaN(t.getTime()))throw new TypeError(y.INVALID_DATE_COMPARISON);return e.getTime()<t.getTime()}throw new TypeError(m(y.UNSUPPORTED_TYPES_COMPARISON,V(e),V(t)))}function H(e,t){if([null,void 0].includes(e)||[null,void 0].includes(t))throw Error(y.NULL_OR_UNDEFINED_COMPARISON);const r=typeof e,a=typeof t;if(r!==a){if("bigint"===r&&"number"===a)return Number(e)>t;if("number"===r&&"bigint"===a)return e>Number(t);throw Error(m(y.TYPE_MISMATCH_COMPARISON,r,a))}if("number"===r&&"number"===a||"bigint"===r&&"bigint"===a){if(Number.isNaN(e)||Number.isNaN(t))throw new TypeError(y.NAN_COMPARISON);return e>t}if(e instanceof Date&&t instanceof Date){if(isNaN(e.getTime())||isNaN(t.getTime()))throw new TypeError(y.INVALID_DATE_COMPARISON);return e.getTime()>t.getTime()}throw new TypeError(m(y.UNSUPPORTED_TYPES_COMPARISON,V(e),V(t)))}function x(e,t){return typeof e===t.toLowerCase()||void 0!==e&&"object"==typeof e&&e.constructor&&e.constructor.name.toLowerCase()===t.toLowerCase()}function F(e,t){return!t.every((t=>!x(e,t)))}function z(e,t){switch(typeof t){case"string":return x(e,t);case"object":return!Array.isArray(t)||F(e,t);case"function":return!t.name||"Object"===t.name||x(e,t.name);default:return!0}}function G(e){return e instanceof Set||e instanceof Map?e.size:e.length}class ${constructor(e,t=h.DEFAULT,...r){this.async=e,this.message=t,r.length&&(this.acceptedTypes=r),this.acceptedTypes&&(this.hasErrors=this.checkTypeAndHasErrors(this.hasErrors.bind(this)))}getMessage(e,...t){return m(e,...t)}checkTypeAndHasErrors(e){return function(t,r,a,...s){return void 0!==t&&this.acceptedTypes?F(t,this.acceptedTypes)?e(t,r,a,...s):this.getMessage(h.TYPE,this.acceptedTypes.join(", "),"number"!=typeof t?typeof t:isNaN(t)?"NaN":typeof t):e(t,r,a,...s)}.bind(this)}static isValidator(e){return e.constructor&&!!e.hasErrors}}class Y extends ${constructor(e=h.DEFAULT,...t){super(!1,e,...t)}}class q{constructor(...e){this.cache={},this.customKeyCache={},this.register(...e)}getCustomKeys(){return Object.assign({},this.customKeyCache)}getKeys(){return Object.keys(this.cache)}get(e){if(!(e in this.cache))return;const t=this.cache[e];if(Y.isValidator(t))return t;const r=new(t.default||t);return this.cache[e]=r,r}register(...e){e.forEach((e=>{if(Y.isValidator(e)){if(e.validationKey in this.cache)return;this.cache[e.validationKey]=e}else{const{validationKey:t,validator:r,save:a}=e;if(t in this.cache)return;if(this.cache[t]=r,!a)return;const s={};s[t.toUpperCase()]=t,this.customKeyCache=Object.assign({},this.customKeyCache,s)}}))}}class K{static{this.actingValidatorRegistry=void 0}constructor(){}static setRegistry(e,t){t&&K.actingValidatorRegistry&&K.actingValidatorRegistry.getKeys().forEach((r=>{const a=e.get(r);a&&e.register(t(a))})),K.actingValidatorRegistry=e}static getRegistry(){return K.actingValidatorRegistry||(K.actingValidatorRegistry=new q),K.actingValidatorRegistry}static get(e){return K.getRegistry().get(e)}static register(...e){return K.getRegistry().register(...e)}static key(e){return u.REFLECT+e}static keys(){return this.getRegistry().getKeys()}static registerDecorator(r,a){const s=t.Metadata.innerGet(Symbol.for(e.ModelKeys.DECORATORS),t.Metadata.key(u.REFLECT,r));s?.[r]||t.Metadata.set(e.ModelKeys.DECORATORS,t.Metadata.key(u.REFLECT,r),a)}static decoratorFromKey(r){try{return t.Metadata.innerGet(Symbol.for(e.ModelKeys.DECORATORS),t.Metadata.key(u.REFLECT,r))}catch(e){throw Error(`No decorator registered under ${r}: ${e}`)}}}function k(e,t){return t?Promise.resolve(e):e}function Q(e,t,r){Object.hasOwnProperty.call(e,t)||(e[t]=r)}function B(e,t){Object.hasOwnProperty.call(e,t)&&delete e[t]}function X(e,t,r,...a){t&&Q(e,E,t),Q(e,T,!!r);const s=e.hasErrors(...a);return B(e,E),B(e,T),s}function W(e,t,r,a,s,...i){let n,o=!1;for(const d of a){const a=ce.get(d);if(a||(n=new c({[e]:{[u.TYPE]:"Unable to verify type consistency, missing model registry for "+d}})),t instanceof a){o=!0,n=X(t,r,s,...i);break}}return o?n:n||new c({[e]:{[u.TYPE]:"Value must be an instance of one of the expected types: "+a.join(", ")}})}function Z(e,...t){return t?.map((t=>("string"==typeof t&&t?.startsWith(e+".")&&(t=t.replace(e+".","")),t)))}function J(t,r,a,s){const i=K.get(a.key);if(!i)throw Error("Missing validator for "+a.key);if(!s&&a.async)return;const n=a.key===e.ModelKeys.TYPE?[a]:a||{},o=I.create(t,{ignoreUndefined:!0,ignoreNull:!0}),c=a.key===e.ModelKeys.TYPE?n[0]:n;return k(i.hasErrors(r,c,o),s)}function ee(t,r,a,s,i,...n){const o={};for(const c in s){const d={...s[c],key:c};if(!i&&d.async)continue;let l=J(t,a,d,i);if(c===u.LIST&&(!l||i)){const e=a instanceof Set?[...a]:a;if(e&&e.length>0){let a=d.class||d.clazz||d.customTypes;a=(Array.isArray(a)?a:[a]).map((e=>(e="function"!=typeof e||e.name?e:e()).name?e.name:e));const s=[a].flat().map((e=>(e+"").toLowerCase())),o=e.map((e=>{if(ce.isModel(e)){const s=Z(r,...n);return W(r,e,t,a.flat(),!!i,...s)}return s.includes(typeof e)?void 0:"Value has no validatable type"}));if(i)l=Promise.all(o).then((e=>e.every((e=>!e))?void 0:e));else{const e=o.every((e=>!e));l=o.length>0&&!e?o:void 0}}}const f=c===e.ModelKeys.TYPE?u.TYPE:c;l&&(o[f]=l)}if(!i)return Object.keys(o).length>0?o:void 0;const c=Object.keys(o),d=Object.values(o);return Promise.all(d).then((e=>{const t={};for(let r=0;r<e.length;r++){const a=e[r];void 0!==a&&(t[c[r]]=a)}return Object.keys(t).length>0?t:void 0}))}function te(r,a,...s){const i=t.Metadata.validatableProperties(r.constructor,...s),n={},o={};for(const c of i){const i=c+"",d=r[c],l=t.Metadata.validationFor(r.constructor,c)||{},{designTypes:f}=t.Metadata.getPropDesignTypes(r.constructor,c);if(!f)continue;if(f.some((e=>[Array.name,Set.name].includes(e.name)))){if(!l||!Object.keys(l).includes(u.LIST)){n[i]={[u.TYPE]:`Array or Set property '${i}' requires a @list decorator`};continue}if(d&&!(Array.isArray(d)||d instanceof Set)){n[i]={[u.TYPE]:`Property '${c+""}' must be either an Array or a Set`};continue}}const h=ee(r,i,d,l,a,...s)||{};if(ce.isPropertyModel(r,i)&&null!=d){const t=f.map((e=>ce.get(e.name||e))).find((e=>!!e)),n=f.map((e=>"function"==typeof e?e.name?e.name.toLowerCase():e()?.name.toLowerCase():e.toLowerCase()));if(t&&d instanceof t){const e=Z(i,...s);o[i]=X(d,r,a,...e)}else n.includes(typeof d)||(h[u.TYPE]=t?"Value must be an instance of "+t.name:`Unable to verify type consistency, missing model registry for ${f.toString()} on prop ${i}`,delete h[e.ModelKeys.TYPE])}(Object.keys(h).length>0||a)&&(n[i]=h),a||Object.entries(o[i]||{}).forEach((([e,t])=>{void 0!==t&&(n[`${i}.${e}`]=t)}))}if(!a)return Object.keys(n).length>0?new c(n):void 0;const d=n,l=Object.keys(d),f=Object.values(d);return Promise.allSettled(f).then((async e=>{const t={};for(const[e,r]of Object.entries(o)){const a=await r;a&&Object.entries(a).forEach((([r,a])=>{void 0!==a&&(t[[e,r].join(".")]=a)}))}for(let r=0;r<e.length;r++){const a=l[r],s=e[r];"fulfilled"===s.status&&void 0!==s.value?t[a]=s.value:"rejected"===s.status&&(t[a]=s.reason instanceof Error?s.reason.message:(s.reason||"Validation failed")+"")}return Object.keys(t).length>0?new c(t):void 0}))}var re;e.Primitives=void 0,(re=e.Primitives||(e.Primitives={})).STRING="string",re.NUMBER="number",re.BOOLEAN="boolean",re.BIGINT="bigint";const ae={STRING:String,OBJECT:Object,NUMBER:Number,BOOLEAN:Boolean,BIGINT:BigInt,DATE:Date},se=["string","array","number","boolean","symbol","function","object","undefined","null","bigint"];let ie,ne;class oe{constructor(e=ce.isModel){this.cache={},this.testFunction=e}register(e,t){if("function"!=typeof e)throw Error("Model registering failed. Missing Class name or constructor");t=t||e.name,this.cache[t]=e}get(e){try{return this.cache[e]}catch(e){return}}build(e={},r){if(!r&&!this.testFunction(e))throw Error("Provided obj is not a Model object");const a=r||t.Metadata.modelName(e.constructor);if(!(a in this.cache))throw Error(`Provided class ${a} is not a registered Model object`);return new this.cache[a](e)}}class ce{constructor(e=void 0){}isAsync(){return!!(this[T]??this?.constructor[T])}hasErrors(...e){return te(this,this.isAsync(),...e)}equals(e,...t){return S(this,e,...t)}compare(e,...r){const a=t.Metadata.properties(this.constructor);if(!a||!a.length)return;const s=a.reduce(((t,a)=>{const s=a;if(r.includes(s))return t;if(void 0===this[s]&&void 0!==e[s])return t[s]={other:e[s],current:void 0},t;if(void 0!==this[s]&&void 0===e[s])return t[s]={other:void 0,current:this[s]},t;if(S(this[s],e[s]))return t;if(ce.isPropertyModel(this,s)){const r=this[s].compare(e[s]);return r&&(t[s]=r),t}if(Array.isArray(this[s])&&Array.isArray(e[s])){if(this[s].length!==e[s].length)return t[s]={current:this[s],other:e[s]},t;const r=this[s].map(((t,r)=>S(t,e[s][r])?null:t instanceof ce&&e[s][r]instanceof ce?t.compare(e[s][r]):{current:t,other:e[s][r]}));return r.some((e=>null!==e))&&(t[s]=r),t}return t[s]={other:e[s],current:this[s]},t}),{});return Object.keys(s).length>0?s:void 0}serialize(){return ce.serialize(this)}toString(){return this.constructor.name+": "+JSON.stringify(this,void 0,2)}hash(){return ce.hash(this)}static deserialize(r){let a;try{a=t.Metadata.get(this.constructor,e.ModelKeys.SERIALIZATION)}catch(e){a=void 0}return a&&a.serializer?o.deserialize(r,a.serializer,...a.args||[]):o.deserialize(r)}static fromObject(e,t){t||(t={});for(const r of ce.getAttributes(e))e[r]=t[r]??e[r]??void 0;return e}static fromModel(e,r){let a;r||(r={});const s=ce.getAttributes(e),i=Object.getPrototypeOf(e);let n;for(const o of s){try{e[o]=r[o]??e[o]??void 0}catch(e){if(n=Object.getOwnPropertyDescriptor(i,o),!n||n.writable)throw Error(`Unable to write property ${o} to model: ${e}`)}if("object"!=typeof e[o])continue;const s=ce.isPropertyModel(e,o);if(s){try{e[o]=ce.build(e[o],"string"==typeof s?s:void 0)}catch(e){}continue}if(a=t.Metadata.allowedTypes(e.constructor,o),!a||!a.length)throw Error("failed to find decorators for property "+o);const c=a.map((e=>"function"!=typeof e||e.name?e:e())),d=Object.values(ae);c.forEach((r=>{if(!d.includes(r))try{switch(r.name){case"Array":case"Set":{const a=t.Metadata.validationFor(e.constructor,o);if(!a||!a[u.LIST])break;const s=a[u.LIST].clazz.map((e=>"function"!=typeof e||e.name?e:e())).find((e=>!se.includes(e.name)));if("Array"===r.name&&(e[o]=e[o].map((e=>["object","function"].includes(typeof e)&&s?ce.build(e,s.name):e))),"Set"===r.name){const t=new Set;for(const r of e[o])["object","function"].includes(typeof r)&&s?t.add(ce.build(r,s.name)):t.add(r);e[o]=t}break}default:void 0!==e[o]&&ce.get(r.name)&&(e[o]=ce.build(e[o],r.name))}}catch(e){}}))}return e}static setBuilder(e){ie=e}static getBuilder(){return ie||ce.fromModel}static getRegistry(){return ne||(ne=new oe),ne}static setRegistry(e){ne=e}static register(e,t){return ce.getRegistry().register(e,t)}static get(e){return ce.getRegistry().get(e)}static build(e={},t){return ce.getRegistry().build(e,t)}static getAttributes(e){const r=e instanceof ce?e.constructor:e,a=new Set,s=e=>{if(!e)return[];const r=s(Object.getPrototypeOf(e)),i=t.Metadata.properties(e)??[];for(const e of i)a.has(e)||(a.add(e),r.push(e));return r};return s(r)}static equals(e,t,...r){return S(e,t,...r)}static hasErrors(e,t,...r){return te(e,t,...r)}static serialize(r){let a;try{a=t.Metadata.get(r.constructor,e.ModelKeys.SERIALIZATION)}catch(e){a=void 0}return a&&a.serializer?o.serialize(this,a.serializer,...a.args||[]):o.serialize(r)}static hash(r){const a=t.Metadata.get(r.constructor,e.ModelKeys.HASHING);return a&&a.algorithm?L.hash(r,a.algorithm,...a.args||[]):L.hash(r)}static isModel(e){try{if(e instanceof ce)return!0;const r=t.Metadata.constr(e);return!(!r||r===e||!t.Metadata.modelName(r))}catch(e){return!1}}static isPropertyModel(e,r){if(ce.isModel(e[r]))return!0;const a=t.Metadata.type(e.constructor,r);return a&&ce.get(a.name)?a.name:void 0}static describe(e,r){return t.Metadata.description(e,r)}}function de(...e){return t.apply((t=>(e.forEach((e=>{K.register({validator:t,validationKey:e,save:!0})})),t)),t.metadata(u.VALIDATOR,e))}t.Metadata.validationFor=((e,r,a)=>{const s=t.Metadata.get(e);if(!s)return;if(!r)return s.validation;if(!s.validation)return;if(!s.validation[u.TYPE]){const{designTypes:a}=t.Metadata.getPropDesignTypes(e,r);s.validation[r]&&a?.length&&a[0]!==ae.OBJECT&&(s.validation[r][u.TYPE]={customTypes:a,message:h.TYPE,description:"defines the accepted types for the attribute",async:!1})}if(!a)return s.validation[r];const i=s.validation[r];return i?i[a]:void 0}).bind(t.Metadata),t.Metadata.modelName=(e=>{const r=t.Metadata.constr(e);return r?r.name:e.name}).bind(t.Metadata),t.Metadata.validatableProperties=((e,...r)=>{const a=t.Metadata.validationFor(e),s=a?Object.keys(a):[];return[...new Set([...ce.getAttributes(e),...s])].filter((e=>!r||!r?.includes(e)))}).bind(t.Metadata),t.Metadata.allowedTypes=((e,r)=>{const a=t.Metadata.type(e,r);if(!a)throw Error("No metadata found for property "+r);const s=t.Metadata.validationFor(e,r);return s&&s[u.TYPE]&&"function"==typeof s[u.TYPE]?.customTypes[Symbol.iterator]?[...s[u.TYPE].customTypes]:[a]}).bind(t.Metadata),t.Metadata.getPropDesignTypes=((e,r)=>{const a=t.Metadata.get(e),s=t.Metadata.type(e,r),i=a?.[u.REFLECT]?.[r];if(!(s||i&&i[u.TYPE]))return{};const n=i&&i[u.TYPE]?[i[u.TYPE].customTypes]:[s];if(!n?.length)return{};const o=n[0],c=o.class||o.clazz||o.customTypes||o;return{designTypes:(Array.isArray(c)?c:[c]).map((e=>"function"!=typeof e||e.name?e:e())),designType:c}}).bind(t.Metadata),e.DateValidator=class extends Y{constructor(e=h.DATE){super(e,Number.name,Date.name,String.name)}hasErrors(e,t={}){if(void 0!==e&&("string"==typeof e&&(e=new Date(e)),Number.isNaN(e.getDate()))){const{message:e=""}=t;return this.getMessage(e||this.message)}}},e.DateValidator=r.__decorate([de(u.DATE),r.__metadata("design:paramtypes",[String])],e.DateValidator),e.DiffValidator=class extends Y{constructor(e=h.DIFF){super(e)}hasErrors(e,t,r){let a;try{a=r.getValueFromPath(t[u.DIFF])}catch(e){return this.getMessage(e.message||this.message)}return S(e,a)?this.getMessage(t.message||this.message,t.label||t[u.DIFF]):void 0}},e.DiffValidator=r.__decorate([de(u.DIFF),r.__metadata("design:paramtypes",[String])],e.DiffValidator);const ue=RegExp("^/(.+)/([gimus]*)$");function le(e,r,a){return t.apply(t.propMetadata(r,a))}function fe(e,t,r){return K.registerDecorator(t,e),(e,a)=>le(0,`${u.REFLECT}.${a}.${t}`,r)(e,a)}function he(e=h.REQUIRED){const r=u.REQUIRED,a={message:e,description:"defines the attribute as required",async:!1};return t.Decoration.for(r).define({decorator:fe,args:[he,r,a]}).apply()}function ge(e,r=h.MIN){const a=u.MIN,s={[u.MIN]:e,message:r,description:`defines the max value of the attribute as ${e} (applies to numbers or Dates)`,async:!1};return t.Decoration.for(a).define({decorator:fe,args:[ge,a,s]}).apply()}function pe(e,r=h.MAX){const a=u.MAX,s={[u.MAX]:e,message:r,description:`defines the max value of the attribute as ${e} (applies to numbers or Dates)`,async:!1};return t.Decoration.for(a).define({decorator:fe,args:[pe,a,s]}).apply()}function me(e,r=h.STEP){const a=u.STEP,s={[u.STEP]:e,message:r,description:"defines the step of the attribute as "+e,async:!1};return t.Decoration.for(a).define({decorator:fe,args:[me,a,s]}).apply()}function ye(e,r=h.MIN_LENGTH){const a=u.MIN_LENGTH,s={[u.MIN_LENGTH]:e,message:r,description:`defines the min length of the attribute as ${e} (applies to strings or lists)`,async:!1};return t.Decoration.for(a).define({decorator:fe,args:[ye,a,s]}).apply()}function Ee(e,r=h.MAX_LENGTH){const a=u.MAX_LENGTH,s={[u.MAX_LENGTH]:e,message:r,description:`defines the max length of the attribute as ${e} (applies to strings or lists)`,async:!1};return t.Decoration.for(a).define({decorator:fe,args:[Ee,a,s]}).apply()}function Te(e,r=h.PATTERN){const a=u.PATTERN,s={[u.PATTERN]:"string"==typeof e?e:e.toString(),message:r,description:`assigns the ${"string"===e?e:e.toString()} pattern to the attribute`,async:!1};return t.Decoration.for(a).define({decorator:fe,args:[Te,a,s]}).apply()}function be(e=h.EMAIL){const r=u.EMAIL,a={[u.PATTERN]:g.EMAIL.toString(),message:e,description:"marks the attribute as an email",async:!1};return t.Decoration.for(r).define({decorator:fe,args:[be,r,a]}).apply()}function Me(e=h.URL){const r=u.URL,a={[u.PATTERN]:g.URL.toString(),message:e,description:"marks the attribute as an url",async:!1};return t.Decoration.for(r).define({decorator:fe,args:[Me,r,a]}).apply()}function Ae(e,r=h.TYPE){const a=u.TYPE,s={customTypes:e,message:r,description:"defines the accepted types for the attribute",async:!1};return t.Decoration.for(a).define({decorator:fe,args:[Ae,a,s]}).apply()}function Ne(e="dd/MM/yyyy",r=h.DATE){const a=u.DATE;return t.Decoration.for(a).define({decorator:function(e,t){const r={[u.FORMAT]:e,message:t,description:"defines the attribute as a date with the format "+e,async:!1};return function(t,s){const i=new WeakMap;return Object.defineProperty(t,s,{configurable:!0,set(t){const r=Object.getOwnPropertyDescriptor(this,s);r&&!r.configurable||Object.defineProperty(this,s,{enumerable:!0,configurable:!1,get:()=>i.get(this),set:t=>{let r;try{r=_(e,t),i.set(this,r)}catch(e){}}}),this[s]=t},get(){return i.get(this)}}),fe(Ne,a,r)(t,s)}},args:[e,r]}).apply()}function Oe(e=g.PASSWORD.CHAR8_ONE_OF_EACH,r=h.PASSWORD){const a=u.PASSWORD,s={[u.PATTERN]:e.toString(),message:r,description:"attribute as a password",async:!1};return t.Decoration.for(a).define({decorator:fe,args:[Oe,a,s]}).apply()}function _e(e,r="Array",a=h.LIST){const s=u.LIST,i={clazz:Array.isArray(e)?e:[e],type:r,message:a,async:!1,description:`defines the attribute as a ${r} of ${e.name}`};return t.Decoration.for(s).define({decorator:fe,args:[_e,s,i]}).apply()}function Se(e,t){return fe(Se,u.EQUALS,{label:t?.label||e,message:t?.message||h.EQUALS,[u.EQUALS]:e,description:"defines attribute as equal to "+e,async:!1})}function Re(e,t){return fe(Re,u.DIFF,{label:t?.label||e,message:t?.message||h.DIFF,[u.DIFF]:e,description:"defines attribute as different to "+e,async:!1})}function ve(e,t){return fe(ve,u.LESS_THAN,{label:t?.label||e,message:t?.message||h.LESS_THAN,[u.LESS_THAN]:e,description:"defines attribute as less than to "+e,async:!1})}function Pe(e,t){return fe(Pe,u.LESS_THAN_OR_EQUAL,{label:t?.label||e,message:t?.message||h.LESS_THAN_OR_EQUAL,[u.LESS_THAN_OR_EQUAL]:e,description:"defines attribute as less or equal to "+e,async:!1})}function Le(e,t){return fe(Le,u.GREATER_THAN,{label:t?.label||e,message:t?.message||h.GREATER_THAN,[u.GREATER_THAN]:e,description:"defines attribute as greater than "+e,async:!1})}function De(e,t){return fe(De,u.GREATER_THAN_OR_EQUAL,{label:t?.label||e,message:t?.message||h.GREATER_THAN_OR_EQUAL,[u.GREATER_THAN_OR_EQUAL]:e,description:"defines attribute as greater or equal to "+e,async:!1})}function we(e,r=h.ENUM){const a=u.ENUM,s={[u.ENUM]:e,message:r,description:"defines a list or an object of accepted values for the attribute",async:!1};return t.Decoration.for(a).define({decorator:fe,args:[we,a,s]}).apply()}function Ie(e,...t){const r=(...t)=>new e(...t);return r.prototype=e.prototype,r(...t)}function Ve(e){if(e instanceof ce)return;function t(e,t){Object.setPrototypeOf(e,t)}const r=Object.getPrototypeOf(e);if(r===Object.prototype)return t(e,ce.prototype);for(;r!==Object.prototype;){const e=Object.getPrototypeOf(r);if(e===Object.prototype||Object.getPrototypeOf(e)===Object.prototype)return t(r,ce.prototype)}throw Error("Could not find proper prototype to bind")}function je(r){const a=(...e)=>{const t=Ie(r,...e);Ve(t);const a=ce.getBuilder();return a&&a(t,e.length?e[0]:void 0),t};return a.prototype=r.prototype,Object.defineProperty(a,"name",{writable:!1,enumerable:!0,configurable:!1,value:r.prototype.constructor.name}),t.metadata(e.ModelKeys.CONSTRUCTOR,r)(a),ce.register(a,r.name),a}function Ue(){const r=e.ModelKeys.MODEL;return t.Decoration.for(r).define(je).apply()}e.PatternValidator=class extends Y{constructor(e=h.PATTERN){super(e,"string")}getPattern(e){if(!ue.test(e))return RegExp(e);const t=e.match(ue);return RegExp(t[1],t[2])}hasErrors(e,t){if(!e)return;let{pattern:r}=t;if(!r)throw Error("Missing Pattern");return r="string"==typeof r?this.getPattern(r):r,r.lastIndex=0,r.test(e)?void 0:this.getMessage(t.message||this.message)}},e.PatternValidator=r.__decorate([de(u.PATTERN),r.__metadata("design:paramtypes",[String])],e.PatternValidator),e.EmailValidator=class extends e.PatternValidator{constructor(e=h.EMAIL){super(e)}hasErrors(e,t={}){return super.hasErrors(e,{...t,message:t.message||this.message,pattern:t?.pattern||g.EMAIL})}},e.EmailValidator=r.__decorate([de(u.EMAIL),r.__metadata("design:paramtypes",[String])],e.EmailValidator),e.EqualsValidator=class extends Y{constructor(e=h.EQUALS){super(e)}hasErrors(e,t,r){let a;try{a=r.getValueFromPath(t[u.EQUALS])}catch(e){return this.getMessage(e.message||this.message)}return S(e,a)?void 0:this.getMessage(t.message||this.message,t.label||t[u.EQUALS])}},e.EqualsValidator=r.__decorate([de(u.EQUALS),r.__metadata("design:paramtypes",[String])],e.EqualsValidator),e.GreaterThanValidator=class extends Y{constructor(e=h.GREATER_THAN){super(e)}hasErrors(e,t,r){let a;try{a=r.getValueFromPath(t[u.GREATER_THAN])}catch(e){return this.getMessage(e.message||this.message)}try{if(!H(e,a))throw Error(t.message||this.message)}catch(e){return this.getMessage(e.message,t.label||t[u.GREATER_THAN])}}},e.GreaterThanValidator=r.__decorate([de(u.GREATER_THAN),r.__metadata("design:paramtypes",[String])],e.GreaterThanValidator),e.GreaterThanOrEqualValidator=class extends Y{constructor(e=h.GREATER_THAN_OR_EQUAL){super(e)}hasErrors(e,t,r){let a;try{a=r.getValueFromPath(t[u.GREATER_THAN_OR_EQUAL])}catch(e){return this.getMessage(e.message||this.message)}try{if(U(e,a)&&S(e,a)||H(e,a))return;throw Error(t.message||this.message)}catch(e){return this.getMessage(e.message,t.label||t[u.GREATER_THAN_OR_EQUAL])}}},e.GreaterThanOrEqualValidator=r.__decorate([de(u.GREATER_THAN_OR_EQUAL),r.__metadata("design:paramtypes",[String])],e.GreaterThanOrEqualValidator),e.LessThanValidator=class extends Y{constructor(e=h.LESS_THAN){super(e)}hasErrors(e,t,r){let a;try{a=r.getValueFromPath(t[u.LESS_THAN])}catch(e){return this.getMessage(e.message||this.message)}try{if(!C(e,a))throw Error(t.message||this.message)}catch(e){return this.getMessage(e.message,t.label||t[u.LESS_THAN])}}},e.LessThanValidator=r.__decorate([de(u.LESS_THAN),r.__metadata("design:paramtypes",[String])],e.LessThanValidator),e.LessThanOrEqualValidator=class extends Y{constructor(e=h.LESS_THAN_OR_EQUAL){super(e)}hasErrors(e,t,r){let a;try{a=r.getValueFromPath(t[u.LESS_THAN_OR_EQUAL])}catch(e){return this.getMessage(e.message||this.message)}try{if(U(e,a)&&S(e,a)||C(e,a))return;throw Error(t.message||this.message)}catch(e){return this.getMessage(e.message,t.label||t[u.LESS_THAN_OR_EQUAL])}}},e.LessThanOrEqualValidator=r.__decorate([de(u.LESS_THAN_OR_EQUAL),r.__metadata("design:paramtypes",[String])],e.LessThanOrEqualValidator),e.ListValidator=class extends Y{constructor(e=h.LIST){super(e,Array.name,Set.name)}hasErrors(e,t){if(!e||(Array.isArray(e)?!e.length:!e.size))return;const r=(Array.isArray(t.clazz)?t.clazz:[t.clazz]).map((e=>"string"==typeof e?e:e?.name||"function"!=typeof e?e?.name:e().name));let a,s=!0;for(let t=0;t<(Array.isArray(e)?e.length:e.size);t++)switch(a=[...e][t],typeof a){case"object":case"function":s=r.includes((a??{}).constructor?.name);break;default:s=r.some((e=>typeof a===e?.toLowerCase()))}return s?void 0:this.getMessage(t.message||this.message,r)}},e.ListValidator=r.__decorate([de(u.LIST),r.__metadata("design:paramtypes",[String])],e.ListValidator),e.MaxLengthValidator=class extends Y{constructor(e=h.MAX_LENGTH){super(e,String.name,Array.name,Set.name,Map.name)}hasErrors(e,t){if(void 0!==e)return G(e)>t.maxlength?this.getMessage(t.message||this.message,t.maxlength):void 0}},e.MaxLengthValidator=r.__decorate([de(u.MAX_LENGTH),r.__metadata("design:paramtypes",[String])],e.MaxLengthValidator),e.MaxValidator=class extends Y{constructor(e=h.MAX){super(e,Number.name,Date.name,String.name)}hasErrors(e,t){if(void 0===e)return;let{max:r}=t;if(e instanceof Date&&!(r instanceof Date)&&(r=new Date(r),Number.isNaN(r.getDate())))throw Error("Invalid Max param defined");return e>r?this.getMessage(t.message||this.message,r):void 0}},e.MaxValidator=r.__decorate([de(u.MAX),r.__metadata("design:paramtypes",[String])],e.MaxValidator),e.MinLengthValidator=class extends Y{constructor(e=h.MIN_LENGTH){super(e,String.name,Array.name,Set.name,Map.name)}hasErrors(e,t){if(void 0!==e)return G(e)<t.minlength?this.getMessage(t.message||this.message,t.minlength):void 0}},e.MinLengthValidator=r.__decorate([de(u.MIN_LENGTH),r.__metadata("design:paramtypes",[String])],e.MinLengthValidator),e.MinValidator=class extends Y{constructor(e=h.MIN){super(e,Number.name,Date.name,String.name)}hasErrors(e,t){if(void 0===e)return;let{min:r}=t;if(e instanceof Date&&!(r instanceof Date)&&(r=new Date(r),Number.isNaN(r.getDate())))throw Error("Invalid Min param defined");return r>e?this.getMessage(t.message||this.message,r):void 0}},e.MinValidator=r.__decorate([de(u.MIN),r.__metadata("design:paramtypes",[String])],e.MinValidator),e.OptionValidator=class extends Y{constructor(e=h.ENUM){super(e)}hasErrors(e,t){if(void 0!==e){if(Array.isArray(t.enum))return t.enum.includes(e)?void 0:this.getMessage(t.message||this.message,t.enum);if("object"==typeof t.enum){const r=Object.keys(t.enum);for(const a of r)if(t.enum[a]===e)return;return this.getMessage(t.message||this.message,Object.values(t.enum))}}}},e.OptionValidator=r.__decorate([de(u.ENUM),r.__metadata("design:paramtypes",[String])],e.OptionValidator),e.PasswordValidator=class extends e.PatternValidator{constructor(e=h.PASSWORD){super(e)}hasErrors(e,t={}){return super.hasErrors(e,{...t,message:t.message||this.message,[u.PATTERN]:t?.pattern||g.PASSWORD.CHAR8_ONE_OF_EACH})}},e.PasswordValidator=r.__decorate([de(u.PASSWORD),r.__metadata("design:paramtypes",[Object])],e.PasswordValidator),e.RequiredValidator=class extends Y{constructor(e=h.REQUIRED){super(e)}hasErrors(e,t={}){switch(typeof e){case"boolean":case"number":return void 0===e?this.getMessage(t.message||this.message):void 0;default:return e?void 0:this.getMessage(t.message||this.message)}}},e.RequiredValidator=r.__decorate([de(u.REQUIRED),r.__metadata("design:paramtypes",[String])],e.RequiredValidator),e.StepValidator=class extends Y{constructor(e=h.STEP){super(e,"number","string")}hasErrors(e,t){if(void 0!==e)return Number(e)%Number(t.step)!=0?this.getMessage(t.message||this.message,t.step):void 0}},e.StepValidator=r.__decorate([de(u.STEP),r.__metadata("design:paramtypes",[String])],e.StepValidator),e.TypeValidator=class extends Y{constructor(e=h.TYPE){super(e)}hasErrors(e,t){if(void 0===e)return;const{type:r,message:a,customTypes:s}=t;let i=s||r;return i=(Array.isArray(i)?i:[i]).map((e=>"string"==typeof e?e:("function"!=typeof e||e.name||(e=e()),e.name||e))),z(e,i)?void 0:this.getMessage(a||this.message,"string"==typeof i?i:Array.isArray(i)?i.join(", "):i,typeof e)}},e.TypeValidator=r.__decorate([de(u.TYPE),r.__metadata("design:paramtypes",[String])],e.TypeValidator),K.register({validator:e.TypeValidator,validationKey:e.ModelKeys.TYPE,save:!1}),e.URLValidator=class extends e.PatternValidator{constructor(e=h.URL){super(e)}hasErrors(e,t={}){return super.hasErrors(e,{...t,message:t.message||this.message,pattern:t.pattern||g.URL})}},e.URLValidator=r.__decorate([de(u.URL),r.__metadata("design:paramtypes",[String])],e.URLValidator);class Ce{constructor(e,t,r){this.parent=e,this.attr=t,this.declaredType=r,this.decorators=[]}decorate(...e){for(const t of e){if(this.decorators.includes(t))throw Error(`Decorator "${t}" has already been used`);this.decorators.push(t)}return this.parent}undecorate(...e){for(const t of e){const e=this.decorators.indexOf(t);if(0>e)throw Error(`Decorator "${t}" is not applied to ${this.attr}`);this.decorators.splice(e,1)}return this.parent}required(e){const t=Ce.asMeta(e),r="string"==typeof e?e:Ce.resolveMessage(t);return this.decorate(he(r))}min(e,t){const r=Ce.asMeta(e),a=r?.[u.MIN]??(r?void 0:e);if(void 0===a)throw Error(`Missing ${u.MIN} for ${this.attr+""}`);return this.decorate(ge(a,Ce.resolveMessage(r,t)))}max(e,t){const r=Ce.asMeta(e),a=r?.[u.MAX]??(r?void 0:e);if(void 0===a)throw Error(`Missing ${u.MAX} for ${this.attr+""}`);return this.decorate(pe(a,Ce.resolveMessage(r,t)))}step(e,t){const r=Ce.asMeta(e),a=r?.[u.STEP]??(r?void 0:e);if(void 0===a)throw Error(`Missing ${u.STEP} for ${this.attr+""}`);return this.decorate(me(a,Ce.resolveMessage(r,t)))}minlength(e,t){const r=Ce.asMeta(e),a=r?.[u.MIN_LENGTH]??(r?void 0:e);if(void 0===a)throw Error(`Missing ${u.MIN_LENGTH} for ${this.attr+""}`);return this.decorate(ye(a,Ce.resolveMessage(r,t)))}maxlength(e,t){const r=Ce.asMeta(e),a=r?.[u.MAX_LENGTH]??(r?void 0:e);if(void 0===a)throw Error(`Missing ${u.MAX_LENGTH} for ${this.attr+""}`);return this.decorate(Ee(a,Ce.resolveMessage(r,t)))}pattern(e,t){const r=Ce.asMeta(e),a=r?.[u.PATTERN]??(r?void 0:e),s=Ce.patternFromString(a)??/.*/;return this.decorate(Te(s,Ce.resolveMessage(r,t)))}email(e){const t=Ce.asMeta(e),r="string"==typeof e?e:Ce.resolveMessage(t);return this.decorate(be(r))}url(e){const t=Ce.asMeta(e),r="string"==typeof e?e:Ce.resolveMessage(t);return this.decorate(Me(r))}type(e,t){const r=Ce.asMeta(e),a=r?.customTypes??r?.type??(r?void 0:e);return this.decorate(Ae(a,Ce.resolveMessage(r,t)))}date(e,t){const r=Ce.asMeta(e),a=r?.[u.FORMAT]??(r?void 0:e);return this.decorate(Ne(a,Ce.resolveMessage(r,t)))}password(e,t){const r=Ce.asMeta(e),a=r?.[u.PATTERN]??(r?void 0:e),s=Ce.patternFromString(a);return this.decorate(Oe(s,Ce.resolveMessage(r,t)))}list(e,t,r){const a=Ce.asMeta(e),s=a?.clazz??(a?void 0:e),i=a?.type??t;return this.decorate(_e(s,i,Ce.resolveMessage(a,r)))}set(e,t){return Ce.isMetadataPayload(e)?this.list(e):this.list(e,"Set",t)}enum(e,t){const r=Ce.asMeta(e),a=r?.[u.ENUM]??(r?void 0:e);return this.decorate(we(a,Ce.resolveMessage(r,t)))}option(e,t){return this.enum(e,t)}static isMetadataPayload(e){return!(!e||e instanceof Date||e instanceof RegExp||Array.isArray(e)||"object"!=typeof e)}static asMeta(e){return Ce.isMetadataPayload(e)?e:void 0}static resolveMessage(e,t){return e?.message??t}static patternFromString(e){if(!e)return;if(e instanceof RegExp)return e;const t=e.match(/^\/(.+)\/([gimsuy]*)$/);return t?RegExp(t[1],t[2]):RegExp(e)}resolveComparison(e,t,r){const a=Ce.asMeta(e);return a?{target:a[t],options:{label:a.label,message:a.message}}:{target:e,options:r}}equals(e,t){const{target:r,options:a}=this.resolveComparison(e,u.EQUALS,t);return this.decorate(Se(r,a))}eq(e,t){return this.equals(e,t)}different(e,t){const{target:r,options:a}=this.resolveComparison(e,u.DIFF,t);return this.decorate(Re(r,a))}diff(e,t){return this.different(e,t)}lessThan(e,t){const{target:r,options:a}=this.resolveComparison(e,u.LESS_THAN,t);return this.decorate(ve(r,a))}lt(e,t){return this.lessThan(e,t)}lessThanOrEqual(e,t){const{target:r,options:a}=this.resolveComparison(e,u.LESS_THAN_OR_EQUAL,t);return this.decorate(Pe(r,a))}lte(e,t){return this.lessThanOrEqual(e,t)}greaterThan(e,t){const{target:r,options:a}=this.resolveComparison(e,u.GREATER_THAN,t);return this.decorate(Le(r,a))}gt(e,t){return this.greaterThan(e,t)}greaterThanOrEqual(e,t){const{target:r,options:a}=this.resolveComparison(e,u.GREATER_THAN_OR_EQUAL,t);return this.decorate(De(r,a))}gte(e,t){return this.greaterThanOrEqual(e,t)}description(e){return this.decorate(t.description(e))}build(e){const r=e.prototype,a=this.attr;Object.getOwnPropertyDescriptor(r,a)||Object.defineProperty(r,a,{configurable:!0,enumerable:!0,writable:!0,value:void 0}),this.declaredType&&Reflect.defineMetadata(t.DecorationKeys.DESIGN_TYPE,this.declaredType,r,a),t.prop()(r,a),this.decorators.forEach((e=>{try{e(r,a)}catch(e){throw Error(`Failed to apply decorator to property "${this.attr}": ${e}`)}}))}}class He{constructor(e,t,r){this.parent=e,this.attribute=t,this.collection=r}ofPrimitives(e,t){return this.attribute.list(e,this.collection,t),this.parent}ofModel(){const e=xe.builder(),t=e.build;let r;return this.attribute.list((()=>(r||(r=Reflect.apply(t,e,[])),r)),this.collection),e.build=new Proxy(t,{apply:(e,t,a)=>(r=Reflect.apply(e,t,a),this.parent)}),e}}class xe extends a.ObjectAccumulator{constructor(){super(...arguments),this.attributes=new Map}setName(e){return this._name=e,this}description(e){return this._description=e,this}attribute(e,t){const r=this.attributes.get(e);if(r){if(r.declaredType!==t)throw Error(`Attribute "${e+""}" already exists with a different type`);return r}const a=new Ce(this,e,t);return this.attributes.set(e,a),a}string(e){return this.attribute(e,String)}number(e){return this.attribute(e,Number)}date(e){return this.attribute(e,Date)}bigint(e){return this.attribute(e,BigInt)}instance(e,t){return this.attribute(t,e)}model(e){const t=new xe;return t.build=new Proxy(t.build,{apply:(t,r,a)=>{const s=Reflect.apply(t,r,a);return this.instance(s,e)}}),t}listOf(e,t="Array"){const r="Set"===t?Set:Array,a=this.attribute(e,r);return new He(this,a,t)}build(){if(!this._name)throw Error("name is required");const e=this._parent??ce;class r extends e{constructor(e){super(e)}}Object.defineProperty(r,"name",{value:this._name,writable:!1});for(const e of this.attributes.values())e.build(r);let a=Ue()(r);return this._description&&(a=t.description(this._description)(a)),a}static builder(){return new xe}static from(e,t){if(!e)throw Error("metadata is required");const r=xe.builder(),a=t??"GeneratedModel"+Date.now();r.setName(a);const s=e.properties||{},i=e.validation||{};for(const[e,t]of Object.entries(s)){const a=r.attribute(e,t||Object),s=i[e];if(s)for(const[e,t]of Object.entries(s)){const r=a[e];if("function"!=typeof r)try{const r=K.decoratorFromKey(e),s="function"==typeof r?r(t):r;a.decorate(s)}catch{}else r.call(a,t)}}return r.build()}}const Fe="##VERSION##",ze="##PACKAGE##";t.Metadata.registerLibrary(ze,Fe),e.ASYNC_META_KEY=T,e.AsyncValidator=class extends ${constructor(e=h.DEFAULT,...t){super(!0,e,...t)}},e.AttributeBuilder=Ce,e.COMPARISON_ERROR_MESSAGES=y,e.ComparisonValidationKeys=d,e.DAYS_OF_WEEK_NAMES=f,e.DEFAULT_ERROR_MESSAGES=h,e.DEFAULT_PATTERNS=g,e.DefaultHashingMethod=P,e.DefaultSerializationMethod=i,e.Hashing=L,e.JSONSerializer=n,e.MONTH_NAMES=l,e.Model=ce,e.ModelBuilder=xe,e.ModelErrorDefinition=c,e.ModelRegistryManager=oe,e.PACKAGE_NAME=ze,e.PathProxyEngine=I,e.ReservedModels=ae,e.Serialization=o,e.VALIDATION_PARENT_KEY=E,e.VERSION=Fe,e.Validation=K,e.ValidationKeys=u,e.Validator=Y,e.ValidatorRegistry=q,e.async=()=>e=>{Object.prototype.hasOwnProperty.call(e,T)||(e[T]=!0)},e.bindDateToString=M,e.bindModelPrototype=Ve,e.bulkModelRegister=(...e)=>{e.forEach((e=>{const t=e.constructor?e.constructor:e;ce.register(t,e.name)}))},e.checkType=x,e.checkTypes=F,e.construct=Ie,e.date=Ne,e.dateFromFormat=b,e.diff=Re,e.email=be,e.eq=Se,e.evaluateDesignTypes=z,e.findLastProtoBeforeObject=e=>{let t=Object.getPrototypeOf(e);if(t===Object.prototype)return e;for(;t!==Object.prototype;){if(t=Object.getPrototypeOf(t),t===Object.prototype)return t;if(Object.getPrototypeOf(t)===Object.prototype)return t}throw Error("Could not find proper prototype")},e.formatDate=O,e.getChildNestedPropsToIgnore=Z,e.gt=Le,e.gte=De,e.hashCode=R,e.hashObj=v,e.hashedBy=(r,...a)=>t.metadata(e.ModelKeys.HASHING,{algorithm:r,args:a}),e.innerValidationDecorator=fe,e.isEqual=S,e.isGreaterThan=H,e.isLessThan=C,e.isValidDate=A,e.isValidForGteOrLteComparison=U,e.jsTypes=se,e.list=_e,e.lt=ve,e.lte=Pe,e.max=pe,e.maxlength=Ee,e.min=ge,e.minlength=ye,e.model=Ue,e.modelBaseDecorator=je,e.option=we,e.parseDate=_,e.password=Oe,e.pattern=Te,e.regexpParser=ue,e.required=he,e.serializedBy=(r,...a)=>t.metadata(e.ModelKeys.SERIALIZATION,{serializer:r,args:a}),e.set=(e,t=h.LIST)=>_e(e,"Set",t),e.sf=m,e.step=me,e.stringFormat=p,e.toConditionalPromise=k,e.twoDigitPad=N,e.type=Ae,e.url=Me,e.validate=te,e.validateChildValue=W,e.validateDecorator=J,e.validateDecorators=ee,e.validationMetadata=le,e.validator=de,e.valueLength=G},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@decaf-ts/decoration"),require("tslib"),require("typed-object-accumulator")):"function"==typeof define&&define.amd?define(["exports","@decaf-ts/decoration","tslib","typed-object-accumulator"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["decorator-validation"]={},e.decafTsDecoration,e.tslib,e.typedObjectAccumulator);
1
+ var e,t;e=this,t=function(e,t,r,a){"use strict";var s;e.ModelKeys=void 0,(s=e.ModelKeys||(e.ModelKeys={})).DESCRIPTION="description",s.TYPE="design:type",s.MODEL="model",s.ANCHOR="__model",s.CONSTRUCTION="constructed-by",s.ATTRIBUTE="__attributes",s.HASHING="hashing",s.SERIALIZATION="serialization",s.DECORATORS="decorators",s.CONSTRUCTOR="__original";const i="json";class n{static{this.current=i}constructor(){}static get(e){if(e in this.cache)return this.cache[e];throw Error("No serialization method registered under "+e)}static register(e,t,r=!1){if(e in this.cache)throw Error(`Serialization method ${e} already registered`);this.cache[e]=new t,r&&(this.current=e)}static serialize(e,t,...r){return t?this.get(t).serialize(e,...r):this.get(this.current).serialize(e,...r)}static deserialize(e,t,...r){return t?this.get(t).deserialize(e,...r):this.get(this.current).deserialize(e,...r)}static setDefault(e){this.current=this.get(e)}}class o{constructor(e){for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&e[t]&&Object.defineProperty(this,t,{enumerable:!0,configurable:!1,value:e[t],writable:!1})}toString(){const e=this;return Object.keys(e).filter((t=>Object.prototype.hasOwnProperty.call(e,t)&&"function"!=typeof e[t])).reduce(((t,r)=>{let a=Object.keys(e[r]).reduce(((t,a)=>(t?t+="\n"+e[r][a]:t=e[r][a],t)),void 0);return a&&(a=`${r} - ${a}`,t?t+="\n"+a:t=a),t}),"")}}const c={EQUALS:"equals",DIFF:"different",LESS_THAN:"lessThan",LESS_THAN_OR_EQUAL:"lessThanOrEqual",GREATER_THAN:"greaterThan",GREATER_THAN_OR_EQUAL:"greaterThanOrEqual"},d={REFLECT:"validation",DATE:"date",EMAIL:"email",FORMAT:"format",LIST:"list",MAX:"max",MAX_LENGTH:"maxlength",MIN:"min",MIN_LENGTH:"minlength",PASSWORD:"password",PATTERN:"pattern",REQUIRED:"required",STEP:"step",TYPE:"type",UNIQUE:"unique",URL:"url",VALIDATOR:"validator",ENUM:"enum",...c},u=["January","February","March","April","May","June","July","August","September","October","November","December"],l=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],g={REQUIRED:"This field is required",MIN:"The minimum value is {0}",MAX:"The maximum value is {0}",MIN_LENGTH:"The minimum length is {0}",MAX_LENGTH:"The maximum length is {0}",PATTERN:"The value does not match the pattern",EMAIL:"The value is not a valid email",URL:"The value is not a valid URL",TYPE:"Invalid type. Expected {0}, received {1}",STEP:"Invalid value. Not a step of {0}",DATE:"Invalid value. not a valid Date",DEFAULT:"There is an Error",PASSWORD:"Must be at least 8 characters and contain one of number, lower and upper case letters, and special character (@$!%*?&_-.,)",LIST:"Invalid list of {0}",MODEL_NOT_FOUND:"No model registered under {0}",EQUALS:"This field must be equal to field {0}",DIFF:"This field must be different from field {0}",LESS_THAN:"This field must be less than field {0}",LESS_THAN_OR_EQUAL:"This field must be less than or equal to field {0}",GREATER_THAN:"This field must be greater than field {0}",GREATER_THAN_OR_EQUAL:"This field must be greater than or equal to field {0}",UNIQUE:"Duplicate found, this field must be unique.",ENUM:"Value is not allowed. Must be one of {0}"},f={EMAIL:/[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?/,URL:/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i,PASSWORD:{CHAR8_ONE_OF_EACH:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&_\-.,])[A-Za-z\d@$!%*?&_\-.,]{8,}$/g},asd:"^(?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\xa1-\uffff][a-z0-9\xa1-\uffff_-]{0,62})?[a-z0-9\xa1-\uffff]\\.)+(?:[a-z\xa1-\uffff]{2,}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?$"};function h(e,...t){return e.replace(/{(\d+)}/g,((e,r)=>void 0!==t[r]?t[r].toString():"undefined"))}const p=h,y={INVALID_PATH:"Invalid path argument. Expected non-empty string but received: '{0}'",CONTEXT_NOT_OBJECT_COMPARISON:"Unable to access parent at level {0} for path '{1}': current context is not an object",PROPERTY_INVALID:"Failed to resolve path {0}: property '{1}' is invalid or does not exist.",PROPERTY_NOT_EXIST:"Failed to resolve path: property '{0}' does not exist.",UNSUPPORTED_TYPES_COMPARISON:"Unsupported types for comparison: '{0}' and '{1}'",NULL_OR_UNDEFINED_COMPARISON:"Comparison failed due to null or undefined value",INVALID_DATE_COMPARISON:"Invalid Date objects are not comparable",TYPE_MISMATCH_COMPARISON:"Cannot compare values of different types: {0} and {1}.",NAN_COMPARISON:"Comparison not supported for NaN values"},m=Symbol("_parent"),E=Symbol("isAsync"),T=e=>null===e?"null":e instanceof Date?"Date":Number.isNaN(e)?"NaN":e===1/0?"Infinity":e===-1/0?"-Infinity":Array.isArray(e)?"array":typeof e,M=e=>void 0===e||e instanceof Date||"bigint"==typeof e||"number"==typeof e&&Number.isFinite(e);function b(e,t){if(M(e)&&M(t))return!0;throw new TypeError(p(y.UNSUPPORTED_TYPES_COMPARISON,T(e),T(t)))}function A(e,t){if([null,void 0].includes(e)||[null,void 0].includes(t))throw Error(y.NULL_OR_UNDEFINED_COMPARISON);const r=typeof e,a=typeof t;if(r!==a){if("bigint"===r&&"number"===a)return t>Number(e);if("number"===r&&"bigint"===a)return Number(t)>e;throw new TypeError(p(y.TYPE_MISMATCH_COMPARISON,r,a))}if("number"===r&&"number"===a||"bigint"===r&&"bigint"===a){if(Number.isNaN(e)||Number.isNaN(t))throw new TypeError(y.NAN_COMPARISON);return t>e}if(e instanceof Date&&t instanceof Date){if(isNaN(e.getTime())||isNaN(t.getTime()))throw new TypeError(y.INVALID_DATE_COMPARISON);return e.getTime()<t.getTime()}throw new TypeError(p(y.UNSUPPORTED_TYPES_COMPARISON,T(e),T(t)))}function N(e,t){if([null,void 0].includes(e)||[null,void 0].includes(t))throw Error(y.NULL_OR_UNDEFINED_COMPARISON);const r=typeof e,a=typeof t;if(r!==a){if("bigint"===r&&"number"===a)return Number(e)>t;if("number"===r&&"bigint"===a)return e>Number(t);throw Error(p(y.TYPE_MISMATCH_COMPARISON,r,a))}if("number"===r&&"number"===a||"bigint"===r&&"bigint"===a){if(Number.isNaN(e)||Number.isNaN(t))throw new TypeError(y.NAN_COMPARISON);return e>t}if(e instanceof Date&&t instanceof Date){if(isNaN(e.getTime())||isNaN(t.getTime()))throw new TypeError(y.INVALID_DATE_COMPARISON);return e.getTime()>t.getTime()}throw new TypeError(p(y.UNSUPPORTED_TYPES_COMPARISON,T(e),T(t)))}function O(e,t){return typeof e===t.toLowerCase()||void 0!==e&&"object"==typeof e&&e.constructor&&e.constructor.name.toLowerCase()===t.toLowerCase()}function _(e,t){return!t.every((t=>!O(e,t)))}function S(e,t){switch(typeof t){case"string":return O(e,t);case"object":return!Array.isArray(t)||_(e,t);case"function":return!t.name||"Object"===t.name||O(e,t.name);default:return!0}}function R(e){return e instanceof Set||e instanceof Map?e.size:e.length}class v{constructor(e,t=g.DEFAULT,...r){this.async=e,this.message=t,r.length&&(this.acceptedTypes=r),this.acceptedTypes&&(this.hasErrors=this.checkTypeAndHasErrors(this.hasErrors.bind(this)))}getMessage(e,...t){return p(e,...t)}checkTypeAndHasErrors(e){return function(t,r,a,...s){return void 0!==t&&this.acceptedTypes?_(t,this.acceptedTypes)?e(t,r,a,...s):this.getMessage(g.TYPE,this.acceptedTypes.join(", "),"number"!=typeof t?typeof t:isNaN(t)?"NaN":typeof t):e(t,r,a,...s)}.bind(this)}static isValidator(e){return e.constructor&&!!e.hasErrors}}class P extends v{constructor(e=g.DEFAULT,...t){super(!1,e,...t)}}class L{constructor(...e){this.cache={},this.customKeyCache={},this.register(...e)}getCustomKeys(){return Object.assign({},this.customKeyCache)}getKeys(){return Object.keys(this.cache)}get(e){if(!(e in this.cache))return;const t=this.cache[e];if(P.isValidator(t))return t;const r=new(t.default||t);return this.cache[e]=r,r}register(...e){e.forEach((e=>{if(P.isValidator(e)){if(e.validationKey in this.cache)return;this.cache[e.validationKey]=e}else{const{validationKey:t,validator:r,save:a}=e;if(t in this.cache)return;if(this.cache[t]=r,!a)return;const s={};s[t.toUpperCase()]=t,this.customKeyCache=Object.assign({},this.customKeyCache,s)}}))}}class D{static{this.actingValidatorRegistry=void 0}constructor(){}static setRegistry(e,t){t&&D.actingValidatorRegistry&&D.actingValidatorRegistry.getKeys().forEach((r=>{const a=e.get(r);a&&e.register(t(a))})),D.actingValidatorRegistry=e}static getRegistry(){return D.actingValidatorRegistry||(D.actingValidatorRegistry=new L),D.actingValidatorRegistry}static get(e){return D.getRegistry().get(e)}static register(...e){return D.getRegistry().register(...e)}static key(e){return d.REFLECT+e}static keys(){return this.getRegistry().getKeys()}static registerDecorator(r,a){const s=t.Metadata.innerGet(Symbol.for(e.ModelKeys.DECORATORS),t.Metadata.key(d.REFLECT,r));s?.[r]||t.Metadata.set(e.ModelKeys.DECORATORS,t.Metadata.key(d.REFLECT,r),a)}static decoratorFromKey(r){try{return t.Metadata.innerGet(Symbol.for(e.ModelKeys.DECORATORS),t.Metadata.key(d.REFLECT,r))}catch(e){throw Error(`No decorator registered under ${r}: ${e}`)}}}const w=e=>e[m],I=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw Error(p(y.PROPERTY_NOT_EXIST,t));return e[t]};class V{static create(e,t){const{getValue:r,getParent:a,ignoreUndefined:s,ignoreNull:i}={getParent:w,getValue:I,ignoreNull:!1,ignoreUndefined:!1,...t};return new Proxy({},{get:(t,n)=>"getValueFromPath"===n?t=>{const n=V.parsePath(t);let o=e;for(let e=0;e<n.length;e++){const c=n[e];if(".."!==c){if(o=r(o,c),!s&&void 0===o)throw Error(p(y.PROPERTY_INVALID,t,c));if(!i&&null===o)throw Error(p(y.PROPERTY_INVALID,t,c))}else{const r=a(o);if(!r||"object"!=typeof r)throw Error(p(y.CONTEXT_NOT_OBJECT_COMPARISON,e+1,t));o=r}}return o}:t[n]})}static parsePath(e){if("string"!=typeof e||!e.trim())throw Error(p(y.INVALID_PATH,e));return e.match(/(\.\.|[^/.]+)/g)||[]}}function j(e,t){return t?Promise.resolve(e):e}var U;e.Primitives=void 0,(U=e.Primitives||(e.Primitives={})).STRING="string",U.NUMBER="number",U.BOOLEAN="boolean",U.BIGINT="bigint";const C={STRING:String,OBJECT:Object,NUMBER:Number,BOOLEAN:Boolean,BIGINT:BigInt,DATE:Date},H=["string","array","number","boolean","symbol","function","object","undefined","null","bigint"];function x(...e){return t.apply((t=>(e.forEach((e=>{D.register({validator:t,validationKey:e,save:!0})})),t)),t.metadata(d.VALIDATOR,e))}function F(e,t,...r){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return e===t;if(typeof e!=typeof t)return!1;if(Number.isNaN(e)&&Number.isNaN(t))return!0;if("object"!=typeof e)return e===t;if(e instanceof Date&&t instanceof Date)return!(!isNaN(e.getTime())||!isNaN(t.getTime()))||e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.toString()===t.toString();if(e instanceof Error&&t instanceof Error)return e.name===t.name&&e.message===t.message;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a++)if(!F(e[a],t[a],...r))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[a,s]of e)if(!t.has(a)||!F(s,t.get(a),...r))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(e.byteLength!==t.byteLength)return!1;if(e.byteOffset!==t.byteOffset)return!1;if(e.buffer.byteLength!==t.buffer.byteLength)return!1;const r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);for(let e=0;e<r.length;e++)if(r[e]!==a[e])return!1;return!0}const a=Object.keys(e).filter((e=>!r.includes(e))),s=Object.keys(t).filter((e=>!r.includes(e)));if(a.length!==s.length)return!1;for(const i of a){if(!s.includes(i))return!1;if(!F(e[i],t[i],...r))return!1}const i=Object.getOwnPropertySymbols(e).filter((e=>!r.includes(e.toString()))),n=Object.getOwnPropertySymbols(t).filter((e=>!r.includes(e.toString())));if(i.length!==n.length)return!1;for(const a of i){if(!n.includes(a))return!1;if(!F(e[a],t[a],...r))return!1}return Object.getPrototypeOf(e)===Object.getPrototypeOf(t)}e.DateValidator=class extends P{constructor(e=g.DATE){super(e,Number.name,Date.name,String.name)}hasErrors(e,t={}){if(void 0!==e&&("string"==typeof e&&(e=new Date(e)),Number.isNaN(e.getDate()))){const{message:e=""}=t;return this.getMessage(e||this.message)}}},e.DateValidator=r.__decorate([x(d.DATE),r.__metadata("design:paramtypes",[String])],e.DateValidator),e.DiffValidator=class extends P{constructor(e=g.DIFF){super(e)}hasErrors(e,t,r){let a;try{a=r.getValueFromPath(t[d.DIFF])}catch(e){return this.getMessage(e.message||this.message)}return F(e,a)?this.getMessage(t.message||this.message,t.label||t[d.DIFF]):void 0}},e.DiffValidator=r.__decorate([x(d.DIFF),r.__metadata("design:paramtypes",[String])],e.DiffValidator);const z=RegExp("^/(.+)/([gimus]*)$");function G(e,t){let r=t;r.match(/hh/)?r=r.replace("hh","(?<hour>\\d{2})"):r.match(/h/)?r=r.replace("h","(?<hour>\\d{1,2})"):r.match(/HH/)?r=r.replace("HH","(?<hour>\\d{2})"):r.match(/H/)&&(r=r.replace("H","(?<hour>\\d{1,2})")),r.match(/mm/)?r=r.replace("mm","(?<minutes>\\d{2})"):r.match(/m/)&&(r=r.replace("m","(?<minutes>\\d{1,2})")),r.match(/ss/)?r=r.replace("ss","(?<seconds>\\d{2})"):r.match(/s/)&&(r=r.replace("s","(?<seconds>\\d{1,2})")),r.match(/dd/)?r=r.replace("dd","(?<day>\\d{2})"):r.match(/d/)&&(r=r.replace("d","(?<day>\\d{1,2})")),r.match(/EEEE/)?r=r.replace("EEEE","(?<dayofweek>\\w+)"):r.match(/EEEE/)&&(r=r.replace("EEE","(?<dayofweek>\\w+)")),r.match(/yyyy/)?r=r.replace("yyyy","(?<year>\\d{4})"):r.match(/yy/)&&(r=r.replace("yy","(?<year>\\d{2})")),r.match(/MMMM/)?r=r.replace("MMMM","(?<monthname>\\w+)"):r.match(/MMM/)&&(r=r.replace("MMM","(?<monthnamesmall>\\w+)")),r.match(/MM/)?r=r.replace("MM","(?<month>\\d{2})"):r.match(/M/)&&(r=r.replace("M","(?<month>\\d{1,2})")),r=r.replace("S","(?<milis>\\d{1,3})").replace("aaa","(?<ampm>\\w{2})");const a=RegExp(r,"g").exec(e);if(!a||!a.groups)return new Date(e);const s=e=>{if(!e)return 0;const t=parseInt(e);return isNaN(t)?0:t},i=s(a.groups.year),n=s(a.groups.day),o=a.groups.ampm;let c=s(a.groups.hour);o&&(c="PM"===o?c+12:c);const d=s(a.groups.minutes),l=s(a.groups.seconds),g=s(a.groups.milis),f=a.groups.monthname,h=a.groups.monthnamesmall;let p=a.groups.month;if(f)p=u.indexOf(f);else if(h){const t=u.find((e=>e.toLowerCase().startsWith(h.toLowerCase())));if(!t)return new Date(e);p=u.indexOf(t)}else p=s(""+p);return new Date(i,p-1,n,c,d,l,g)}function $(e,t){if(e)return Object.defineProperty(e,"toISOString",{enumerable:!1,configurable:!1,value:new Proxy(e.toISOString,{apply:(e,r)=>K(r,t)})}),Object.defineProperty(e,"toString",{enumerable:!1,configurable:!1,value:new Proxy(e.toISOString,{apply:(e,r)=>K(r,t)})}),e}function Y(e){return e&&"[object Date]"===Object.prototype.toString.call(e)&&!Number.isNaN(e)}function q(e){return 10>e?"0"+e:e.toString()}function K(e,t="yyyy/MM/dd"){const r=e.getDate(),a=e.getMonth(),s=e.getFullYear(),i=e.getHours(),n=e.getMinutes(),o=e.getSeconds(),c=e.getMilliseconds(),d=i%12,g=q(d),f=q(i),h=q(n),p=q(o),y=12>i?"AM":"PM",m=l[e.getDay()],E=m.substr(0,3),T=q(r),M=a+1,b=q(M),A=u[a],N=A.substr(0,3),O=s+"",_=O.substr(2,2);return(t=t.replace("hh",g).replace("h",d.toString()).replace("HH",f).replace("H",i.toString()).replace("mm",h).replace("m",n.toString()).replace("ss",p).replace("s",o.toString()).replace("S",c.toString()).replace("dd",T).replace("d",r.toString()).replace("EEEE",m).replace("EEE",E).replace("yyyy",O).replace("yy",_).replace("aaa",y)).indexOf("MMM")>-1?t.replace("MMMM",A).replace("MMM",N):t.replace("MM",b).replace("M",M.toString())}function k(e,t){let r;if(t){if(t instanceof Date)try{r=G(K(t,e),e)}catch(r){throw Error(p("Could not convert date {0} to format: {1}",t.toString(),e))}else if("string"==typeof t)r=G(t,e);else if("number"==typeof t)r=G(K(new Date(t),e),e);else{if(!Y(t))throw Error("Invalid value provided "+t);try{r=G(K(new Date(t),e),e)}catch(r){throw Error(p("Could not convert date {0} to format: {1}",t,e))}}return $(r,e)}}function Q(e,r,a){return t.apply(t.propMetadata(r,a))}function B(e,t,r){return D.registerDecorator(t,e),(e,a)=>Q(0,`${d.REFLECT}.${a}.${t}`,r)(e,a)}function X(e=g.REQUIRED){const r=d.REQUIRED,a={message:e,description:"defines the attribute as required",async:!1};return t.Decoration.for(r).define({decorator:B,args:[X,r,a]}).apply()}function W(e,r=g.MIN){const a=d.MIN,s={[d.MIN]:e,message:r,description:`defines the max value of the attribute as ${e} (applies to numbers or Dates)`,async:!1};return t.Decoration.for(a).define({decorator:B,args:[W,a,s]}).apply()}function Z(e,r=g.MAX){const a=d.MAX,s={[d.MAX]:e,message:r,description:`defines the max value of the attribute as ${e} (applies to numbers or Dates)`,async:!1};return t.Decoration.for(a).define({decorator:B,args:[Z,a,s]}).apply()}function J(e,r=g.STEP){const a=d.STEP,s={[d.STEP]:e,message:r,description:"defines the step of the attribute as "+e,async:!1};return t.Decoration.for(a).define({decorator:B,args:[J,a,s]}).apply()}function ee(e,r=g.MIN_LENGTH){const a=d.MIN_LENGTH,s={[d.MIN_LENGTH]:e,message:r,description:`defines the min length of the attribute as ${e} (applies to strings or lists)`,async:!1};return t.Decoration.for(a).define({decorator:B,args:[ee,a,s]}).apply()}function te(e,r=g.MAX_LENGTH){const a=d.MAX_LENGTH,s={[d.MAX_LENGTH]:e,message:r,description:`defines the max length of the attribute as ${e} (applies to strings or lists)`,async:!1};return t.Decoration.for(a).define({decorator:B,args:[te,a,s]}).apply()}function re(e,r=g.PATTERN){const a=d.PATTERN,s={[d.PATTERN]:"string"==typeof e?e:e.toString(),message:r,description:`assigns the ${"string"===e?e:e.toString()} pattern to the attribute`,async:!1};return t.Decoration.for(a).define({decorator:B,args:[re,a,s]}).apply()}function ae(e=g.EMAIL){const r=d.EMAIL,a={[d.PATTERN]:f.EMAIL.toString(),message:e,description:"marks the attribute as an email",async:!1};return t.Decoration.for(r).define({decorator:B,args:[ae,r,a]}).apply()}function se(e=g.URL){const r=d.URL,a={[d.PATTERN]:f.URL.toString(),message:e,description:"marks the attribute as an url",async:!1};return t.Decoration.for(r).define({decorator:B,args:[se,r,a]}).apply()}function ie(e,r=g.TYPE){const a=d.TYPE,s={customTypes:e,message:r,description:"defines the accepted types for the attribute",async:!1};return t.Decoration.for(a).define({decorator:B,args:[ie,a,s]}).apply()}function ne(e="dd/MM/yyyy",r=g.DATE){const a=d.DATE;return t.Decoration.for(a).define({decorator:function(e,t){const r={[d.FORMAT]:e,message:t,description:"defines the attribute as a date with the format "+e,async:!1};return function(t,s){const i=new WeakMap;return Object.defineProperty(t,s,{configurable:!0,set(t){const r=Object.getOwnPropertyDescriptor(this,s);r&&!r.configurable||Object.defineProperty(this,s,{enumerable:!0,configurable:!1,get:()=>i.get(this),set:t=>{let r;try{r=k(e,t),i.set(this,r)}catch(e){}}}),this[s]=t},get(){return i.get(this)}}),B(ne,a,r)(t,s)}},args:[e,r]}).apply()}function oe(e=f.PASSWORD.CHAR8_ONE_OF_EACH,r=g.PASSWORD){const a=d.PASSWORD,s={[d.PATTERN]:e.toString(),message:r,description:"attribute as a password",async:!1};return t.Decoration.for(a).define({decorator:B,args:[oe,a,s]}).apply()}function ce(e,r="Array",a=g.LIST){const s=d.LIST,i={clazz:Array.isArray(e)?e:[e],type:r,message:a,async:!1,description:`defines the attribute as a ${r} of ${e.name}`};return t.Decoration.for(s).define({decorator:B,args:[ce,s,i]}).apply()}function de(e,t){return B(de,d.EQUALS,{label:t?.label||e,message:t?.message||g.EQUALS,[d.EQUALS]:e,description:"defines attribute as equal to "+e,async:!1})}function ue(e,t){return B(ue,d.DIFF,{label:t?.label||e,message:t?.message||g.DIFF,[d.DIFF]:e,description:"defines attribute as different to "+e,async:!1})}function le(e,t){return B(le,d.LESS_THAN,{label:t?.label||e,message:t?.message||g.LESS_THAN,[d.LESS_THAN]:e,description:"defines attribute as less than to "+e,async:!1})}function ge(e,t){return B(ge,d.LESS_THAN_OR_EQUAL,{label:t?.label||e,message:t?.message||g.LESS_THAN_OR_EQUAL,[d.LESS_THAN_OR_EQUAL]:e,description:"defines attribute as less or equal to "+e,async:!1})}function fe(e,t){return B(fe,d.GREATER_THAN,{label:t?.label||e,message:t?.message||g.GREATER_THAN,[d.GREATER_THAN]:e,description:"defines attribute as greater than "+e,async:!1})}function he(e,t){return B(he,d.GREATER_THAN_OR_EQUAL,{label:t?.label||e,message:t?.message||g.GREATER_THAN_OR_EQUAL,[d.GREATER_THAN_OR_EQUAL]:e,description:"defines attribute as greater or equal to "+e,async:!1})}function pe(e,r=g.ENUM){const a=d.ENUM,s={[d.ENUM]:e,message:r,description:"defines a list or an object of accepted values for the attribute",async:!1};return t.Decoration.for(a).define({decorator:B,args:[pe,a,s]}).apply()}let ye,me;e.PatternValidator=class extends P{constructor(e=g.PATTERN){super(e,"string")}getPattern(e){if(!z.test(e))return RegExp(e);const t=e.match(z);return RegExp(t[1],t[2])}hasErrors(e,t){if(!e)return;let{pattern:r}=t;if(!r)throw Error("Missing Pattern");return r="string"==typeof r?this.getPattern(r):r,r.lastIndex=0,r.test(e)?void 0:this.getMessage(t.message||this.message)}},e.PatternValidator=r.__decorate([x(d.PATTERN),r.__metadata("design:paramtypes",[String])],e.PatternValidator),e.EmailValidator=class extends e.PatternValidator{constructor(e=g.EMAIL){super(e)}hasErrors(e,t={}){return super.hasErrors(e,{...t,message:t.message||this.message,pattern:t?.pattern||f.EMAIL})}},e.EmailValidator=r.__decorate([x(d.EMAIL),r.__metadata("design:paramtypes",[String])],e.EmailValidator),e.EqualsValidator=class extends P{constructor(e=g.EQUALS){super(e)}hasErrors(e,t,r){let a;try{a=r.getValueFromPath(t[d.EQUALS])}catch(e){return this.getMessage(e.message||this.message)}return F(e,a)?void 0:this.getMessage(t.message||this.message,t.label||t[d.EQUALS])}},e.EqualsValidator=r.__decorate([x(d.EQUALS),r.__metadata("design:paramtypes",[String])],e.EqualsValidator),e.GreaterThanValidator=class extends P{constructor(e=g.GREATER_THAN){super(e)}hasErrors(e,t,r){let a;try{a=r.getValueFromPath(t[d.GREATER_THAN])}catch(e){return this.getMessage(e.message||this.message)}try{if(!N(e,a))throw Error(t.message||this.message)}catch(e){return this.getMessage(e.message,t.label||t[d.GREATER_THAN])}}},e.GreaterThanValidator=r.__decorate([x(d.GREATER_THAN),r.__metadata("design:paramtypes",[String])],e.GreaterThanValidator),e.GreaterThanOrEqualValidator=class extends P{constructor(e=g.GREATER_THAN_OR_EQUAL){super(e)}hasErrors(e,t,r){let a;try{a=r.getValueFromPath(t[d.GREATER_THAN_OR_EQUAL])}catch(e){return this.getMessage(e.message||this.message)}try{if(b(e,a)&&F(e,a)||N(e,a))return;throw Error(t.message||this.message)}catch(e){return this.getMessage(e.message,t.label||t[d.GREATER_THAN_OR_EQUAL])}}},e.GreaterThanOrEqualValidator=r.__decorate([x(d.GREATER_THAN_OR_EQUAL),r.__metadata("design:paramtypes",[String])],e.GreaterThanOrEqualValidator),e.LessThanValidator=class extends P{constructor(e=g.LESS_THAN){super(e)}hasErrors(e,t,r){let a;try{a=r.getValueFromPath(t[d.LESS_THAN])}catch(e){return this.getMessage(e.message||this.message)}try{if(!A(e,a))throw Error(t.message||this.message)}catch(e){return this.getMessage(e.message,t.label||t[d.LESS_THAN])}}},e.LessThanValidator=r.__decorate([x(d.LESS_THAN),r.__metadata("design:paramtypes",[String])],e.LessThanValidator),e.LessThanOrEqualValidator=class extends P{constructor(e=g.LESS_THAN_OR_EQUAL){super(e)}hasErrors(e,t,r){let a;try{a=r.getValueFromPath(t[d.LESS_THAN_OR_EQUAL])}catch(e){return this.getMessage(e.message||this.message)}try{if(b(e,a)&&F(e,a)||A(e,a))return;throw Error(t.message||this.message)}catch(e){return this.getMessage(e.message,t.label||t[d.LESS_THAN_OR_EQUAL])}}},e.LessThanOrEqualValidator=r.__decorate([x(d.LESS_THAN_OR_EQUAL),r.__metadata("design:paramtypes",[String])],e.LessThanOrEqualValidator),e.ListValidator=class extends P{constructor(e=g.LIST){super(e,Array.name,Set.name)}hasErrors(e,t){if(!e||(Array.isArray(e)?!e.length:!e.size))return;const r=(Array.isArray(t.clazz)?t.clazz:[t.clazz]).map((e=>"string"==typeof e?e:e?.name||"function"!=typeof e?e?.name:e().name));let a,s=!0;for(let t=0;t<(Array.isArray(e)?e.length:e.size);t++)switch(a=[...e][t],typeof a){case"object":case"function":s=r.includes((a??{}).constructor?.name);break;default:s=r.some((e=>typeof a===e?.toLowerCase()))}return s?void 0:this.getMessage(t.message||this.message,r)}},e.ListValidator=r.__decorate([x(d.LIST),r.__metadata("design:paramtypes",[String])],e.ListValidator),e.MaxLengthValidator=class extends P{constructor(e=g.MAX_LENGTH){super(e,String.name,Array.name,Set.name,Map.name)}hasErrors(e,t){if(void 0!==e)return R(e)>t.maxlength?this.getMessage(t.message||this.message,t.maxlength):void 0}},e.MaxLengthValidator=r.__decorate([x(d.MAX_LENGTH),r.__metadata("design:paramtypes",[String])],e.MaxLengthValidator),e.MaxValidator=class extends P{constructor(e=g.MAX){super(e,Number.name,Date.name,String.name)}hasErrors(e,t){if(void 0===e)return;let{max:r}=t;if(e instanceof Date&&!(r instanceof Date)&&(r=new Date(r),Number.isNaN(r.getDate())))throw Error("Invalid Max param defined");return e>r?this.getMessage(t.message||this.message,r):void 0}},e.MaxValidator=r.__decorate([x(d.MAX),r.__metadata("design:paramtypes",[String])],e.MaxValidator),e.MinLengthValidator=class extends P{constructor(e=g.MIN_LENGTH){super(e,String.name,Array.name,Set.name,Map.name)}hasErrors(e,t){if(void 0!==e)return R(e)<t.minlength?this.getMessage(t.message||this.message,t.minlength):void 0}},e.MinLengthValidator=r.__decorate([x(d.MIN_LENGTH),r.__metadata("design:paramtypes",[String])],e.MinLengthValidator),e.MinValidator=class extends P{constructor(e=g.MIN){super(e,Number.name,Date.name,String.name)}hasErrors(e,t){if(void 0===e)return;let{min:r}=t;if(e instanceof Date&&!(r instanceof Date)&&(r=new Date(r),Number.isNaN(r.getDate())))throw Error("Invalid Min param defined");return r>e?this.getMessage(t.message||this.message,r):void 0}},e.MinValidator=r.__decorate([x(d.MIN),r.__metadata("design:paramtypes",[String])],e.MinValidator),e.OptionValidator=class extends P{constructor(e=g.ENUM){super(e)}hasErrors(e,t){if(void 0!==e){if(Array.isArray(t.enum))return t.enum.includes(e)?void 0:this.getMessage(t.message||this.message,t.enum);if("object"==typeof t.enum){const r=Object.keys(t.enum);for(const a of r)if(t.enum[a]===e)return;return this.getMessage(t.message||this.message,Object.values(t.enum))}}}},e.OptionValidator=r.__decorate([x(d.ENUM),r.__metadata("design:paramtypes",[String])],e.OptionValidator),e.PasswordValidator=class extends e.PatternValidator{constructor(e=g.PASSWORD){super(e)}hasErrors(e,t={}){return super.hasErrors(e,{...t,message:t.message||this.message,[d.PATTERN]:t?.pattern||f.PASSWORD.CHAR8_ONE_OF_EACH})}},e.PasswordValidator=r.__decorate([x(d.PASSWORD),r.__metadata("design:paramtypes",[Object])],e.PasswordValidator),e.RequiredValidator=class extends P{constructor(e=g.REQUIRED){super(e)}hasErrors(e,t={}){switch(typeof e){case"boolean":case"number":return void 0===e?this.getMessage(t.message||this.message):void 0;default:return e?void 0:this.getMessage(t.message||this.message)}}},e.RequiredValidator=r.__decorate([x(d.REQUIRED),r.__metadata("design:paramtypes",[String])],e.RequiredValidator),e.StepValidator=class extends P{constructor(e=g.STEP){super(e,"number","string")}hasErrors(e,t){if(void 0!==e)return Number(e)%Number(t.step)!=0?this.getMessage(t.message||this.message,t.step):void 0}},e.StepValidator=r.__decorate([x(d.STEP),r.__metadata("design:paramtypes",[String])],e.StepValidator),e.TypeValidator=class extends P{constructor(e=g.TYPE){super(e)}hasErrors(e,t){if(void 0===e)return;const{type:r,message:a,customTypes:s}=t;let i=s||r;return i=(Array.isArray(i)?i:[i]).map((e=>"string"==typeof e?e:("function"!=typeof e||e.name||(e=e()),e.name||e))),S(e,i)?void 0:this.getMessage(a||this.message,"string"==typeof i?i:Array.isArray(i)?i.join(", "):i,typeof e)}},e.TypeValidator=r.__decorate([x(d.TYPE),r.__metadata("design:paramtypes",[String])],e.TypeValidator),D.register({validator:e.TypeValidator,validationKey:e.ModelKeys.TYPE,save:!1}),e.URLValidator=class extends e.PatternValidator{constructor(e=g.URL){super(e)}hasErrors(e,t={}){return super.hasErrors(e,{...t,message:t.message||this.message,pattern:t.pattern||f.URL})}},e.URLValidator=r.__decorate([x(d.URL),r.__metadata("design:paramtypes",[String])],e.URLValidator);class Ee{constructor(e=t.Metadata.isModel){this.cache={},this.testFunction=e}register(e,t){if("function"!=typeof e)throw Error("Model registering failed. Missing Class name or constructor");t=t||e.name,this.cache[t]=e}get(e){try{return this.cache[e]}catch(e){return}}build(e={},r){if(!r&&!this.testFunction(e))throw Error("Provided obj is not a Model object");const a=r||t.Metadata.modelName(e.constructor);if(!(a in this.cache))throw Error(`Provided class ${a} is not a registered Model object`);return new this.cache[a](e)}static setBuilder(e){ye=e}static getBuilder(){return ye||Ee.fromModel}static fromModel(e,r){let a;r||(r={});const s=t.Metadata.getAttributes(e),i=Object.getPrototypeOf(e);let n;for(const o of s){try{e[o]=r[o]??e[o]??void 0}catch(e){if(n=Object.getOwnPropertyDescriptor(i,o),!n||n.writable)throw Error(`Unable to write property ${o} to model: ${e}`)}if("object"!=typeof e[o])continue;const s=t.Metadata.isPropertyModel(e,o);if(s){try{e[o]=Ee.getRegistry().build(e[o],"string"==typeof s?s:void 0)}catch(e){}continue}if(a=t.Metadata.allowedTypes(e.constructor,o),!a||!a.length)throw Error("failed to find decorators for property "+o);const c=a.map((e=>"function"!=typeof e||e.name?e:e())),u=Object.values(C);c.forEach((r=>{if(!u.includes(r))try{switch(r.name){case"Array":case"Set":{const a=t.Metadata.validationFor(e.constructor,o);if(!a||!a[d.LIST])break;const s=a[d.LIST].clazz.map((e=>"function"!=typeof e||e.name?e:e())).find((e=>!H.includes(e.name)));if("Array"===r.name&&(e[o]=e[o].map((e=>["object","function"].includes(typeof e)&&s?Ee.getRegistry().build(e,s.name):e))),"Set"===r.name){const t=new Set;for(const r of e[o])["object","function"].includes(typeof r)&&s?t.add(Ee.getRegistry().build(r,s.name)):t.add(r);e[o]=t}break}default:void 0!==e[o]&&Ee.getRegistry().get(r.name)&&(e[o]=Ee.getRegistry().build(e[o],r.name))}}catch(e){}}))}return e}static getRegistry(){return me||(me=new Ee),me}static setRegistry(e){me=e}}function Te(e,t,r){Object.hasOwnProperty.call(e,t)||(e[t]=r)}function Me(e,t){Object.hasOwnProperty.call(e,t)&&delete e[t]}function be(e,t,r,...a){t&&Te(e,m,t),Te(e,E,!!r);const s=e.hasErrors(...a);return Me(e,m),Me(e,E),s}function Ae(e,t,r,a,s,...i){let n,c=!1;for(const u of a){const a=Ee.getRegistry().get(u);if(a||(n=new o({[e]:{[d.TYPE]:"Unable to verify type consistency, missing model registry for "+u}})),t instanceof a){c=!0,n=be(t,r,s,...i);break}}return c?n:n||new o({[e]:{[d.TYPE]:"Value must be an instance of one of the expected types: "+a.join(", ")}})}function Ne(e,...t){return t?.map((t=>("string"==typeof t&&t?.startsWith(e+".")&&(t=t.replace(e+".","")),t)))}function Oe(t,r,a,s){const i=D.get(a.key);if(!i)throw Error("Missing validator for "+a.key);if(!s&&a.async)return;const n=a.key===e.ModelKeys.TYPE?[a]:a||{},o=V.create(t,{ignoreUndefined:!0,ignoreNull:!0}),c=a.key===e.ModelKeys.TYPE?n[0]:n;return j(i.hasErrors(r,c,o),s)}function _e(r,a,s,i,n,...o){const c={};for(const u in i){const l={...i[u],key:u};if(!n&&l.async)continue;let g=Oe(r,s,l,n);if(u===d.LIST&&(!g||n)){const e=s instanceof Set?[...s]:s;if(e&&e.length>0){let s=l.class||l.clazz||l.customTypes;s=(Array.isArray(s)?s:[s]).map((e=>(e="function"!=typeof e||e.name?e:e()).name?e.name:e));const i=[s].flat().map((e=>(e+"").toLowerCase())),c=e.map((e=>{if(t.Metadata.isModel(e)){const t=Ne(a,...o);return Ae(a,e,r,s.flat(),!!n,...t)}return i.includes(typeof e)?void 0:"Value has no validatable type"}));if(n)g=Promise.all(c).then((e=>e.every((e=>!e))?void 0:e));else{const e=c.every((e=>!e));g=c.length>0&&!e?c:void 0}}}const f=u===e.ModelKeys.TYPE?d.TYPE:u;g&&(c[f]=g)}if(!n)return Object.keys(c).length>0?c:void 0;const u=Object.keys(c),l=Object.values(c);return Promise.all(l).then((e=>{const t={};for(let r=0;r<e.length;r++){const a=e[r];void 0!==a&&(t[u[r]]=a)}return Object.keys(t).length>0?t:void 0}))}function Se(r,a,...s){const i=t.Metadata.validatableProperties(r.constructor,...s),n={},c={};for(const o of i){const i=o+"",u=r[o],l=t.Metadata.validationFor(r.constructor,o)||{},{designTypes:g}=t.Metadata.getPropDesignTypes(r.constructor,o);if(!g)continue;if(g.some((e=>[Array.name,Set.name].includes(e.name)))){if(!l||!Object.keys(l).includes(d.LIST)){n[i]={[d.TYPE]:`Array or Set property '${i}' requires a @list decorator`};continue}if(u&&!(Array.isArray(u)||u instanceof Set)){n[i]={[d.TYPE]:`Property '${o+""}' must be either an Array or a Set`};continue}}const f=_e(r,i,u,l,a,...s)||{};if(t.Metadata.isPropertyModel(r,i)&&null!=u){const t=g.map((e=>Ee.getRegistry().get(e.name||e))).find((e=>!!e)),n=g.map((e=>"function"==typeof e?e.name?e.name.toLowerCase():e()?.name.toLowerCase():e.toLowerCase()));if(t&&u instanceof t){const e=Ne(i,...s);c[i]=be(u,r,a,...e)}else n.includes(typeof u)||(f[d.TYPE]=t?"Value must be an instance of "+t.name:`Unable to verify type consistency, missing model registry for ${g.toString()} on prop ${i}`,delete f[e.ModelKeys.TYPE])}(Object.keys(f).length>0||a)&&(n[i]=f),a||Object.entries(c[i]||{}).forEach((([e,t])=>{void 0!==t&&(n[`${i}.${e}`]=t)}))}if(!a)return Object.keys(n).length>0?new o(n):void 0;const u=n,l=Object.keys(u),g=Object.values(u);return Promise.allSettled(g).then((async e=>{const t={};for(const[e,r]of Object.entries(c)){const a=await r;a&&Object.entries(a).forEach((([r,a])=>{void 0!==a&&(t[[e,r].join(".")]=a)}))}for(let r=0;r<e.length;r++){const a=l[r],s=e[r];"fulfilled"===s.status&&void 0!==s.value?t[a]=s.value:"rejected"===s.status&&(t[a]=s.reason instanceof Error?s.reason.message:(s.reason||"Validation failed")+"")}return Object.keys(t).length>0?new o(t):void 0}))}function Re(e){e+="";let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return t.toString()}function ve(e){const t=(e,t)=>{const r=a(t);return"string"==typeof r?a((e||"")+a(t)):0|(e=((e=e||0)<<5)-e+r)},r=Re,a=e=>void 0===e?"":-1!==["string","number","symbol"].indexOf(typeof e)?r(e.toString()):e instanceof Date?r(e.getTime()):Array.isArray(e)?e.reduce(t,void 0):Object.values(e).reduce(t,void 0),s=Object.values(e).reduce(t,0);return("number"==typeof s?Math.abs(s):s).toString()}const Pe="default";class Le{static{this.current=Pe}static{this.cache={default:ve}}constructor(){}static get(e){if(e in this.cache)return this.cache[e];throw Error("No hashing method registered under "+e)}static register(e,t,r=!1){if(e in this.cache)throw Error(`Hashing method ${e} already registered`);this.cache[e]=t,r&&(this.current=e)}static hash(e,t,...r){return t?this.get(t)(e,...r):this.get(this.current)(e,...r)}static setDefault(e){this.current=this.get(e)}}class De{constructor(e=void 0){}isAsync(){return!!(this[E]??this?.constructor[E])}hasErrors(...e){return Se(this,this.isAsync(),...e)}equals(e,...t){return F(this,e,...t)}compare(e,...r){const a=t.Metadata.properties(this.constructor);if(!a||!a.length)return;const s=a.reduce(((t,a)=>{const s=a;if(r.includes(s))return t;if(void 0===this[s]&&void 0!==e[s])return t[s]={other:e[s],current:void 0},t;if(void 0!==this[s]&&void 0===e[s])return t[s]={other:void 0,current:this[s]},t;if(F(this[s],e[s]))return t;if(De.isPropertyModel(this,s)){const r=this[s].compare(e[s]);return r&&(t[s]=r),t}if(Array.isArray(this[s])&&Array.isArray(e[s])){if(this[s].length!==e[s].length)return t[s]={current:this[s],other:e[s]},t;const r=this[s].map(((t,r)=>F(t,e[s][r])?null:t instanceof De&&e[s][r]instanceof De?t.compare(e[s][r]):{current:t,other:e[s][r]}));return r.some((e=>null!==e))&&(t[s]=r),t}return t[s]={other:e[s],current:this[s]},t}),{});return Object.keys(s).length>0?s:void 0}serialize(){return De.serialize(this)}toString(){return this.constructor.name+": "+JSON.stringify(this,void 0,2)}hash(){return De.hash(this)}static deserialize(r){let a;try{a=t.Metadata.get(this.constructor,e.ModelKeys.SERIALIZATION)}catch(e){a=void 0}return a&&a.serializer?n.deserialize(r,a.serializer,...a.args||[]):n.deserialize(r)}static fromObject(e,t){t||(t={});for(const r of De.getAttributes(e))e[r]=t[r]??e[r]??void 0;return e}static fromModel(e,t){return Ee.fromModel(e,t)}static setBuilder(e){Ee.setBuilder(e)}static getBuilder(){return Ee.getBuilder()}static getRegistry(){return Ee.getRegistry()}static setRegistry(e){Ee.setRegistry(e)}static register(e,t){return Ee.getRegistry().register(e,t)}static get(e){return Ee.getRegistry().get(e)}static build(e={},t){return De.getRegistry().build(e,t)}static getAttributes(e){return t.Metadata.getAttributes(e)}static equals(e,t,...r){return F(e,t,...r)}static hasErrors(e,t,...r){return Se(e,t,...r)}static serialize(r){let a;try{a=t.Metadata.get(r.constructor,e.ModelKeys.SERIALIZATION)}catch(e){a=void 0}return a&&a.serializer?n.serialize(this,a.serializer,...a.args||[]):n.serialize(r)}static hash(r){const a=t.Metadata.get(r.constructor,e.ModelKeys.HASHING);return a&&a.algorithm?Le.hash(r,a.algorithm,...a.args||[]):Le.hash(r)}static isModel(e){return t.Metadata.isModel(e)}static isPropertyModel(e,r){return t.Metadata.isPropertyModel(e,r)}static describe(e,r){return t.Metadata.description(e,r)}}t.Metadata.validationFor=((e,r,a)=>{const s=t.Metadata.get(e);if(!s)return;if(!r)return s.validation;if(!s.validation)return;if(!s.validation[d.TYPE]){const{designTypes:a}=t.Metadata.getPropDesignTypes(e,r);s.validation[r]&&a?.length&&a[0]!==C.OBJECT&&(s.validation[r][d.TYPE]={customTypes:a,message:g.TYPE,description:"defines the accepted types for the attribute",async:!1})}if(!a)return s.validation[r];const i=s.validation[r];return i?i[a]:void 0}).bind(t.Metadata),t.Metadata.modelName=(e=>{const r=t.Metadata.constr(e);return r?r.name:e.name}).bind(t.Metadata),t.Metadata.validatableProperties=((e,...r)=>{const a=t.Metadata.validationFor(e),s=a?Object.keys(a):[];return[...new Set([...De.getAttributes(e),...s])].filter((e=>!r||!r?.includes(e)))}).bind(t.Metadata),t.Metadata.allowedTypes=((e,r)=>{const a=t.Metadata.type(e,r);if(!a)throw Error("No metadata found for property "+r);const s=t.Metadata.validationFor(e,r);return s&&s[d.TYPE]&&"function"==typeof s[d.TYPE]?.customTypes[Symbol.iterator]?[...s[d.TYPE].customTypes]:[a]}).bind(t.Metadata),t.Metadata.getPropDesignTypes=((e,r)=>{const a=t.Metadata.get(e),s=t.Metadata.type(e,r),i=a?.[d.REFLECT]?.[r];if(!(s||i&&i[d.TYPE]))return{};const n=i&&i[d.TYPE]?[i[d.TYPE].customTypes]:[s];if(!n?.length)return{};const o=n[0],c=o.class||o.clazz||o.customTypes||o;return{designTypes:(Array.isArray(c)?c:[c]).map((e=>"function"!=typeof e||e.name?e:e())),designType:c}}).bind(t.Metadata),t.Metadata.isModel=(e=>{try{if(e instanceof De)return!0;const r=t.Metadata.constr(e);return!(!r||r===e||!t.Metadata.modelName(r))}catch(e){return!1}}).bind(t.Metadata),t.Metadata.isPropertyModel=((e,r)=>{if(t.Metadata.isModel(e[r]))return!0;const a=t.Metadata.type(e.constructor,r);return a&&Ee.getRegistry().get(a.name)?a.name:void 0}).bind(t.Metadata),t.Metadata.getAttributes=(e=>{const r=e instanceof De?e.constructor:e,a=new Set,s=e=>{if(!e)return[];const r=s(Object.getPrototypeOf(e)),i=t.Metadata.properties(e)??[];for(const e of i)a.has(e)||(a.add(e),r.push(e));return r};return s(r)}).bind(t.Metadata);class we{constructor(){}preSerialize(r,...a){const s=Object.assign({},r);let i;try{i=t.Metadata.modelName(r.constructor)}catch(e){i=void 0}return s[e.ModelKeys.ANCHOR]=i||r.constructor.name,s}deserialize(t,...r){const a=JSON.parse(t),s=a[e.ModelKeys.ANCHOR];if(!s)throw Error("Could not find class reference in serialized model");return De.build(a,s)}serialize(e,...t){return JSON.stringify(this.preSerialize(e))}}function Ie(e,...t){const r=(...t)=>new e(...t);return r.prototype=e.prototype,r(...t)}function Ve(e){if(e instanceof De)return;function t(e,t){Object.setPrototypeOf(e,t)}const r=Object.getPrototypeOf(e);if(r===Object.prototype)return t(e,De.prototype);for(;r!==Object.prototype;){const e=Object.getPrototypeOf(r);if(e===Object.prototype||Object.getPrototypeOf(e)===Object.prototype)return t(r,De.prototype)}throw Error("Could not find proper prototype to bind")}function je(r){const a=(...e)=>{const t=Ie(r,...e);Ve(t);const a=De.getBuilder();return a&&a(t,e.length?e[0]:void 0),t};return a.prototype=r.prototype,Object.defineProperty(a,"name",{writable:!1,enumerable:!0,configurable:!1,value:r.prototype.constructor.name}),t.metadata(e.ModelKeys.CONSTRUCTOR,r)(a),De.register(a,r.name),a}function Ue(){const r=e.ModelKeys.MODEL;return t.Decoration.for(r).define(je).apply()}n.cache={json:new we};class Ce{constructor(e,t,r){this.parent=e,this.attr=t,this.declaredType=r,this.decorators=[]}decorate(...e){for(const t of e){if(this.decorators.includes(t))throw Error(`Decorator "${t}" has already been used`);this.decorators.push(t)}return this.parent}undecorate(...e){for(const t of e){const e=this.decorators.indexOf(t);if(0>e)throw Error(`Decorator "${t}" is not applied to ${this.attr}`);this.decorators.splice(e,1)}return this.parent}required(e){const t=Ce.asMeta(e),r="string"==typeof e?e:Ce.resolveMessage(t);return this.decorate(X(r))}min(e,t){const r=Ce.asMeta(e),a=r?.[d.MIN]??(r?void 0:e);if(void 0===a)throw Error(`Missing ${d.MIN} for ${this.attr+""}`);return this.decorate(W(a,Ce.resolveMessage(r,t)))}max(e,t){const r=Ce.asMeta(e),a=r?.[d.MAX]??(r?void 0:e);if(void 0===a)throw Error(`Missing ${d.MAX} for ${this.attr+""}`);return this.decorate(Z(a,Ce.resolveMessage(r,t)))}step(e,t){const r=Ce.asMeta(e),a=r?.[d.STEP]??(r?void 0:e);if(void 0===a)throw Error(`Missing ${d.STEP} for ${this.attr+""}`);return this.decorate(J(a,Ce.resolveMessage(r,t)))}minlength(e,t){const r=Ce.asMeta(e),a=r?.[d.MIN_LENGTH]??(r?void 0:e);if(void 0===a)throw Error(`Missing ${d.MIN_LENGTH} for ${this.attr+""}`);return this.decorate(ee(a,Ce.resolveMessage(r,t)))}maxlength(e,t){const r=Ce.asMeta(e),a=r?.[d.MAX_LENGTH]??(r?void 0:e);if(void 0===a)throw Error(`Missing ${d.MAX_LENGTH} for ${this.attr+""}`);return this.decorate(te(a,Ce.resolveMessage(r,t)))}pattern(e,t){const r=Ce.asMeta(e),a=r?.[d.PATTERN]??(r?void 0:e),s=Ce.patternFromString(a)??/.*/;return this.decorate(re(s,Ce.resolveMessage(r,t)))}email(e){const t=Ce.asMeta(e),r="string"==typeof e?e:Ce.resolveMessage(t);return this.decorate(ae(r))}url(e){const t=Ce.asMeta(e),r="string"==typeof e?e:Ce.resolveMessage(t);return this.decorate(se(r))}type(e,t){const r=Ce.asMeta(e),a=r?.customTypes??r?.type??(r?void 0:e);return this.decorate(ie(a,Ce.resolveMessage(r,t)))}date(e,t){const r=Ce.asMeta(e),a=r?.[d.FORMAT]??(r?void 0:e);return this.decorate(ne(a,Ce.resolveMessage(r,t)))}password(e,t){const r=Ce.asMeta(e),a=r?.[d.PATTERN]??(r?void 0:e),s=Ce.patternFromString(a);return this.decorate(oe(s,Ce.resolveMessage(r,t)))}list(e,t,r){const a=Ce.asMeta(e),s=a?.clazz??(a?void 0:e),i=a?.type??t;return this.decorate(ce(s,i,Ce.resolveMessage(a,r)))}set(e,t){return Ce.isMetadataPayload(e)?this.list(e):this.list(e,"Set",t)}enum(e,t){const r=Ce.asMeta(e),a=r?.[d.ENUM]??(r?void 0:e);return this.decorate(pe(a,Ce.resolveMessage(r,t)))}option(e,t){return this.enum(e,t)}static isMetadataPayload(e){return!(!e||e instanceof Date||e instanceof RegExp||Array.isArray(e)||"object"!=typeof e)}static asMeta(e){return Ce.isMetadataPayload(e)?e:void 0}static resolveMessage(e,t){return e?.message??t}static patternFromString(e){if(!e)return;if(e instanceof RegExp)return e;const t=e.match(/^\/(.+)\/([gimsuy]*)$/);return t?RegExp(t[1],t[2]):RegExp(e)}resolveComparison(e,t,r){const a=Ce.asMeta(e);return a?{target:a[t],options:{label:a.label,message:a.message}}:{target:e,options:r}}equals(e,t){const{target:r,options:a}=this.resolveComparison(e,d.EQUALS,t);return this.decorate(de(r,a))}eq(e,t){return this.equals(e,t)}different(e,t){const{target:r,options:a}=this.resolveComparison(e,d.DIFF,t);return this.decorate(ue(r,a))}diff(e,t){return this.different(e,t)}lessThan(e,t){const{target:r,options:a}=this.resolveComparison(e,d.LESS_THAN,t);return this.decorate(le(r,a))}lt(e,t){return this.lessThan(e,t)}lessThanOrEqual(e,t){const{target:r,options:a}=this.resolveComparison(e,d.LESS_THAN_OR_EQUAL,t);return this.decorate(ge(r,a))}lte(e,t){return this.lessThanOrEqual(e,t)}greaterThan(e,t){const{target:r,options:a}=this.resolveComparison(e,d.GREATER_THAN,t);return this.decorate(fe(r,a))}gt(e,t){return this.greaterThan(e,t)}greaterThanOrEqual(e,t){const{target:r,options:a}=this.resolveComparison(e,d.GREATER_THAN_OR_EQUAL,t);return this.decorate(he(r,a))}gte(e,t){return this.greaterThanOrEqual(e,t)}description(e){return this.decorate(t.description(e))}build(e){const r=e.prototype,a=this.attr;Object.getOwnPropertyDescriptor(r,a)||Object.defineProperty(r,a,{configurable:!0,enumerable:!0,writable:!0,value:void 0}),this.declaredType&&Reflect.defineMetadata(t.DecorationKeys.DESIGN_TYPE,this.declaredType,r,a),t.prop()(r,a),this.decorators.forEach((e=>{try{e(r,a)}catch(e){throw Error(`Failed to apply decorator to property "${this.attr}": ${e}`)}}))}}class He{constructor(e,t,r){this.parent=e,this.attribute=t,this.collection=r}ofPrimitives(e,t){return this.attribute.list(e,this.collection,t),this.parent}ofModel(){const e=xe.builder(),t=e.build;let r;return this.attribute.list((()=>(r||(r=Reflect.apply(t,e,[])),r)),this.collection),e.build=new Proxy(t,{apply:(e,t,a)=>(r=Reflect.apply(e,t,a),this.parent)}),e}}class xe extends a.ObjectAccumulator{constructor(){super(...arguments),this.attributes=new Map}setName(e){return this._name=e,this}description(e){return this._description=e,this}attribute(e,t){const r=this.attributes.get(e);if(r){if(r.declaredType!==t)throw Error(`Attribute "${e+""}" already exists with a different type`);return r}const a=new Ce(this,e,t);return this.attributes.set(e,a),a}string(e){return this.attribute(e,String)}number(e){return this.attribute(e,Number)}date(e){return this.attribute(e,Date)}bigint(e){return this.attribute(e,BigInt)}instance(e,t){return this.attribute(t,e)}model(e){const t=new xe;return t.build=new Proxy(t.build,{apply:(t,r,a)=>{const s=Reflect.apply(t,r,a);return this.instance(s,e)}}),t}listOf(e,t="Array"){const r="Set"===t?Set:Array,a=this.attribute(e,r);return new He(this,a,t)}build(){if(!this._name)throw Error("name is required");const e=this._parent??De;class r extends e{constructor(e){super(e)}}Object.defineProperty(r,"name",{value:this._name,writable:!1});for(const e of this.attributes.values())e.build(r);let a=Ue()(r);return this._description&&(a=t.description(this._description)(a)),a}static builder(){return new xe}static from(e,t){if(!e)throw Error("metadata is required");const r=xe.builder(),a=t??"GeneratedModel"+Date.now();r.setName(a);const s=e.properties||{},i=e.validation||{};for(const[e,t]of Object.entries(s)){const a=r.attribute(e,t||Object),s=i[e];if(s)for(const[e,t]of Object.entries(s)){const r=a[e];if("function"!=typeof r)try{const r=D.decoratorFromKey(e),s="function"==typeof r?r(t):r;a.decorate(s)}catch{}else r.call(a,t)}}return r.build()}}const Fe="##VERSION##",ze="##PACKAGE##";t.Metadata.registerLibrary(ze,Fe),e.ASYNC_META_KEY=E,e.AsyncValidator=class extends v{constructor(e=g.DEFAULT,...t){super(!0,e,...t)}},e.AttributeBuilder=Ce,e.COMPARISON_ERROR_MESSAGES=y,e.ComparisonValidationKeys=c,e.DAYS_OF_WEEK_NAMES=l,e.DEFAULT_ERROR_MESSAGES=g,e.DEFAULT_PATTERNS=f,e.DefaultHashingMethod=Pe,e.DefaultSerializationMethod=i,e.Hashing=Le,e.JSONSerializer=we,e.MONTH_NAMES=u,e.Model=De,e.ModelBuilder=xe,e.ModelErrorDefinition=o,e.ModelRegistryManager=Ee,e.PACKAGE_NAME=ze,e.PathProxyEngine=V,e.ReservedModels=C,e.Serialization=n,e.VALIDATION_PARENT_KEY=m,e.VERSION=Fe,e.Validation=D,e.ValidationKeys=d,e.Validator=P,e.ValidatorRegistry=L,e.async=()=>e=>{Object.prototype.hasOwnProperty.call(e,E)||(e[E]=!0)},e.bindDateToString=$,e.bindModelPrototype=Ve,e.bulkModelRegister=(...e)=>{e.forEach((e=>{const t=e.constructor?e.constructor:e;Ee.getRegistry().register(t,e.name)}))},e.checkType=O,e.checkTypes=_,e.construct=Ie,e.date=ne,e.dateFromFormat=G,e.diff=ue,e.email=ae,e.eq=de,e.evaluateDesignTypes=S,e.findLastProtoBeforeObject=e=>{let t=Object.getPrototypeOf(e);if(t===Object.prototype)return e;for(;t!==Object.prototype;){if(t=Object.getPrototypeOf(t),t===Object.prototype)return t;if(Object.getPrototypeOf(t)===Object.prototype)return t}throw Error("Could not find proper prototype")},e.formatDate=K,e.getChildNestedPropsToIgnore=Ne,e.gt=fe,e.gte=he,e.hashCode=Re,e.hashObj=ve,e.hashedBy=(r,...a)=>t.metadata(e.ModelKeys.HASHING,{algorithm:r,args:a}),e.innerValidationDecorator=B,e.isEqual=F,e.isGreaterThan=N,e.isLessThan=A,e.isValidDate=Y,e.isValidForGteOrLteComparison=b,e.jsTypes=H,e.list=ce,e.lt=le,e.lte=ge,e.max=Z,e.maxlength=te,e.min=W,e.minlength=ee,e.model=Ue,e.modelBaseDecorator=je,e.option=pe,e.parseDate=k,e.password=oe,e.pattern=re,e.regexpParser=z,e.required=X,e.serializedBy=(r,...a)=>t.metadata(e.ModelKeys.SERIALIZATION,{serializer:r,args:a}),e.set=(e,t=g.LIST)=>ce(e,"Set",t),e.sf=p,e.step=J,e.stringFormat=h,e.toConditionalPromise=j,e.twoDigitPad=q,e.type=ie,e.url=se,e.validate=Se,e.validateChildValue=Ae,e.validateDecorator=Oe,e.validateDecorators=_e,e.validationMetadata=Q,e.validator=x,e.valueLength=R},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@decaf-ts/decoration"),require("tslib"),require("typed-object-accumulator")):"function"==typeof define&&define.amd?define(["exports","@decaf-ts/decoration","tslib","typed-object-accumulator"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["decorator-validation"]={},e.decafTsDecoration,e.tslib,e.typedObjectAccumulator);
2
2
  //# sourceMappingURL=decorator-validation.cjs.map