From 03624d769e8088473084a4aeefbfd1c30e83265c Mon Sep 17 00:00:00 2001 From: Yevhenii Voloshchak Date: Mon, 25 Apr 2022 11:16:47 +0300 Subject: [PATCH 01/10] Remove maxLength from expiration date field --- src/pages/settings/Payments/AddDebitCardPage.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/settings/Payments/AddDebitCardPage.js b/src/pages/settings/Payments/AddDebitCardPage.js index e6a8406c1cea..25dccd304295 100644 --- a/src/pages/settings/Payments/AddDebitCardPage.js +++ b/src/pages/settings/Payments/AddDebitCardPage.js @@ -249,7 +249,6 @@ class DebitCardPage extends Component { label={this.props.translate('addDebitCardPage.expiration')} placeholder={this.props.translate('addDebitCardPage.expirationDate')} value={this.state.expirationDate} - maxLength={7} errorText={this.getErrorText('expirationDate')} keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD} onChangeText={this.addOrRemoveSlashToExpiryDate} From e3509aeea6564794ddf8476de6422bf6a11483bf Mon Sep 17 00:00:00 2001 From: Yevhenii Voloshchak Date: Mon, 25 Apr 2022 11:25:56 +0300 Subject: [PATCH 02/10] Remove maxLength from taxID field --- src/CONST.js | 1 - src/pages/ReimbursementAccount/CompanyStep.js | 1 - 2 files changed, 2 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index c60a5d15b06e..a74b8e421c25 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -86,7 +86,6 @@ const CONST = { PENDING: 'PENDING', }, MAX_LENGTH: { - TAX_ID_NUMBER: 9, SSN: 4, ZIP_CODE: 5, }, diff --git a/src/pages/ReimbursementAccount/CompanyStep.js b/src/pages/ReimbursementAccount/CompanyStep.js index 384a7bfeba05..c21751661932 100644 --- a/src/pages/ReimbursementAccount/CompanyStep.js +++ b/src/pages/ReimbursementAccount/CompanyStep.js @@ -262,7 +262,6 @@ class CompanyStep extends React.Component { disabled={shouldDisableCompanyTaxID} placeholder={this.props.translate('companyStep.taxIDNumberPlaceholder')} errorText={this.getErrorText('companyTaxID')} - maxLength={CONST.BANK_ACCOUNT.MAX_LENGTH.TAX_ID_NUMBER} /> Date: Mon, 25 Apr 2022 11:44:36 +0300 Subject: [PATCH 03/10] Strip all non-numeric characters and test for length of 9 in error validation --- src/pages/ReimbursementAccount/CompanyStep.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ReimbursementAccount/CompanyStep.js b/src/pages/ReimbursementAccount/CompanyStep.js index c21751661932..475b715d2ba3 100644 --- a/src/pages/ReimbursementAccount/CompanyStep.js +++ b/src/pages/ReimbursementAccount/CompanyStep.js @@ -142,7 +142,7 @@ class CompanyStep extends React.Component { errors.website = true; } - if (!/[0-9]{9}/.test(this.state.companyTaxID)) { + if (!/^\d{9}$/.test(this.state.companyTaxID.replace(/\D/g,''))) { errors.companyTaxID = true; } From 50caa1310299acfe19f429b61f6fefbf95b2edb3 Mon Sep 17 00:00:00 2001 From: Yevhenii Voloshchak Date: Mon, 25 Apr 2022 11:51:58 +0300 Subject: [PATCH 04/10] Strip all non-numeric characters in companyTaxID on form submission --- src/pages/ReimbursementAccount/CompanyStep.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ReimbursementAccount/CompanyStep.js b/src/pages/ReimbursementAccount/CompanyStep.js index 475b715d2ba3..3bfe628f9ab7 100644 --- a/src/pages/ReimbursementAccount/CompanyStep.js +++ b/src/pages/ReimbursementAccount/CompanyStep.js @@ -176,7 +176,7 @@ class CompanyStep extends React.Component { } const incorporationDate = moment(this.state.incorporationDate).format(CONST.DATE.MOMENT_FORMAT_STRING); - BankAccounts.setupWithdrawalAccount({...this.state, incorporationDate}); + BankAccounts.setupWithdrawalAccount({...this.state, incorporationDate, companyTaxID: this.state.companyTaxID.replace(/\D/g,'')}); } render() { From ff0468f19d0f8d5dffdd20b63583e7cc91fe4d68 Mon Sep 17 00:00:00 2001 From: Yevhenii Voloshchak Date: Mon, 25 Apr 2022 11:54:55 +0300 Subject: [PATCH 05/10] Change taxID input placeholder --- src/languages/en.js | 2 +- src/languages/es.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index 0c9f6e74a8d8..0c655c30a591 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -687,7 +687,7 @@ export default { legalBusinessName: 'Legal business name', companyWebsite: 'Company website', taxIDNumber: 'Tax ID number', - taxIDNumberPlaceholder: '9 digits, no hyphens', + taxIDNumberPlaceholder: '9 digits', companyType: 'Company type', incorporationDate: 'Incorporation date', incorporationState: 'Incorporation state', diff --git a/src/languages/es.js b/src/languages/es.js index 3a2729b04f1e..1ecec657163d 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -689,7 +689,7 @@ export default { legalBusinessName: 'Nombre comercial legal', companyWebsite: 'Página web de la empresa', taxIDNumber: 'Número de identificación fiscal', - taxIDNumberPlaceholder: '9 dígitos, sin guiones', + taxIDNumberPlaceholder: '9 dígitos', companyType: 'Tipo de empresa', incorporationDate: 'Fecha de incorporación', incorporationState: 'Estado de incorporación', From 8c31474b7ef16deb04068ccd3447f77001435faf Mon Sep 17 00:00:00 2001 From: Yevhenii Voloshchak Date: Mon, 25 Apr 2022 12:06:47 +0300 Subject: [PATCH 06/10] Fix linter errors --- src/pages/ReimbursementAccount/CompanyStep.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/ReimbursementAccount/CompanyStep.js b/src/pages/ReimbursementAccount/CompanyStep.js index 3bfe628f9ab7..983e75365c7c 100644 --- a/src/pages/ReimbursementAccount/CompanyStep.js +++ b/src/pages/ReimbursementAccount/CompanyStep.js @@ -142,7 +142,7 @@ class CompanyStep extends React.Component { errors.website = true; } - if (!/^\d{9}$/.test(this.state.companyTaxID.replace(/\D/g,''))) { + if (!/^\d{9}$/.test(this.state.companyTaxID.replace(/\D/g, ''))) { errors.companyTaxID = true; } @@ -176,7 +176,7 @@ class CompanyStep extends React.Component { } const incorporationDate = moment(this.state.incorporationDate).format(CONST.DATE.MOMENT_FORMAT_STRING); - BankAccounts.setupWithdrawalAccount({...this.state, incorporationDate, companyTaxID: this.state.companyTaxID.replace(/\D/g,'')}); + BankAccounts.setupWithdrawalAccount({...this.state, incorporationDate, companyTaxID: this.state.companyTaxID.replace(/\D/g, '')}); } render() { From 70b90f379e6b90e2fbce8f95ed5808a9ef13e40c Mon Sep 17 00:00:00 2001 From: Yevhenii Voloshchak Date: Tue, 26 Apr 2022 23:00:15 +0300 Subject: [PATCH 07/10] Move tax ID validation to ValidationUtils.js --- src/CONST.js | 1 + src/libs/ValidationUtils.js | 11 +++++++++++ src/pages/ReimbursementAccount/CompanyStep.js | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/CONST.js b/src/CONST.js index a74b8e421c25..6c9abbe184a3 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -639,6 +639,7 @@ const CONST = { // eslint-disable-next-line max-len, no-misleading-character-class EMOJIS: /(?:\uD83D(?:\uDC41\u200D\uD83D\uDDE8|\uDC68\u200D\uD83D[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uDC69\u200D\uD83D\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|[\ud83c\ude32-\ude3a]|[\ud83c\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/g, + TAX_ID: /^\d{9}$/, }, PRONOUNS: { diff --git a/src/libs/ValidationUtils.js b/src/libs/ValidationUtils.js index 83ce6b2c816f..acb9a6462415 100644 --- a/src/libs/ValidationUtils.js +++ b/src/libs/ValidationUtils.js @@ -355,6 +355,16 @@ function isExistingRoomName(roomName, reports, policyID) { ); } +/** + * Validate that this is a valid tax ID (consisting of 9 digits) + * + * @param {String} taxID + * @returns {Boolean} + */ +function isValidTaxID(taxID) { + return CONST.REGEX.TAX_ID.test(taxID.replace(/\D/g, '')); +} + export { meetsAgeRequirements, isValidAddress, @@ -381,4 +391,5 @@ export { doesFailCharacterLimit, isReservedRoomName, isExistingRoomName, + isValidTaxID, }; diff --git a/src/pages/ReimbursementAccount/CompanyStep.js b/src/pages/ReimbursementAccount/CompanyStep.js index 983e75365c7c..9a6a876f5576 100644 --- a/src/pages/ReimbursementAccount/CompanyStep.js +++ b/src/pages/ReimbursementAccount/CompanyStep.js @@ -142,7 +142,7 @@ class CompanyStep extends React.Component { errors.website = true; } - if (!/^\d{9}$/.test(this.state.companyTaxID.replace(/\D/g, ''))) { + if (!ValidationUtils.isValidTaxID(this.state.companyTaxID)) { errors.companyTaxID = true; } From d104d5d90405a1383c006eab4acd8ef0e2e4efa8 Mon Sep 17 00:00:00 2001 From: Yevhenii Voloshchak Date: Wed, 27 Apr 2022 10:29:07 +0300 Subject: [PATCH 08/10] Change isValidTaxID comment --- src/libs/ValidationUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ValidationUtils.js b/src/libs/ValidationUtils.js index acb9a6462415..e68d2878f39c 100644 --- a/src/libs/ValidationUtils.js +++ b/src/libs/ValidationUtils.js @@ -356,7 +356,7 @@ function isExistingRoomName(roomName, reports, policyID) { } /** - * Validate that this is a valid tax ID (consisting of 9 digits) + * Checks if tax ID consists of 9 digits * * @param {String} taxID * @returns {Boolean} From 08076bf7ef368f2c3894692c520526f199171d3a Mon Sep 17 00:00:00 2001 From: Yevhenii Voloshchak Date: Wed, 27 Apr 2022 10:35:47 +0300 Subject: [PATCH 09/10] Move non-numeric regex to CONST.js --- src/libs/ValidationUtils.js | 2 +- src/pages/ReimbursementAccount/CompanyStep.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ValidationUtils.js b/src/libs/ValidationUtils.js index e68d2878f39c..5138541a8bac 100644 --- a/src/libs/ValidationUtils.js +++ b/src/libs/ValidationUtils.js @@ -362,7 +362,7 @@ function isExistingRoomName(roomName, reports, policyID) { * @returns {Boolean} */ function isValidTaxID(taxID) { - return CONST.REGEX.TAX_ID.test(taxID.replace(/\D/g, '')); + return CONST.REGEX.TAX_ID.test(taxID.replace(CONST.REGEX.NON_NUMERIC, '')); } export { diff --git a/src/pages/ReimbursementAccount/CompanyStep.js b/src/pages/ReimbursementAccount/CompanyStep.js index 9a6a876f5576..832dac6e63f0 100644 --- a/src/pages/ReimbursementAccount/CompanyStep.js +++ b/src/pages/ReimbursementAccount/CompanyStep.js @@ -176,7 +176,7 @@ class CompanyStep extends React.Component { } const incorporationDate = moment(this.state.incorporationDate).format(CONST.DATE.MOMENT_FORMAT_STRING); - BankAccounts.setupWithdrawalAccount({...this.state, incorporationDate, companyTaxID: this.state.companyTaxID.replace(/\D/g, '')}); + BankAccounts.setupWithdrawalAccount({...this.state, incorporationDate, companyTaxID: this.state.companyTaxID.replace(CONST.REGEX.NON_NUMERIC, '')}); } render() { From f96796886c549db9f40a7ea826d364bbe9a2936b Mon Sep 17 00:00:00 2001 From: Yevhenii Voloshchak Date: Wed, 27 Apr 2022 10:37:34 +0300 Subject: [PATCH 10/10] Move non-numeric regex to CONST.js --- src/CONST.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CONST.js b/src/CONST.js index 6c9abbe184a3..10ef79563be5 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -640,6 +640,7 @@ const CONST = { // eslint-disable-next-line max-len, no-misleading-character-class EMOJIS: /(?:\uD83D(?:\uDC41\u200D\uD83D\uDDE8|\uDC68\u200D\uD83D[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uDC69\u200D\uD83D\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|[\ud83c\ude32-\ude3a]|[\ud83c\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/g, TAX_ID: /^\d{9}$/, + NON_NUMERIC: /\D/g, }, PRONOUNS: {