diff --git a/src/config/config.ts b/src/config/config.ts index 49be8342b5..c15ef74c15 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -183,7 +183,7 @@ export class Config extends ConfigFile { 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'); }, diff --git a/test/unit/config/configTest.ts b/test/unit/config/configTest.ts index 2b0c1ed895..00fcecad8c 100644 --- a/test/unit/config/configTest.ts +++ b/test/unit/config/configTest.ts @@ -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');