"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.BondFixedRateDetails = void 0;
const ValidatedArgs_1 = __importDefault(require("../../../core/validation/ValidatedArgs"));
const SecurityDate_1 = require("../shared/SecurityDate");
const InvalidNegativeRate_1 = require("./error/InvalidNegativeRate");
class BondFixedRateDetails extends ValidatedArgs_1.default {
    currency;
    nominalValue;
    nominalValueDecimals;
    startingDate;
    maturityDate;
    rate;
    rateDecimals;
    constructor(currency, nominalValue, nominalValueDecimals, startingDate, maturityDate, rate, rateDecimals) {
        super({
            maturityDate: (val) => {
                return SecurityDate_1.SecurityDate.checkDateTimestamp(val, this.startingDate);
            },
            rateDecimals: (_) => {
                return BondFixedRateDetails.checkRate(this.rateDecimals);
            },
        });
        this.currency = currency;
        this.nominalValue = nominalValue;
        this.nominalValueDecimals = nominalValueDecimals;
        this.startingDate = startingDate;
        this.maturityDate = maturityDate;
        this.rate = rate;
        this.rateDecimals = rateDecimals;
        ValidatedArgs_1.default.handleValidation(BondFixedRateDetails.name, this);
    }
    static checkRate(value) {
        const errorList = [];
        if (value < 0) {
            errorList.push(new InvalidNegativeRate_1.InvalidNegativeRate(value));
        }
        return errorList;
    }
}
exports.BondFixedRateDetails = BondFixedRateDetails;
