// SPDX-License-Identifier: Apache-2.0
import ValidatedDomain from "../../../core/validation/ValidatedArgs";
import FormatValidation from "../../../port/in/request/FormatValidation";
import { InvalidNegativeRate } from "./error/InvalidNegativeRate";
export class InterestRate extends ValidatedDomain {
    maxRate;
    baseRate;
    minRate;
    startPeriod;
    startRate;
    missedPenalty;
    reportPeriod;
    rateDecimals;
    constructor(maxRate, baseRate, minRate, startPeriod, startRate, missedPenalty, reportPeriod, rateDecimals) {
        super({
            baseRate: FormatValidation.checkNumber({
                max: maxRate,
                min: minRate,
            }),
            rateDecimals: (_) => {
                return InterestRate.checkRate(this.rateDecimals);
            },
        });
        this.maxRate = maxRate;
        this.baseRate = baseRate;
        this.minRate = minRate;
        this.startPeriod = startPeriod;
        this.startRate = startRate;
        this.missedPenalty = missedPenalty;
        this.reportPeriod = reportPeriod;
        this.rateDecimals = rateDecimals;
        ValidatedDomain.handleValidation(InterestRate.name, this);
    }
    static checkRate(value) {
        const errorList = [];
        if (value < 0) {
            errorList.push(new InvalidNegativeRate(value));
        }
        return errorList;
    }
}
