"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseRuleHandler=void 0;const t=require("../../common/message");exports.BaseRuleHandler=class{constructor(t){this.rule=void 0,this.next=void 0,this.rule=t}isObjectAttr(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t}validate(t,e,r){const s=e.split(".");s.length>1?this.validateObject(t,s):(this.rule&&this.rule.validate(t,e,r),this.next&&this.next.validate(t,e,r))}validateObject(t,e){t=this.getObjectValueByAttrName(t,e);const r=e[e.length-1],s=e.join(".");this.rule&&this.rule.validate(t,r,s),this.next&&this.next.validate(t,r,s)}getObjectValueByAttrName(e,r){for(let s=0;s<r.length-1;s++){const i=e[r[s]];if(!this.isObjectAttr(i))throw new Error((0,t.format)(t.Messages.Validator.AttributeTypeError,{attrName:`${r[s]}`}));e=i}return e}setNext(t){this.next=t}getNext(){return this.next}getTail(){if(!this.next)return this;let t=this.next;for(;t&&t.getNext();)t=t.getNext();return t}};