Skip to content

Fix NaN handling in currency conversion input validation - #1251

Open
pavankumar-vh wants to merge 1 commit into
CodebuffAI:mainfrom
pavankumar-vh:fix/currency-input-validation
Open

Fix NaN handling in currency conversion input validation#1251
pavankumar-vh wants to merge 1 commit into
CodebuffAI:mainfrom
pavankumar-vh:fix/currency-input-validation

Conversation

@pavankumar-vh

Copy link
Copy Markdown

Overview

Fix NaN handling in currency conversion input validation in common/src/util/currency.ts.

Bug Description

The functions didn't validate that credits and amountInCents are finite numbers. If they were NaN or Infinity, Math.ceil(NaN * centsPerCredit) would return NaN.

Fix

Added Number.isFinite() checks to return 0 for invalid inputs.

Testing

No existing tests for this function, but the fix prevents incorrect behavior with invalid inputs.

Files Changed

  • common/src/util/currency.ts - Added NaN validation

Scope

This change only touches common/ which is an approved contribution area per the Contributing Guide.

The functions didn't validate that credits and amountInCents are finite numbers.
If they were NaN or Infinity, Math.ceil(NaN * centsPerCredit) would return NaN.

Added Number.isFinite() checks to return 0 for invalid inputs.
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.

1 participant