Skip to content

bug: budget step validation doesn't catch NaN, letting "NaN" reach the escrow review total #144

Description

@JamesVictor-O

Problem

The campaign budget step's validation doesn't catch NaN, letting a broken budget value silently reach the final review screen.

components/campaigns/new/steps/step-budget.tsx:

<input type="number" min={0} value={data.totalBudget || ""}
  onChange={(e) => update({ totalBudget: Number(e.target.value) })} .../>

components/dashboard/business/campaign-wizard-modal.tsx:

if (state.budget.totalBudget <= 0) errors.totalBudget = "Budget must be greater than 0.";

Typing a lone - (or any non-numeric string) into the budget field yields Number("-") === NaN. Since NaN <= 0 evaluates to false in JavaScript, this validation is silently bypassed. The input visually clears (NaN || "" renders empty), so it looks like nothing happened — but state.budget.totalBudget is now NaN, and clicking "Next Step" proceeds past step 3 with no error shown.

Concrete failure scenario

  1. User types - into "Total Campaign Budget." The field looks empty.
  2. Validation passes (NaN <= 0 is false), so "Next Step" advances normally.
  3. The Review step (step-review-fund.tsx) renders total.toLocaleString() — showing "NaN" / "≈ $NaN USD" as the amount to lock in escrow, an unmistakably broken value on the last screen before a funding action.

Expected behaviour

Validate with Number.isFinite(state.budget.totalBudget) && state.budget.totalBudget > 0 instead of a bare <= 0 comparison, so non-numeric input is caught with a clear inline error instead of silently passing through as NaN.

Files

  • components/dashboard/business/campaign-wizard-modal.tsxvalidateStep
  • components/campaigns/new/steps/step-budget.tsx — input handling

Acceptance criteria

  • Typing non-numeric input (e.g. a lone -) into the budget field produces a visible validation error, not a silent pass-through
  • The wizard cannot advance past the budget step with a NaN totalBudget
  • The Review step never renders "NaN" for the budget total

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignThird CampaignCampaign: Third CampaignbugSomething isn't workingfrontendFrontend UI/UX work

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions