Skip to content

Commit

Permalink
Use ValidationUtils.isNumeric
Browse files Browse the repository at this point in the history
  • Loading branch information
roryabraham committed Jun 27, 2024
1 parent 51c85dd commit d178103
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/libs/ValidationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ function isNumeric(value: string): boolean {
if (typeof value !== 'string') {
return false;
}
return /^\d*$/.test(value);
return CONST.REGEX.NUMBER.test(value);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
import shouldFetchReport from '@libs/shouldFetchReport';
import * as ValidationUtils from '@libs/ValidationUtils';
import type {AuthScreensParamList} from '@navigation/types';
import variables from '@styles/variables';
import * as ComposerActions from '@userActions/Composer';
Expand Down Expand Up @@ -169,8 +170,8 @@ function ReportScreen({
// Don't update if there is a reportID in the params already
if (route.params.reportID) {
const reportActionID = route?.params?.reportActionID;
const regexValidReportActionID = new RegExp(/^\d*$/);
if (reportActionID && !regexValidReportActionID.test(reportActionID)) {
const isValidReportActionID = ValidationUtils.isNumeric(reportActionID);
if (reportActionID && !isValidReportActionID) {
navigation.setParams({reportActionID: ''});
}
return;
Expand Down

0 comments on commit d178103

Please sign in to comment.