Skip to content

Commit

Permalink
Add validation to ensure principal and date arrays have equal lengths…
Browse files Browse the repository at this point in the history
… in SimObject class
  • Loading branch information
77it committed Jan 6, 2025
1 parent 40b884b commit b41274c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/engine/simobject/simobject.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ class SimObject {
p.bs_Principal__PrincipalToPay_AmortizationSchedule__Principal.reduce((a, b) => a + b, 0n))
throw new Error(`value must be equal to indefinite + principal, got ${p.value} !== ${p.bs_Principal__PrincipalToPay_IndefiniteExpiryDate} + ${p.bs_Principal__PrincipalToPay_AmortizationSchedule__Principal.reduce((a, b) => a + b, 0n)}`);

// length of principal arrays must be equal
if (p.bs_Principal__PrincipalToPay_AmortizationSchedule__Date.length !== p.bs_Principal__PrincipalToPay_AmortizationSchedule__Principal.length)
throw new Error(`length of principal arrays must be equal, got date = ${p.bs_Principal__PrincipalToPay_AmortizationSchedule__Date.length}, principal = ${p.bs_Principal__PrincipalToPay_AmortizationSchedule__Principal.length}`);

// length of metadata arrays must be equal
if (p.metadata__Name.length !== p.metadata__Value.length || p.metadata__Name.length !== p.metadata__PercentageWeight.length)
throw new Error(`length of metadata arrays must be equal, got name = ${p.metadata__Name.length}, value = ${p.metadata__Value.length}, weight= ${p.metadata__PercentageWeight.length}`);
Expand Down

0 comments on commit b41274c

Please sign in to comment.