1
+ import { Str } from 'expensify-common' ;
1
2
import React from 'react' ;
2
3
import { View } from 'react-native' ;
3
4
import { useOnyx } from 'react-native-onyx' ;
@@ -8,6 +9,8 @@ import useLocalize from '@hooks/useLocalize';
8
9
import useThemeStyles from '@hooks/useThemeStyles' ;
9
10
import * as LoginUtils from '@libs/LoginUtils' ;
10
11
import type { PlatformStackScreenProps } from '@libs/Navigation/PlatformStackNavigation/types' ;
12
+ import * as PhoneNumberUtils from '@libs/PhoneNumber' ;
13
+ import * as ValidationUtils from '@libs/ValidationUtils' ;
11
14
import type { SettingsNavigatorParamList } from '@navigation/types' ;
12
15
import CONST from '@src/CONST' ;
13
16
import ONYXKEYS from '@src/ONYXKEYS' ;
@@ -40,12 +43,17 @@ function GetPhysicalCardPhone({
40
43
41
44
const errors : OnValidateResult = { } ;
42
45
43
- if ( ! LoginUtils . validateNumber ( phoneNumberToValidate ) ) {
44
- errors . phoneNumber = translate ( 'common.error.phoneNumber' ) ;
45
- } else if ( ! phoneNumberToValidate ) {
46
+ if ( ! ValidationUtils . isRequiredFulfilled ( phoneNumberToValidate ) ) {
46
47
errors . phoneNumber = translate ( 'common.error.fieldRequired' ) ;
47
48
}
48
49
50
+ const phoneNumberWithCountryCode = LoginUtils . appendCountryCode ( phoneNumberToValidate ) ;
51
+ const parsedPhoneNumber = PhoneNumberUtils . parsePhoneNumber ( phoneNumberWithCountryCode ) ;
52
+
53
+ if ( ! parsedPhoneNumber . possible || ! Str . isValidE164Phone ( phoneNumberWithCountryCode . slice ( 0 ) ) ) {
54
+ errors . phoneNumber = translate ( 'bankAccount.error.phoneNumber' ) ;
55
+ }
56
+
49
57
return errors ;
50
58
} ;
51
59
0 commit comments