fix(standing-instruction): reject non-positive and non-numeric amounts
The amount validation in AddEditSIViewModel used any { !it.isDigit() } to catch invalid input, but isDigit() returns false for ., so any decimal amount like 10.50 was rejected with "Amount is Invalid" even though the amount field uses KeyboardType.Number which allows decimal separators.
Replaced the character-level digit check with toDoubleOrNull() == null for format validation, and added a <= 0 guard to reject zero and negative amounts. The null-path message is corrected to "Amount is Invalid" rather than the previous "Amount is Required".
Tested manually by entering 10.50, 0, -5, and abc in the standing instruction form to confirm each case is handled correctly.
Summary by CodeRabbit
- Bug Fixes
- Improved amount field validation in Standing Instructions to provide clearer error messages and prevent invalid amounts (zero or negative values).
No actionable comments were generated in the recent review. π
βΉοΈ Recent review info
βοΈ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 28b82a1a-f587-4012-a62e-b9c5754e4e94
π₯ Commits
Reviewing files that changed from the base of the PR and between d399e0a61f1e1c1a46ba5226f866dace21f2a7d2 and f30639e046077b170984c3075e17272a3e638542.
π Files selected for processing (1)
feature/standing-instruction/src/commonMain/kotlin/org/mifospay/feature/standing/instruction/createOrUpdate/AddEditSIViewModel.kt
π Walkthrough
Walkthrough
This PR updates amount validation in standing instruction creation to strengthen input validation. The change replaces digit-only checking with floating-point numeric parsing and adds a guard to reject zero or negative amounts.
Changes
Standing Instruction Amount Validation
| Layer / File(s) | Summary |
|---|---|
Amount validation with numeric and positive checks feature/standing-instruction/src/commonMain/kotlin/org/mifospay/feature/standing/instruction/createOrUpdate/AddEditSIViewModel.kt |
Amount validation in add mode now uses toDoubleOrNull() to parse numeric input with "Amount is Invalid" error messaging, and rejects non-positive values with "Amount must be greater than 0". |
Estimated code review effort
π― 1 (Trivial) | β±οΈ ~5 minutes
Poem
A standing instruction stands tall and true,
When amounts are checked, both old and new.
No zeros creeping, no negatives here,
Just valid numbers, loud and clear! π°β¨
π₯ Pre-merge checks | β 4 | β 1
β Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | β οΈ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
β Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | β Passed | Check skipped - CodeRabbitβs high-level summary is enabled. |
| Title check | β Passed | The PR title accurately and specifically describes the main change: fixing standing instruction amount validation to reject non-positive and non-numeric amounts. |
| Linked Issues check | β Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | β Passed | Check skipped because no linked issues were found for this pull request. |
βοΈ Tip: You can configure your own custom pre-merge checks in the settings.
β¨ Finishing Touches
π§ͺ Generate unit tests (beta)
- [ ] Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Hi, @bhuvan-somisetty We appreciate your contribution. To facilitate seamless integration and collaboration, please ensure you have joined our Slack workspace and the relevant designated channel. We recommend thoroughly reviewing the bookmark pages, project README, and wiki to gain a comprehensive understanding of the project architecture and development guidelines. Active participation in the daily stand-up meetings is encouraged for discussions, ticket assignments, and to foster connections with the development team. Prior to requesting an assignment in the channel, please create a Jira ticket or ask for an assignment of existing tickets. All pull request descriptions must comprehensively detail the before and after changes, substantiated by relevant video or image evidence.
Thanks for the pointers - I'll make sure to join the Slack workspace and the project channel, and go through the README/wiki and Jira board before picking up further work. Rebased this PR onto latest dev in the meantime; the fix and manual test steps are described above (10.50 / 0 / -5 / abc cases). Happy to add anything else needed for review.