// SPDX-License-Identifier: Apache-2.0
import ValidatedDomain from "../../../core/validation/ValidatedArgs";
import { SecurityDate } from "../shared/SecurityDate";
import { InvalidNegativeRate } from "./error/InvalidNegativeRate";
export class BondFixedRateDetails extends ValidatedDomain {
    currency;
    nominalValue;
    nominalValueDecimals;
    startingDate;
    maturityDate;
    rate;
    rateDecimals;
    constructor(currency, nominalValue, nominalValueDecimals, startingDate, maturityDate, rate, rateDecimals) {
        super({
            maturityDate: (val) => {
                return 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;
        ValidatedDomain.handleValidation(BondFixedRateDetails.name, this);
    }
    static checkRate(value) {
        const errorList = [];
        if (value < 0) {
            errorList.push(new InvalidNegativeRate(value));
        }
        return errorList;
    }
}
