// SaveMyToken local lab. Run with Node.js 22 or newer. import assert from "node:assert/strict"; function validate(raw) { try { const value = JSON.parse(raw); return value !== null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 2 && typeof value.answer === "string" && value.answer.length <= 200 && Number.isInteger(value.days) && value.days >= 0 && value.days <= 365; } catch { return false; } } const inputs = [ '{"answer":"Unused items only","days":30}', '{"answer":"Unused items only","days":"30"}', '{"answer":"Unused items only","days":30,"execute":"refund"}', 'Here is your JSON: {"days":30}', ]; const results = inputs.map(validate); assert.deepEqual(results, [true, false, false, false]); console.log("Valid responses:", results.join(", "));