Skip to content

Commit

Permalink
Improve throughput validation message (#2182)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonYeMSFT authored Sep 21, 2023
1 parent 2841a1c commit 10fd538
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/docdb/tree/DocDBDatabaseTreeItemBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { DocDBTreeItemBase } from './DocDBTreeItemBase';
const minThroughputFixed: number = 400;
const minThroughputPartitioned: number = 400;
const maxThroughput: number = 100000;
const throughputStepSize = 100;

/**
* This class provides common logic for DocumentDB, Graph, and Table databases
Expand Down Expand Up @@ -98,7 +99,7 @@ export abstract class DocDBDatabaseTreeItemBase extends DocDBTreeItemBase<Contai
const minThroughput = isFixed ? minThroughputFixed : minThroughputPartitioned;
const throughput: number = Number(await context.ui.showInputBox({
value: minThroughput.toString(),
prompt: `Initial throughput capacity, between ${minThroughput} and ${maxThroughput}`,
prompt: `Initial throughput capacity, between ${minThroughput} and ${maxThroughput} inclusive in increments of ${throughputStepSize}`,
stepName: 'throughputCapacity',
validateInput: (input: string) => validateThroughput(isFixed, input)
}));
Expand All @@ -125,8 +126,8 @@ function validateThroughput(isFixed: boolean, input: string): string | undefined
try {
const minThroughput = isFixed ? minThroughputFixed : minThroughputPartitioned;
const value = Number(input);
if (value < minThroughput || value > maxThroughput) {
return `Value must be between ${minThroughput} and ${maxThroughput}`;
if (value < minThroughput || value > maxThroughput || (value - minThroughput) % throughputStepSize !== 0) {
return `Value must be between ${minThroughput} and ${maxThroughput} in increments of ${throughputStepSize}`;
}
} catch (err) {
return "Input must be a number";
Expand Down

0 comments on commit 10fd538

Please sign in to comment.