Skip to content

Commit

Permalink
#210: Validate carb ratios are reasonable
Browse files Browse the repository at this point in the history
  • Loading branch information
scottleibrand committed Sep 16, 2016
1 parent 07dea9b commit 032a44f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/profile/carbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ function carbRatioLookup (inputs, profile) {
for (var i = 0; i < carbratio_data.schedule.length - 1; i++) {
if ((now >= getTime(carbratio_data.schedule[i].offset)) && (now < getTime(carbratio_data.schedule[i + 1].offset))) {
carbRatio = carbratio_data.schedule[i];
// disallow impossibly high/low carbRatios due to bad decoding
if (carbRatio < 3 || carbRatio > 150) {
console.error("Error: carbRatio of " + carbRatio + " out of bounds.");
return;
}
break;
}
}
Expand Down

0 comments on commit 032a44f

Please sign in to comment.