Skip to content

Commit

Permalink
fix(lib): update validation for e-net
Browse files Browse the repository at this point in the history
- error out when 'energy-per-gb' is 0
  • Loading branch information
manushak committed Mar 30, 2024
1 parent 12b6a46 commit b6f505d
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/lib/e-net/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,12 @@ export const ENet = (globalConfig: ConfigParams): PluginInterface => {
*/
const validateConfig = () => {
const schema = z.object({
'energy-per-gb': z.number(),
'energy-per-gb': z.number().gt(0),
});

// Manually add default value from CCF: https://www.cloudcarbonfootprint.org/docs/methodology/#chosen-coefficient
const energyPerGB =
!globalConfig ||
!globalConfig['energy-per-gb'] ||
globalConfig['energy-per-gb'] === 0
? 0.001
: globalConfig['energy-per-gb'];
(globalConfig && globalConfig['energy-per-gb']) ?? 0.001;

return validate<z.infer<typeof schema>>(schema, {
...globalConfig,
Expand Down

0 comments on commit b6f505d

Please sign in to comment.