Skip to content

Commit

Permalink
actually test
Browse files Browse the repository at this point in the history
  • Loading branch information
Govorunb committed Jun 13, 2024
1 parent c04d7f9 commit d148f89
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions ebs/src/modules/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,16 @@ function validateArgs(config: Config, cart: Cart, logContext: LogMessage): strin
const value = cart.args[arg.name];
if (!value) {
if (!arg.required) continue;

// LiteralTypes.Boolean
if (arg.type === 3) {
// HTML form conventions - false is not transmitted, true is "on" (to save 2 bytes i'm guessing)
continue;
}

return `Missing required argument ${arg.name}`;
}
let parsed: number;
switch (arg.type) {
// esbuild dies if you use enums
// so we have to use their pure values instead
Expand All @@ -310,7 +317,7 @@ function validateArgs(config: Config, cart: Cart, logContext: LogMessage): strin
break;
case 1: // LiteralTypes.Integer
case 2: // LiteralTypes.Float
let parsed = parseInt(value);
parsed = parseInt(value);
if (Number.isNaN(parsed)) {
return `Argument ${arg.name} is not a number`;
}
Expand All @@ -323,9 +330,13 @@ function validateArgs(config: Config, cart: Cart, logContext: LogMessage): strin
}
break;
case 3: // LiteralTypes.Boolean
if (typeof value !== "boolean" && value !== "true" && value !== "false") {
if (typeof value !== "boolean" && value !== "true" && value !== "false" && value !== "on") {
return `Argument ${arg.name} not a boolean`;
}
if (value === "on") {
cart.args[arg.name] = true;
console.log(cart);
}
break;
case 4: // LiteralTypes.Vector
if (!Array.isArray(value) || value.length != 3) {
Expand Down

0 comments on commit d148f89

Please sign in to comment.