Skip to content

Commit

Permalink
Only pass numberic strings to Str.fromUSDToNumber
Browse files Browse the repository at this point in the history
Str.fromUSDToNumber now crashes if you pass a boolean true|false or
strings that are not valid numbers
  • Loading branch information
aldo-expensify committed Aug 22, 2023
1 parent 06f34c6 commit b955641
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pages/ReimbursementAccount/ValidationStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ValidationStep extends React.Component {
const errors = {};

_.each(values, (value, key) => {
const filteredValue = this.filterInput(value);
const filteredValue = typeof value === 'string' ? this.filterInput(value) : value;
if (ValidationUtils.isRequiredFulfilled(filteredValue)) {
return;
}
Expand Down Expand Up @@ -103,7 +103,7 @@ class ValidationStep extends React.Component {
*/
filterInput(amount) {
let value = amount ? amount.toString().trim() : '';
if (value === '' || !Math.abs(Str.fromUSDToNumber(value)) || _.isNaN(Number(value))) {
if (value === '' || _.isNaN(Number(value)) || !Math.abs(Str.fromUSDToNumber(value))) {
return '';
}

Expand Down

0 comments on commit b955641

Please sign in to comment.