From d148f89692eb82513bb7b868aa90749f2dfb1b33 Mon Sep 17 00:00:00 2001 From: Govorunb Date: Fri, 14 Jun 2024 03:39:46 +1000 Subject: [PATCH] actually test --- ebs/src/modules/transactions.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ebs/src/modules/transactions.ts b/ebs/src/modules/transactions.ts index 3da2cfd..6c322eb 100644 --- a/ebs/src/modules/transactions.ts +++ b/ebs/src/modules/transactions.ts @@ -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 @@ -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`; } @@ -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) {