-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5940 from Expensify/joe-update-add-debit-form
Update Add Debit Card form to match VBA styles
- Loading branch information
Showing
15 changed files
with
352 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Returns the masked card number (ex: 4242XXXXXXXX4242) | ||
* | ||
* @param {String} cardNumber | ||
* @return {Boolean} | ||
*/ | ||
function maskCardNumber(cardNumber) { | ||
const firstFour = cardNumber.substring(0, 4); | ||
const lastFour = cardNumber.substring(cardNumber.length - 4); | ||
|
||
return `${firstFour}${'X'.repeat(cardNumber.length - 8)}${lastFour}`; | ||
} | ||
|
||
/** | ||
* @param {String} expirationDateString - string in MM/YYYY, MM/YY, MMYY, or MMYYYY format | ||
* @returns {String} | ||
*/ | ||
function getMonthFromExpirationDateString(expirationDateString) { | ||
return expirationDateString.substr(0, 2); | ||
} | ||
|
||
/** | ||
* @param {String} expirationDateString - string in MMYY or MMYYYY format, with any non-number separator | ||
* @returns {String} | ||
*/ | ||
function getYearFromExpirationDateString(expirationDateString) { | ||
const stringContainsNumbersOnly = /^\d+$/.test(expirationDateString); | ||
const cardYear = stringContainsNumbersOnly | ||
? expirationDateString.substr(2) | ||
: expirationDateString.substr(3); | ||
|
||
return cardYear.length === 2 ? `20${cardYear}` : cardYear; | ||
} | ||
|
||
export { | ||
maskCardNumber, | ||
getMonthFromExpirationDateString, | ||
getYearFromExpirationDateString, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.