Skip to content

fix: prevent negative/zero amounts and add Reset Form button (#90) - #91

Open
amanvatss wants to merge 1 commit into
rahulhaque:masterfrom
amanvatss:fix/amount-validation-and-reset-form
Open

fix: prevent negative/zero amounts and add Reset Form button (#90)#91
amanvatss wants to merge 1 commit into
rahulhaque:masterfrom
amanvatss:fix/amount-validation-and-reset-form

Conversation

@amanvatss

Copy link
Copy Markdown

Changes

Closes #90

Bug Fix: Amount Validation

  • Enforces strictly positive numbers on all expense and income forms
  • Users now see a clear error message if they enter 0 or a negative value
  • Fixes inconsistency where Expense.jsx and Income.jsx used yup.string() while EditExpense.jsx and EditIncome.jsx used yup.number() for the same amount field

New Feature: Reset Form Button

  • Adds a secondary "Reset" button to the Add Expense and Add Income forms
  • Clicking it instantly clears all form fields using react-hook-form's reset() method
  • Disabled during form submission to prevent accidental resets

Files Changed

  • src/app/expense/Expense.jsx
  • src/app/expense/EditExpense.jsx
  • src/app/income/Income.jsx
  • src/app/income/EditIncome.jsx

…que#90)

- Update yup validation schemas in Expense.jsx, EditExpense.jsx,
  Income.jsx, and EditIncome.jsx to use number().positive() for the
  amount field, preventing zero or negative values from being submitted

- Add a secondary "Reset" button next to the submit button in the
  Add Expense and Add Income forms, bound to react-hook-form's reset()

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: Prevent negative/zero amounts and add "Reset Form" functionality to transaction forms

1 participant