Skip to content

Commit

Permalink
fix: maxQueryLimit must be > 0
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Feb 4, 2021
1 parent 63e6c4d commit a3d9156
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class Config extends ConfigFile<ConfigFile.Options> {
input: {
// the bit shift will remove the negative bit, and any decimal numbers
// then the parseFloat will handle converting it to a number from a string
validator: (value) => (value as number) >>> 0 === parseFloat(value as string),
validator: (value) => (value as number) >>> 0 === parseFloat(value as string) && (value as number) > 0,
get failedMessage() {
return Config.messages?.getMessage('InvalidNumberConfigValue');
},
Expand Down
9 changes: 9 additions & 0 deletions test/unit/config/configTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,15 @@ describe('Config', () => {
expect(err).to.have.property('name', 'InvalidConfigValue');
}
});
it('will throw an error when value is 0', async () => {
const config: Config = await Config.create(Config.getDefaultOptions(true));
try {
config.set('maxQueryLimit', '0');
assert.fail('Expected an error to be thrown.');
} catch (err) {
expect(err).to.have.property('name', 'InvalidConfigValue');
}
});
it('will set config value with stringified number', async () => {
const config: Config = await Config.create(Config.getDefaultOptions(true));
const res = config.set('maxQueryLimit', '123');
Expand Down

0 comments on commit a3d9156

Please sign in to comment.