Skip to content

Commit

Permalink
Merge pull request Expensify#11616 from Expensify/cmartins-fixManualVBA
Browse files Browse the repository at this point in the history
Fix masked account number and default values
  • Loading branch information
luacmartins authored Oct 5, 2022
2 parents 3aad87d + 211f478 commit 113d548
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ const CONST = {
},
REGEX: {
US_ACCOUNT_NUMBER: /^[0-9]{4,17}$/,

// If the account number length is from 4 to 13 digits, we show the last 4 digits and hide the rest with X
// If the length is longer than 13 digits, we show the first 6 and last 4 digits, hiding the rest with X
MASKED_US_ACCOUNT_NUMBER: /^[X]{0,9}[0-9]{4}$|^[0-9]{6}[X]{4,7}[0-9]{4}$/,
SWIFT_BIC: /^[A-Za-z0-9]{8,11}$/,
},
VERIFICATION_MAX_ATTEMPTS: 7,
Expand Down
8 changes: 7 additions & 1 deletion src/pages/ReimbursementAccount/BankAccountManualStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ class BankAccountManualStep extends React.Component {
const errorFields = {};
const routingNumber = values.routingNumber && values.routingNumber.trim();

if (!values.accountNumber || !CONST.BANK_ACCOUNT.REGEX.US_ACCOUNT_NUMBER.test(values.accountNumber.trim())) {
if (
!values.accountNumber
|| (!CONST.BANK_ACCOUNT.REGEX.US_ACCOUNT_NUMBER.test(values.accountNumber.trim()) && !CONST.BANK_ACCOUNT.REGEX.MASKED_US_ACCOUNT_NUMBER.test(values.accountNumber.trim()))
) {
errorFields.accountNumber = this.props.translate('bankAccount.error.accountNumber');
}
if (!routingNumber || !CONST.BANK_ACCOUNT.REGEX.SWIFT_BIC.test(routingNumber) || !ValidationUtils.isValidRoutingNumber(routingNumber)) {
Expand Down Expand Up @@ -91,6 +94,7 @@ class BankAccountManualStep extends React.Component {
<TextInput
inputID="routingNumber"
label={this.props.translate('bankAccount.routingNumber')}
defaultValue={ReimbursementAccountUtils.getDefaultStateForField(this.props, 'routingNumber', '')}
keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD}
disabled={shouldDisableInputs}
shouldSaveDraft
Expand All @@ -99,6 +103,7 @@ class BankAccountManualStep extends React.Component {
inputID="accountNumber"
containerStyles={[styles.mt4]}
label={this.props.translate('bankAccount.accountNumber')}
defaultValue={ReimbursementAccountUtils.getDefaultStateForField(this.props, 'accountNumber', '')}
keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD}
disabled={shouldDisableInputs}
shouldSaveDraft
Expand All @@ -116,6 +121,7 @@ class BankAccountManualStep extends React.Component {
</TextLink>
</View>
)}
defaultValue={ReimbursementAccountUtils.getDefaultStateForField(this.props, 'acceptTerms', true)}
shouldSaveDraft
/>
</Form>
Expand Down

0 comments on commit 113d548

Please sign in to comment.