"use strict";
// SPDX-License-Identifier: Apache-2.0
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.InterestRate = void 0;
const ValidatedArgs_1 = __importDefault(require("../../../core/validation/ValidatedArgs"));
const FormatValidation_1 = __importDefault(require("../../../port/in/request/FormatValidation"));
const InvalidNegativeRate_1 = require("./error/InvalidNegativeRate");
class InterestRate extends ValidatedArgs_1.default {
    maxRate;
    baseRate;
    minRate;
    startPeriod;
    startRate;
    missedPenalty;
    reportPeriod;
    rateDecimals;
    constructor(maxRate, baseRate, minRate, startPeriod, startRate, missedPenalty, reportPeriod, rateDecimals) {
        super({
            baseRate: FormatValidation_1.default.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;
        ValidatedArgs_1.default.handleValidation(InterestRate.name, this);
    }
    static checkRate(value) {
        const errorList = [];
        if (value < 0) {
            errorList.push(new InvalidNegativeRate_1.InvalidNegativeRate(value));
        }
        return errorList;
    }
}
exports.InterestRate = InterestRate;
