@decaf-ts/decorator-validation 1.11.1 → 1.11.3

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.
package/README.md CHANGED
@@ -8,6 +8,7 @@ A TypeScript decorator-driven validation and model framework. It lets you:
8
8
  - Extend validation via a registry of Validator classes and utilities.
9
9
  - Optionally expose validation as MCP tools for automation workflows.
10
10
 
11
+ > Release docs refreshed on 2025-11-26. See [workdocs/reports/RELEASE_NOTES.md](./workdocs/reports/RELEASE_NOTES.md) for ticket summaries.
11
12
 
12
13
  ![Licence](https://img.shields.io/github/license/decaf-ts/decorator-validation.svg?style=plastic)
13
14
  ![GitHub language count](https://img.shields.io/github/languages/count/decaf-ts/decorator-validation?style=plastic)
@@ -32,7 +33,7 @@ A TypeScript decorator-driven validation and model framework. It lets you:
32
33
 
33
34
  Documentation available [here](https://decaf-ts.github.io/decorator-validation/)
34
35
 
35
- Minimal size: 13.1 KB kb gzipped
36
+ Minimal size: 13.3 KB kb gzipped
36
37
 
37
38
 
38
39
  # Decorator Validation – Detailed Description
@@ -568,6 +569,9 @@ const allKeys = Validation.keys();
568
569
  - builder;
569
570
  - etc;
570
571
 
572
+ ## Release Documentation Hooks
573
+ Stay aligned with the automated release pipeline by reviewing [Release Notes](./workdocs/reports/RELEASE_NOTES.md) and [Dependencies](./workdocs/reports/DEPENDENCIES.md) after trying these recipes (updated on 2025-11-26).
574
+
571
575
 
572
576
  ### Related
573
577
 
@@ -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 o{constructor(){}preSerialize(r){const a=Object.assign({},r);let s;try{s=t.Metadata.modelName(r.constructor)}catch(e){s=void 0}return a[e.ModelKeys.ANCHOR]=s||r.constructor.name,a}deserialize(t){const r=JSON.parse(t),a=r[e.ModelKeys.ANCHOR];if(!a)throw Error("Could not find class reference in serialized model");return ne.build(r,a)}serialize(e){return JSON.stringify(this.preSerialize(e))}}class n{static{this.current=i}static{this.cache={json:new o}}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"},l={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},u=["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 y=p,m={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),o=s(a.groups.day),n=a.groups.ampm;let c=s(a.groups.hour);n&&(c="PM"===n?c+12:c);const d=s(a.groups.minutes),l=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=u.indexOf(h);else if(g){const t=u.find(e=>e.toLowerCase().startsWith(g.toLowerCase()));if(!t)return new Date(e);p=u.indexOf(t)}else p=s(""+p);return new Date(i,p-1,o,c,d,l,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(),o=e.getMinutes(),n=e.getSeconds(),c=e.getMilliseconds(),d=i%12,l=N(d),h=N(i),g=N(o),p=N(n),y=12>i?"AM":"PM",m=f[e.getDay()],E=m.substr(0,3),T=N(r),b=a+1,M=N(b),A=u[a],O=A.substr(0,3),_=s+"",S=_.substr(2,2);return(t=t.replace("hh",l).replace("h",d.toString()).replace("HH",h).replace("H",i.toString()).replace("mm",g).replace("m",o.toString()).replace("ss",p).replace("s",n.toString()).replace("S",c.toString()).replace("dd",T).replace("d",r.toString()).replace("EEEE",m).replace("EEE",E).replace("yyyy",_).replace("yy",S).replace("aaa",y)).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(y("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(y("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())),o=Object.getOwnPropertySymbols(t).filter(e=>!r.includes(e.toString()));if(i.length!==o.length)return!1;for(const a of i){if(!o.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&=t;return t.toString()}function v(e){const t=(e,t)=>{const r=a(t);return"string"==typeof r?a((e||"")+a(t)):(e=((e=e||0)<<5)-e+r)&e},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],I=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw Error(y(m.PROPERTY_NOT_EXIST,t));return e[t]};class w{static create(e,t){const{getValue:r,getParent:a,ignoreUndefined:s,ignoreNull:i}={getParent:D,getValue:I,ignoreNull:!1,ignoreUndefined:!1,...t};return new Proxy({},{get:(t,o)=>"getValueFromPath"===o?t=>{const o=w.parsePath(t);let n=e;for(let e=0;e<o.length;e++){const c=o[e];if(".."===c){const r=a(n);if(!r||"object"!=typeof r)throw Error(y(m.CONTEXT_NOT_OBJECT_COMPARISON,e+1,t));n=r;continue}if(n=r(n,c),!s&&void 0===n)throw Error(y(m.PROPERTY_INVALID,t,c));if(!i&&null===n)throw Error(y(m.PROPERTY_INVALID,t,c))}return n}:t[o]})}static parsePath(e){if("string"!=typeof e||!e.trim())throw Error(y(m.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(y(m.UNSUPPORTED_TYPES_COMPARISON,V(e),V(t)))}function H(e,t){if([null,void 0].includes(e)||[null,void 0].includes(t))throw Error(m.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(y(m.TYPE_MISMATCH_COMPARISON,r,a))}if("number"===r&&"number"===a||"bigint"===r&&"bigint"===a){if(Number.isNaN(e)||Number.isNaN(t))throw new TypeError(m.NAN_COMPARISON);return t>e}if(e instanceof Date&&t instanceof Date){if(isNaN(e.getTime())||isNaN(t.getTime()))throw new TypeError(m.INVALID_DATE_COMPARISON);return e.getTime()<t.getTime()}throw new TypeError(y(m.UNSUPPORTED_TYPES_COMPARISON,V(e),V(t)))}function C(e,t){if([null,void 0].includes(e)||[null,void 0].includes(t))throw Error(m.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(y(m.TYPE_MISMATCH_COMPARISON,r,a))}if("number"===r&&"number"===a||"bigint"===r&&"bigint"===a){if(Number.isNaN(e)||Number.isNaN(t))throw new TypeError(m.NAN_COMPARISON);return e>t}if(e instanceof Date&&t instanceof Date){if(isNaN(e.getTime())||isNaN(t.getTime()))throw new TypeError(m.INVALID_DATE_COMPARISON);return e.getTime()>t.getTime()}throw new TypeError(y(m.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 y(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 l.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(l.REFLECT,r));s?.[r]||t.Metadata.set(e.ModelKeys.DECORATORS,t.Metadata.key(l.REFLECT,r),a)}static decoratorFromKey(r){try{return t.Metadata.innerGet(Symbol.for(e.ModelKeys.DECORATORS),t.Metadata.key(l.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 o,n=!1;for(const d of a){const a=ne.get(d);if(a||(o=new c({[e]:{[l.TYPE]:"Unable to verify type consistency, missing model registry for "+d}})),t instanceof a){n=!0,o=X(t,r,s,...i);break}}return n?o:o||new c({[e]:{[l.TYPE]:"Value must be an instance of one of the expected types: "+a.join(", ")}})}function Z(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 o=a.key===e.ModelKeys.TYPE?[a]:a||{},n=w.create(t,{ignoreUndefined:!0,ignoreNull:!0}),c=a.key===e.ModelKeys.TYPE?o[0]:o;return k(i.hasErrors(r,c,n),s)}function J(t,r,a,s,i,...o){const n={};for(const c in s){const d={...s[c],key:c};if(!i&&d.async)continue;let u=Z(t,a,d,i);if(c===l.LIST&&(!u||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()),n=e.map(e=>ne.isModel(e)?W(r,e,t,a.flat(),!!i,...o):s.includes(typeof e)?void 0:"Value has no validatable type");if(i)u=Promise.all(n).then(e=>e.every(e=>!e)?void 0:e);else{const e=n.every(e=>!e);u=n.length>0&&!e?n:void 0}}}const f=c===e.ModelKeys.TYPE?l.TYPE:c;u&&(n[f]=u)}if(!i)return Object.keys(n).length>0?n:void 0;const c=Object.keys(n),d=Object.values(n);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 ee(r,a,...s){const i=t.Metadata.validatableProperties(r.constructor,...s),o={},n={};for(const c of i){const i=c+"",d=r[c],u=t.Metadata.validationFor(r.constructor,c)||{},{designTypes:f,designType:h}=t.Metadata.getPropDesignTypes(r.constructor,c);if(!f)continue;if(f.some(e=>[Array.name,Set.name].includes(e.name))){if(!u||!Object.keys(u).includes(l.LIST)){o[i]={[l.TYPE]:`Array or Set property '${i}' requires a @list decorator`};continue}if(d&&!(Array.isArray(d)||d instanceof Set)){o[i]={[l.TYPE]:`Property '${c+""}' must be either an Array or a Set`};continue}}const g=J(r,i,d,u,a,...s)||{},p=ne.isPropertyModel(r,i),y=null!=d,m=y&&ne.isModel(d);if(p&&y&&m){const t=d;if(ne.shouldValidateNestedHandler(r,i)){const o=(Array.isArray(h)?f:[h]).map(e=>("function"!=typeof e||e.name||(e=e()),ne.get(e.name||e))).find(e=>!!e);o&&t instanceof o?n[i]=X(t,r,a,...s):(g[l.TYPE]=o?"Value must be an instance of "+o.name:`Unable to verify type consistency, missing model registry for ${f.toString()} on prop ${i}`,delete g[e.ModelKeys.TYPE])}}(Object.keys(g).length>0||a)&&(o[i]=g),a||Object.entries(n[i]||{}).forEach(([e,t])=>{void 0!==t&&(o[`${i}.${e}`]=t)})}if(!a)return Object.keys(o).length>0?new c(o):void 0;const d=o,u=Object.keys(d),f=Object.values(d);return Promise.allSettled(f).then(async e=>{const t={};for(const[e,r]of Object.entries(n)){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=u[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 te;e.Primitives=void 0,(te=e.Primitives||(e.Primitives={})).STRING="string",te.NUMBER="number",te.BOOLEAN="boolean",te.BIGINT="bigint";const re={STRING:String,OBJECT:Object,NUMBER:Number,BOOLEAN:Boolean,BIGINT:BigInt,DATE:Date},ae=["string","array","number","boolean","symbol","function","object","undefined","null","bigint"];let se,ie;class oe{constructor(e=ne.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 ne{constructor(e=void 0){}isAsync(){return!!(this[T]??this?.constructor[T])}hasErrors(...e){return ee(this,this.isAsync(),...e)}equals(e,...t){return S(this,e,...t)}serialize(){return ne.serialize(this)}toString(){return this.constructor.name+": "+JSON.stringify(this,void 0,2)}hash(){return ne.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 ne.getAttributes(e))e[r]=t[r]??e[r]??void 0;return e}static fromModel(e,r){let a;r||(r={});const s=ne.getAttributes(e),i=Object.getPrototypeOf(e);let o;for(const n of s){try{e[n]=r[n]??e[n]??void 0}catch(e){if(o=Object.getOwnPropertyDescriptor(i,n),!o||o.writable)throw Error(`Unable to write property ${n} to model: ${e}`)}if("object"!=typeof e[n])continue;const s=ne.isPropertyModel(e,n);if(s){try{e[n]=ne.build(e[n],"string"==typeof s?s:void 0)}catch(e){}continue}if(a=t.Metadata.allowedTypes(e.constructor,n),!a||!a.length)throw Error("failed to find decorators for property "+n);const c=a.map(e=>"function"!=typeof e||e.name?e:e()),d=Object.values(re);c.forEach(r=>{if(!d.includes(r))try{switch(r.name){case"Array":case"Set":{const a=t.Metadata.validationFor(e.constructor,n);if(!a||!a[l.LIST])break;const s=a[l.LIST].clazz.map(e=>"function"!=typeof e||e.name?e:e()).find(e=>!ae.includes(e.name));if("Array"===r.name&&(e[n]=e[n].map(e=>["object","function"].includes(typeof e)&&s?ne.build(e,s.name):e)),"Set"===r.name){const t=new Set;for(const r of e[n])["object","function"].includes(typeof r)&&s?t.add(ne.build(r,s.name)):t.add(r);e[n]=t}break}default:void 0!==e[n]&&ne.get(r.name)&&(e[n]=ne.build(e[n],r.name))}}catch(e){}})}return e}static setBuilder(e){se=e}static getBuilder(){return se||ne.fromModel}static getRegistry(){return ie||(ie=new oe),ie}static setRegistry(e){ie=e}static register(e,t){return ne.getRegistry().register(e,t)}static get(e){return ne.getRegistry().get(e)}static build(e={},t){return ne.getRegistry().build(e,t)}static getAttributes(e){const r=e instanceof ne?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 ee(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?L.hash(r,a.algorithm,...a.args||[]):L.hash(r)}static isModel(e){try{if(e instanceof ne)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(ne.isModel(e[r]))return!0;const a=t.Metadata.type(e.constructor,r);return a&&ne.get(a.name)?a.name:void 0}static describe(e,r){return t.Metadata.description(e,r)}static{this.shouldValidateNestedHandler=(e,t)=>{const r=e[t];return!!r&&"object"==typeof r&&"function"==typeof r.hasErrors}}}function ce(...e){return t.apply(t=>(e.forEach(e=>{K.register({validator:t,validationKey:e,save:!0})}),t),t.metadata(l.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[l.TYPE]){const{designTypes:a}=t.Metadata.getPropDesignTypes(e,r);s.validation[r]&&a?.length&&a[0]!==re.OBJECT&&(s.validation[r][l.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([...ne.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[l.TYPE]&&"function"==typeof s[l.TYPE]?.customTypes[Symbol.iterator]?[...s[l.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?.[l.REFLECT]?.[r];if(!(s||i&&i[l.TYPE]))return{};const o=i&&i[l.TYPE]?[i[l.TYPE].customTypes]:[s];if(!o?.length)return{};const n=o[0],c=n.class||n.clazz||n.customTypes||n;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([ce(l.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[l.DIFF])}catch(e){return this.getMessage(e.message||this.message)}return S(e,a)?this.getMessage(t.message||this.message,t.label||t[l.DIFF]):void 0}},e.DiffValidator=r.__decorate([ce(l.DIFF),r.__metadata("design:paramtypes",[String])],e.DiffValidator);const de=RegExp("^/(.+)/([gimus]*)$");function le(e,r,a){return t.apply(t.propMetadata(r,a))}function ue(e,t,r){return K.registerDecorator(t,e),(e,a)=>le(0,`${l.REFLECT}.${a}.${t}`,r)(e,a)}function fe(e=h.REQUIRED){const r=l.REQUIRED,a={message:e,description:"defines the attribute as required",async:!1};return t.Decoration.for(r).define({decorator:ue,args:[fe,r,a]}).apply()}function he(e,r=h.MIN){const a=l.MIN,s={[l.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:ue,args:[he,a,s]}).apply()}function ge(e,r=h.MAX){const a=l.MAX,s={[l.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:ue,args:[ge,a,s]}).apply()}function pe(e,r=h.STEP){const a=l.STEP,s={[l.STEP]:e,message:r,description:"defines the step of the attribute as "+e,async:!1};return t.Decoration.for(a).define({decorator:ue,args:[pe,a,s]}).apply()}function ye(e,r=h.MIN_LENGTH){const a=l.MIN_LENGTH,s={[l.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:ue,args:[ye,a,s]}).apply()}function me(e,r=h.MAX_LENGTH){const a=l.MAX_LENGTH,s={[l.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:ue,args:[me,a,s]}).apply()}function Ee(e,r=h.PATTERN){const a=l.PATTERN,s={[l.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:ue,args:[Ee,a,s]}).apply()}function Te(e=h.EMAIL){const r=l.EMAIL,a={[l.PATTERN]:g.EMAIL.toString(),message:e,description:"marks the attribute as an email",async:!1};return t.Decoration.for(r).define({decorator:ue,args:[Te,r,a]}).apply()}function be(e=h.URL){const r=l.URL,a={[l.PATTERN]:g.URL.toString(),message:e,description:"marks the attribute as an url",async:!1};return t.Decoration.for(r).define({decorator:ue,args:[be,r,a]}).apply()}function Me(e,r=h.TYPE){const a=l.TYPE,s={customTypes:e,message:r,description:"defines the accepted types for the attribute",async:!1};return t.Decoration.for(a).define({decorator:ue,args:[Me,a,s]}).apply()}function Ae(e="dd/MM/yyyy",r=h.DATE){const a=l.DATE;return t.Decoration.for(a).define({decorator:function(e,t){const r={[l.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)}}),ue(Ae,a,r)(t,s)}},args:[e,r]}).apply()}function Ne(e=g.PASSWORD.CHAR8_ONE_OF_EACH,r=h.PASSWORD){const a=l.PASSWORD,s={[l.PATTERN]:e.toString(),message:r,description:"attribute as a password",async:!1};return t.Decoration.for(a).define({decorator:ue,args:[Ne,a,s]}).apply()}function Oe(e,r="Array",a=h.LIST){const s=l.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:ue,args:[Oe,s,i]}).apply()}function _e(e,t){return ue(_e,l.EQUALS,{label:t?.label||e,message:t?.message||h.EQUALS,[l.EQUALS]:e,description:"defines attribute as equal to "+e,async:!1})}function Se(e,t){return ue(Se,l.DIFF,{label:t?.label||e,message:t?.message||h.DIFF,[l.DIFF]:e,description:"defines attribute as different to "+e,async:!1})}function Re(e,t){return ue(Re,l.LESS_THAN,{label:t?.label||e,message:t?.message||h.LESS_THAN,[l.LESS_THAN]:e,description:"defines attribute as less than to "+e,async:!1})}function ve(e,t){return ue(ve,l.LESS_THAN_OR_EQUAL,{label:t?.label||e,message:t?.message||h.LESS_THAN_OR_EQUAL,[l.LESS_THAN_OR_EQUAL]:e,description:"defines attribute as less or equal to "+e,async:!1})}function Pe(e,t){return ue(Pe,l.GREATER_THAN,{label:t?.label||e,message:t?.message||h.GREATER_THAN,[l.GREATER_THAN]:e,description:"defines attribute as greater than "+e,async:!1})}function Le(e,t){return ue(Le,l.GREATER_THAN_OR_EQUAL,{label:t?.label||e,message:t?.message||h.GREATER_THAN_OR_EQUAL,[l.GREATER_THAN_OR_EQUAL]:e,description:"defines attribute as greater or equal to "+e,async:!1})}function De(e,r=h.ENUM){const a=l.ENUM,s={[l.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:ue,args:[De,a,s]}).apply()}function Ie(e,...t){const r=(...t)=>new e(...t);return r.prototype=e.prototype,r(...t)}function we(e){if(e instanceof ne)return;function t(e,t){Object.setPrototypeOf(e,t)}const r=Object.getPrototypeOf(e);if(r===Object.prototype)return t(e,ne.prototype);for(;r!==Object.prototype;){const e=Object.getPrototypeOf(r);if(e===Object.prototype||Object.getPrototypeOf(e)===Object.prototype)return t(r,ne.prototype)}throw Error("Could not find proper prototype to bind")}function Ve(r){const a=(...e)=>{const t=Ie(r,...e);we(t);const a=ne.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),ne.register(a,r.name),a}function je(){const r=e.ModelKeys.MODEL;return t.Decoration.for(r).define(Ve).apply()}e.PatternValidator=class extends Y{constructor(e=h.PATTERN){super(e,"string")}getPattern(e){if(!de.test(e))return RegExp(e);const t=e.match(de);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([ce(l.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([ce(l.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[l.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[l.EQUALS])}},e.EqualsValidator=r.__decorate([ce(l.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[l.GREATER_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[l.GREATER_THAN])}}},e.GreaterThanValidator=r.__decorate([ce(l.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[l.GREATER_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[l.GREATER_THAN_OR_EQUAL])}}},e.GreaterThanOrEqualValidator=r.__decorate([ce(l.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[l.LESS_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[l.LESS_THAN])}}},e.LessThanValidator=r.__decorate([ce(l.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[l.LESS_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[l.LESS_THAN_OR_EQUAL])}}},e.LessThanOrEqualValidator=r.__decorate([ce(l.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([ce(l.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([ce(l.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([ce(l.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([ce(l.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([ce(l.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([ce(l.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,[l.PATTERN]:t?.pattern||g.PASSWORD.CHAR8_ONE_OF_EACH})}},e.PasswordValidator=r.__decorate([ce(l.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([ce(l.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([ce(l.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([ce(l.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([ce(l.URL),r.__metadata("design:paramtypes",[String])],e.URLValidator);class Ue{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=Ue.asMeta(e),r="string"==typeof e?e:Ue.resolveMessage(t);return this.decorate(fe(r))}min(e,t){const r=Ue.asMeta(e),a=r?.[l.MIN]??(r?void 0:e);if(void 0===a)throw Error(`Missing ${l.MIN} for ${this.attr+""}`);return this.decorate(he(a,Ue.resolveMessage(r,t)))}max(e,t){const r=Ue.asMeta(e),a=r?.[l.MAX]??(r?void 0:e);if(void 0===a)throw Error(`Missing ${l.MAX} for ${this.attr+""}`);return this.decorate(ge(a,Ue.resolveMessage(r,t)))}step(e,t){const r=Ue.asMeta(e),a=r?.[l.STEP]??(r?void 0:e);if(void 0===a)throw Error(`Missing ${l.STEP} for ${this.attr+""}`);return this.decorate(pe(a,Ue.resolveMessage(r,t)))}minlength(e,t){const r=Ue.asMeta(e),a=r?.[l.MIN_LENGTH]??(r?void 0:e);if(void 0===a)throw Error(`Missing ${l.MIN_LENGTH} for ${this.attr+""}`);return this.decorate(ye(a,Ue.resolveMessage(r,t)))}maxlength(e,t){const r=Ue.asMeta(e),a=r?.[l.MAX_LENGTH]??(r?void 0:e);if(void 0===a)throw Error(`Missing ${l.MAX_LENGTH} for ${this.attr+""}`);return this.decorate(me(a,Ue.resolveMessage(r,t)))}pattern(e,t){const r=Ue.asMeta(e),a=r?.[l.PATTERN]??(r?void 0:e),s=Ue.patternFromString(a)??/.*/;return this.decorate(Ee(s,Ue.resolveMessage(r,t)))}email(e){const t=Ue.asMeta(e),r="string"==typeof e?e:Ue.resolveMessage(t);return this.decorate(Te(r))}url(e){const t=Ue.asMeta(e),r="string"==typeof e?e:Ue.resolveMessage(t);return this.decorate(be(r))}type(e,t){const r=Ue.asMeta(e),a=r?.customTypes??r?.type??(r?void 0:e);return this.decorate(Me(a,Ue.resolveMessage(r,t)))}date(e,t){const r=Ue.asMeta(e),a=r?.[l.FORMAT]??(r?void 0:e);return this.decorate(Ae(a,Ue.resolveMessage(r,t)))}password(e,t){const r=Ue.asMeta(e),a=r?.[l.PATTERN]??(r?void 0:e),s=Ue.patternFromString(a);return this.decorate(Ne(s,Ue.resolveMessage(r,t)))}list(e,t,r){const a=Ue.asMeta(e),s=a?.clazz??(a?void 0:e),i=a?.type??t;return this.decorate(Oe(s,i,Ue.resolveMessage(a,r)))}set(e,t){return Ue.isMetadataPayload(e)?this.list(e):this.list(e,"Set",t)}enum(e,t){const r=Ue.asMeta(e),a=r?.[l.ENUM]??(r?void 0:e);return this.decorate(De(a,Ue.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 Ue.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=Ue.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,l.EQUALS,t);return this.decorate(_e(r,a))}eq(e,t){return this.equals(e,t)}different(e,t){const{target:r,options:a}=this.resolveComparison(e,l.DIFF,t);return this.decorate(Se(r,a))}diff(e,t){return this.different(e,t)}lessThan(e,t){const{target:r,options:a}=this.resolveComparison(e,l.LESS_THAN,t);return this.decorate(Re(r,a))}lt(e,t){return this.lessThan(e,t)}lessThanOrEqual(e,t){const{target:r,options:a}=this.resolveComparison(e,l.LESS_THAN_OR_EQUAL,t);return this.decorate(ve(r,a))}lte(e,t){return this.lessThanOrEqual(e,t)}greaterThan(e,t){const{target:r,options:a}=this.resolveComparison(e,l.GREATER_THAN,t);return this.decorate(Pe(r,a))}gt(e,t){return this.greaterThan(e,t)}greaterThanOrEqual(e,t){const{target:r,options:a}=this.resolveComparison(e,l.GREATER_THAN_OR_EQUAL,t);return this.decorate(Le(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=Ce.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 Ce 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 Ue(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 Ce;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??ne;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=je()(r);return this._description&&(a=t.description(this._description)(a)),a}static builder(){return new Ce}static from(e,t){if(!e)throw Error("metadata is required");const r=Ce.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 xe="##VERSION##",Fe="##PACKAGE##";t.Metadata.registerLibrary(Fe,xe),e.ASYNC_META_KEY=T,e.AsyncValidator=class extends ${constructor(e=h.DEFAULT,...t){super(!0,e,...t)}},e.AttributeBuilder=Ue,e.COMPARISON_ERROR_MESSAGES=m,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=o,e.MONTH_NAMES=u,e.Model=ne,e.ModelBuilder=Ce,e.ModelErrorDefinition=c,e.ModelRegistryManager=oe,e.PACKAGE_NAME=Fe,e.PathProxyEngine=w,e.ReservedModels=re,e.Serialization=n,e.VALIDATION_PARENT_KEY=E,e.VERSION=xe,e.Validation=K,e.ValidationKeys=l,e.Validator=Y,e.ValidatorRegistry=q,e.async=()=>e=>{Object.prototype.hasOwnProperty.call(e,T)||(e[T]=!0)},e.bindDateToString=M,e.bindModelPrototype=we,e.bulkModelRegister=(...e)=>{e.forEach(e=>{const t=e.constructor?e.constructor:e;ne.register(t,e.name)})},e.checkType=x,e.checkTypes=F,e.construct=Ie,e.date=Ae,e.dateFromFormat=b,e.diff=Se,e.email=Te,e.eq=_e,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.gt=Pe,e.gte=Le,e.hashCode=R,e.hashObj=v,e.hashedBy=(r,...a)=>t.metadata(e.ModelKeys.HASHING,{algorithm:r,args:a}),e.innerValidationDecorator=ue,e.isEqual=S,e.isGreaterThan=C,e.isLessThan=H,e.isValidDate=A,e.isValidForGteOrLteComparison=U,e.jsTypes=ae,e.list=Oe,e.lt=Re,e.lte=ve,e.max=ge,e.maxlength=me,e.min=he,e.minlength=ye,e.model=je,e.modelBaseDecorator=Ve,e.option=De,e.parseDate=_,e.password=Ne,e.pattern=Ee,e.regexpParser=de,e.required=fe,e.serializedBy=(r,...a)=>t.metadata(e.ModelKeys.SERIALIZATION,{serializer:r,args:a}),e.set=(e,t=h.LIST)=>Oe(e,"Set",t),e.sf=y,e.step=pe,e.stringFormat=p,e.toConditionalPromise=k,e.twoDigitPad=N,e.type=Me,e.url=be,e.validate=ee,e.validateChildValue=W,e.validateDecorator=Z,e.validateDecorators=J,e.validationMetadata=le,e.validator=ce,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{constructor(){}preSerialize(r){const a=Object.assign({},r);let s;try{s=t.Metadata.modelName(r.constructor)}catch(e){s=void 0}return a[e.ModelKeys.ANCHOR]=s||r.constructor.name,a}deserialize(t){const r=JSON.parse(t),a=r[e.ModelKeys.ANCHOR];if(!a)throw Error("Could not find class reference in serialized model");return oe.build(r,a)}serialize(e){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 y=p,m={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),y=12>i?"AM":"PM",m=f[e.getDay()],E=m.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",m).replace("EEE",E).replace("yyyy",_).replace("yy",S).replace("aaa",y)).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(y("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(y("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&=t;return t.toString()}function v(e){const t=(e,t)=>{const r=a(t);return"string"==typeof r?a((e||"")+a(t)):(e=((e=e||0)<<5)-e+r)&e},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],I=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw Error(y(m.PROPERTY_NOT_EXIST,t));return e[t]};class w{static create(e,t){const{getValue:r,getParent:a,ignoreUndefined:s,ignoreNull:i}={getParent:D,getValue:I,ignoreNull:!1,ignoreUndefined:!1,...t};return new Proxy({},{get:(t,n)=>"getValueFromPath"===n?t=>{const n=w.parsePath(t);let o=e;for(let e=0;e<n.length;e++){const c=n[e];if(".."===c){const r=a(o);if(!r||"object"!=typeof r)throw Error(y(m.CONTEXT_NOT_OBJECT_COMPARISON,e+1,t));o=r;continue}if(o=r(o,c),!s&&void 0===o)throw Error(y(m.PROPERTY_INVALID,t,c));if(!i&&null===o)throw Error(y(m.PROPERTY_INVALID,t,c))}return o}:t[n]})}static parsePath(e){if("string"!=typeof e||!e.trim())throw Error(y(m.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(y(m.UNSUPPORTED_TYPES_COMPARISON,V(e),V(t)))}function H(e,t){if([null,void 0].includes(e)||[null,void 0].includes(t))throw Error(m.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(y(m.TYPE_MISMATCH_COMPARISON,r,a))}if("number"===r&&"number"===a||"bigint"===r&&"bigint"===a){if(Number.isNaN(e)||Number.isNaN(t))throw new TypeError(m.NAN_COMPARISON);return t>e}if(e instanceof Date&&t instanceof Date){if(isNaN(e.getTime())||isNaN(t.getTime()))throw new TypeError(m.INVALID_DATE_COMPARISON);return e.getTime()<t.getTime()}throw new TypeError(y(m.UNSUPPORTED_TYPES_COMPARISON,V(e),V(t)))}function C(e,t){if([null,void 0].includes(e)||[null,void 0].includes(t))throw Error(m.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(y(m.TYPE_MISMATCH_COMPARISON,r,a))}if("number"===r&&"number"===a||"bigint"===r&&"bigint"===a){if(Number.isNaN(e)||Number.isNaN(t))throw new TypeError(m.NAN_COMPARISON);return e>t}if(e instanceof Date&&t instanceof Date){if(isNaN(e.getTime())||isNaN(t.getTime()))throw new TypeError(m.INVALID_DATE_COMPARISON);return e.getTime()>t.getTime()}throw new TypeError(y(m.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 y(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=oe.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(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=w.create(t,{ignoreUndefined:!0,ignoreNull:!0}),c=a.key===e.ModelKeys.TYPE?n[0]:n;return k(i.hasErrors(r,c,o),s)}function J(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=Z(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=>oe.isModel(e)?W(r,e,t,a.flat(),!!i,...n):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 ee(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,designType:h}=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 g=J(r,i,d,l,a,...s)||{},p=oe.isPropertyModel(r,i),y=null!=d,m=y&&oe.isModel(d);if(p&&y&&m){const t=d;if(oe.shouldValidateNestedHandler(r,i)){const n=(Array.isArray(h)?f:[h]).map(e=>("function"!=typeof e||e.name||(e=e()),oe.get(e.name||e))).find(e=>!!e);n&&t instanceof n?o[i]=X(t,r,a,...s):(g[u.TYPE]=n?"Value must be an instance of "+n.name:`Unable to verify type consistency, missing model registry for ${f.toString()} on prop ${i}`,delete g[e.ModelKeys.TYPE])}}(Object.keys(g).length>0||a)&&(n[i]=g),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 te;e.Primitives=void 0,(te=e.Primitives||(e.Primitives={})).STRING="string",te.NUMBER="number",te.BOOLEAN="boolean",te.BIGINT="bigint";const re={STRING:String,OBJECT:Object,NUMBER:Number,BOOLEAN:Boolean,BIGINT:BigInt,DATE:Date},ae=["string","array","number","boolean","symbol","function","object","undefined","null","bigint"];let se,ie;class ne{constructor(e=oe.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 oe{constructor(e=void 0){}isAsync(){return!!(this[T]??this?.constructor[T])}hasErrors(...e){return ee(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(S(this[s],e[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(oe.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 oe&&e[s][r]instanceof oe?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 oe.serialize(this)}toString(){return this.constructor.name+": "+JSON.stringify(this,void 0,2)}hash(){return oe.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 oe.getAttributes(e))e[r]=t[r]??e[r]??void 0;return e}static fromModel(e,r){let a;r||(r={});const s=oe.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=oe.isPropertyModel(e,o);if(s){try{e[o]=oe.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(re);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=>!ae.includes(e.name));if("Array"===r.name&&(e[o]=e[o].map(e=>["object","function"].includes(typeof e)&&s?oe.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(oe.build(r,s.name)):t.add(r);e[o]=t}break}default:void 0!==e[o]&&oe.get(r.name)&&(e[o]=oe.build(e[o],r.name))}}catch(e){}})}return e}static setBuilder(e){se=e}static getBuilder(){return se||oe.fromModel}static getRegistry(){return ie||(ie=new ne),ie}static setRegistry(e){ie=e}static register(e,t){return oe.getRegistry().register(e,t)}static get(e){return oe.getRegistry().get(e)}static build(e={},t){return oe.getRegistry().build(e,t)}static getAttributes(e){const r=e instanceof oe?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 ee(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 oe)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(oe.isModel(e[r]))return!0;const a=t.Metadata.type(e.constructor,r);return a&&oe.get(a.name)?a.name:void 0}static describe(e,r){return t.Metadata.description(e,r)}static{this.shouldValidateNestedHandler=(e,t)=>{const r=e[t];return!!r&&"object"==typeof r&&"function"==typeof r.hasErrors}}}function ce(...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]!==re.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([...oe.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([ce(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([ce(u.DIFF),r.__metadata("design:paramtypes",[String])],e.DiffValidator);const de=RegExp("^/(.+)/([gimus]*)$");function ue(e,r,a){return t.apply(t.propMetadata(r,a))}function le(e,t,r){return K.registerDecorator(t,e),(e,a)=>ue(0,`${u.REFLECT}.${a}.${t}`,r)(e,a)}function fe(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:le,args:[fe,r,a]}).apply()}function he(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:le,args:[he,a,s]}).apply()}function ge(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:le,args:[ge,a,s]}).apply()}function pe(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:le,args:[pe,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:le,args:[ye,a,s]}).apply()}function me(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:le,args:[me,a,s]}).apply()}function Ee(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:le,args:[Ee,a,s]}).apply()}function Te(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:le,args:[Te,r,a]}).apply()}function be(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:le,args:[be,r,a]}).apply()}function Me(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:le,args:[Me,a,s]}).apply()}function Ae(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)}}),le(Ae,a,r)(t,s)}},args:[e,r]}).apply()}function Ne(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:le,args:[Ne,a,s]}).apply()}function Oe(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:le,args:[Oe,s,i]}).apply()}function _e(e,t){return le(_e,u.EQUALS,{label:t?.label||e,message:t?.message||h.EQUALS,[u.EQUALS]:e,description:"defines attribute as equal to "+e,async:!1})}function Se(e,t){return le(Se,u.DIFF,{label:t?.label||e,message:t?.message||h.DIFF,[u.DIFF]:e,description:"defines attribute as different to "+e,async:!1})}function Re(e,t){return le(Re,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 ve(e,t){return le(ve,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 Pe(e,t){return le(Pe,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 Le(e,t){return le(Le,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 De(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:le,args:[De,a,s]}).apply()}function Ie(e,...t){const r=(...t)=>new e(...t);return r.prototype=e.prototype,r(...t)}function we(e){if(e instanceof oe)return;function t(e,t){Object.setPrototypeOf(e,t)}const r=Object.getPrototypeOf(e);if(r===Object.prototype)return t(e,oe.prototype);for(;r!==Object.prototype;){const e=Object.getPrototypeOf(r);if(e===Object.prototype||Object.getPrototypeOf(e)===Object.prototype)return t(r,oe.prototype)}throw Error("Could not find proper prototype to bind")}function Ve(r){const a=(...e)=>{const t=Ie(r,...e);we(t);const a=oe.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),oe.register(a,r.name),a}function je(){const r=e.ModelKeys.MODEL;return t.Decoration.for(r).define(Ve).apply()}e.PatternValidator=class extends Y{constructor(e=h.PATTERN){super(e,"string")}getPattern(e){if(!de.test(e))return RegExp(e);const t=e.match(de);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([ce(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([ce(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([ce(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(!C(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([ce(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)||C(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([ce(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(!H(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([ce(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)||H(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([ce(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([ce(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([ce(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([ce(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([ce(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([ce(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([ce(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([ce(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([ce(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([ce(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([ce(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([ce(u.URL),r.__metadata("design:paramtypes",[String])],e.URLValidator);class Ue{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=Ue.asMeta(e),r="string"==typeof e?e:Ue.resolveMessage(t);return this.decorate(fe(r))}min(e,t){const r=Ue.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(he(a,Ue.resolveMessage(r,t)))}max(e,t){const r=Ue.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(ge(a,Ue.resolveMessage(r,t)))}step(e,t){const r=Ue.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(pe(a,Ue.resolveMessage(r,t)))}minlength(e,t){const r=Ue.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,Ue.resolveMessage(r,t)))}maxlength(e,t){const r=Ue.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(me(a,Ue.resolveMessage(r,t)))}pattern(e,t){const r=Ue.asMeta(e),a=r?.[u.PATTERN]??(r?void 0:e),s=Ue.patternFromString(a)??/.*/;return this.decorate(Ee(s,Ue.resolveMessage(r,t)))}email(e){const t=Ue.asMeta(e),r="string"==typeof e?e:Ue.resolveMessage(t);return this.decorate(Te(r))}url(e){const t=Ue.asMeta(e),r="string"==typeof e?e:Ue.resolveMessage(t);return this.decorate(be(r))}type(e,t){const r=Ue.asMeta(e),a=r?.customTypes??r?.type??(r?void 0:e);return this.decorate(Me(a,Ue.resolveMessage(r,t)))}date(e,t){const r=Ue.asMeta(e),a=r?.[u.FORMAT]??(r?void 0:e);return this.decorate(Ae(a,Ue.resolveMessage(r,t)))}password(e,t){const r=Ue.asMeta(e),a=r?.[u.PATTERN]??(r?void 0:e),s=Ue.patternFromString(a);return this.decorate(Ne(s,Ue.resolveMessage(r,t)))}list(e,t,r){const a=Ue.asMeta(e),s=a?.clazz??(a?void 0:e),i=a?.type??t;return this.decorate(Oe(s,i,Ue.resolveMessage(a,r)))}set(e,t){return Ue.isMetadataPayload(e)?this.list(e):this.list(e,"Set",t)}enum(e,t){const r=Ue.asMeta(e),a=r?.[u.ENUM]??(r?void 0:e);return this.decorate(De(a,Ue.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 Ue.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=Ue.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(_e(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(Se(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(Re(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(ve(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(Pe(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(Le(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=Ce.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 Ce 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 Ue(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 Ce;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??oe;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=je()(r);return this._description&&(a=t.description(this._description)(a)),a}static builder(){return new Ce}static from(e,t){if(!e)throw Error("metadata is required");const r=Ce.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 xe="##VERSION##",Fe="##PACKAGE##";t.Metadata.registerLibrary(Fe,xe),e.ASYNC_META_KEY=T,e.AsyncValidator=class extends ${constructor(e=h.DEFAULT,...t){super(!0,e,...t)}},e.AttributeBuilder=Ue,e.COMPARISON_ERROR_MESSAGES=m,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=oe,e.ModelBuilder=Ce,e.ModelErrorDefinition=c,e.ModelRegistryManager=ne,e.PACKAGE_NAME=Fe,e.PathProxyEngine=w,e.ReservedModels=re,e.Serialization=o,e.VALIDATION_PARENT_KEY=E,e.VERSION=xe,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=we,e.bulkModelRegister=(...e)=>{e.forEach(e=>{const t=e.constructor?e.constructor:e;oe.register(t,e.name)})},e.checkType=x,e.checkTypes=F,e.construct=Ie,e.date=Ae,e.dateFromFormat=b,e.diff=Se,e.email=Te,e.eq=_e,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.gt=Pe,e.gte=Le,e.hashCode=R,e.hashObj=v,e.hashedBy=(r,...a)=>t.metadata(e.ModelKeys.HASHING,{algorithm:r,args:a}),e.innerValidationDecorator=le,e.isEqual=S,e.isGreaterThan=C,e.isLessThan=H,e.isValidDate=A,e.isValidForGteOrLteComparison=U,e.jsTypes=ae,e.list=Oe,e.lt=Re,e.lte=ve,e.max=ge,e.maxlength=me,e.min=he,e.minlength=ye,e.model=je,e.modelBaseDecorator=Ve,e.option=De,e.parseDate=_,e.password=Ne,e.pattern=Ee,e.regexpParser=de,e.required=fe,e.serializedBy=(r,...a)=>t.metadata(e.ModelKeys.SERIALIZATION,{serializer:r,args:a}),e.set=(e,t=h.LIST)=>Oe(e,"Set",t),e.sf=y,e.step=pe,e.stringFormat=p,e.toConditionalPromise=k,e.twoDigitPad=N,e.type=Me,e.url=be,e.validate=ee,e.validateChildValue=W,e.validateDecorator=Z,e.validateDecorators=J,e.validationMetadata=ue,e.validator=ce,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);
2
2
  //# sourceMappingURL=decorator-validation.cjs.map