Skip to content

Commit

Permalink
Merge pull request #244 from DestinyItemManager/opt-tier-validate
Browse files Browse the repository at this point in the history
Validate optimizer tiers
  • Loading branch information
bhollis authored Oct 21, 2024
2 parents 3d294bd + 70b3776 commit bc2e0eb
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions api/routes/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,27 @@ export function validateLoadout(metricPrefix: string, loadout: Loadout, appId: s
message: 'Item ID is invalid',
};
}
for (const constraint of loadout.parameters?.statConstraints ?? []) {
for (const tier of [constraint.minTier, constraint.maxTier]) {
if (tier === undefined) {
continue;
}
if (!Number.isInteger(tier)) {
metrics.increment(`${metricPrefix}.validation.tierValueNotInteger.count`);
return {
status: 'InvalidArgument',
message: 'Loadout Optimizer stat tiers must be integers, not ${tier}',
};
}
if (tier < 0 || tier > 10) {
metrics.increment(`${metricPrefix}.validation.tierValueOutOfRange.count`);
return {
status: 'InvalidArgument',
message: 'Loadout Optimizer stat tiers must be between 0 and 10',
};
}
}
}

return undefined;
}
Expand Down

0 comments on commit bc2e0eb

Please sign in to comment.