Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: remove maxLength property for taxId and expiration date fields #8764

Merged
merged 10 commits into from
Apr 27, 2022
3 changes: 2 additions & 1 deletion src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const CONST = {
PENDING: 'PENDING',
},
MAX_LENGTH: {
TAX_ID_NUMBER: 9,
SSN: 4,
ZIP_CODE: 5,
},
Expand Down Expand Up @@ -640,6 +639,8 @@ 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: {
Expand Down
2 changes: 1 addition & 1 deletion src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
11 changes: 11 additions & 0 deletions src/libs/ValidationUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,16 @@ function isExistingRoomName(roomName, reports, policyID) {
);
}

/**
* Checks if tax ID consists of 9 digits
*
* @param {String} taxID
* @returns {Boolean}
*/
function isValidTaxID(taxID) {
return CONST.REGEX.TAX_ID.test(taxID.replace(CONST.REGEX.NON_NUMERIC, ''));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taxID.replace(CONST.REGEX.NON_NUMERIC, '') allowed emojis to be used in the TaxId field which caused a regression #21065

}

export {
meetsAgeRequirements,
isValidAddress,
Expand All @@ -381,4 +391,5 @@ export {
doesFailCharacterLimit,
isReservedRoomName,
isExistingRoomName,
isValidTaxID,
};
5 changes: 2 additions & 3 deletions src/pages/ReimbursementAccount/CompanyStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class CompanyStep extends React.Component {
errors.website = true;
}

if (!/[0-9]{9}/.test(this.state.companyTaxID)) {
if (!ValidationUtils.isValidTaxID(this.state.companyTaxID)) {
errors.companyTaxID = true;
}

Expand Down Expand Up @@ -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(CONST.REGEX.NON_NUMERIC, '')});
}

render() {
Expand Down Expand Up @@ -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}
/>
<View style={styles.mt4}>
<Picker
Expand Down
1 change: 0 additions & 1 deletion src/pages/settings/Payments/AddDebitCardPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down