Skip to content

Commit

Permalink
Fix validation issues for number configuration values
Browse files Browse the repository at this point in the history
fixes #578
  • Loading branch information
cdupuis committed Nov 24, 2018
1 parent ebd2376 commit 14715d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/api/machine/ConfigurationValues.ts
Expand Up @@ -54,7 +54,7 @@ export function validateConfigurationValues(config: any, options: ConfigurationV
} else {
switch (type) {
case ConfigurationValueType.Number:
if (!Number.isNaN(value)) {
if (typeof value !== "number") {
invalidValues.push(`${path} ${JSON.stringify(value)} is not a 'number'`);
}
break;
Expand Down
Expand Up @@ -131,4 +131,15 @@ describe("validateConfigurationValues", () => {
}
done();
});

it("should validate value with correct number type", done => {
const config = { sdm: { test: 3 } };
const requiredValues = [{ path: "sdm.test", type: ConfigurationValueType.Number }];
try {
validateConfigurationValues(config, { requiredConfigurationValues: requiredValues });
} catch (err) {
assert.fail();
}
done();
});
});

0 comments on commit 14715d8

Please sign in to comment.