Skip to content

Commit

Permalink
Merge pull request #33865 from tienifr/fix/regression-31385
Browse files Browse the repository at this point in the history
Do not allow emojis in address
  • Loading branch information
grgia authored Jan 8, 2024
2 parents c0c4d64 + 9ce24ae commit 5cb22df
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/libs/ValidationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function validateCardNumber(value: string): boolean {
* Validating that this is a valid address (PO boxes are not allowed)
*/
function isValidAddress(value: string): boolean {
if (!CONST.REGEX.ANY_VALUE.test(value)) {
if (!CONST.REGEX.ANY_VALUE.test(value) || value.match(CONST.REGEX.EMOJIS)) {
return false;
}

Expand Down Expand Up @@ -306,6 +306,13 @@ function isValidRoutingNumber(routingNumber: string): boolean {
return false;
}

/**
* Checks that the provided name doesn't contain any emojis
*/
function isValidCompanyName(name: string) {
return !name.match(CONST.REGEX.EMOJIS);
}

/**
* Checks that the provided name doesn't contain any commas or semicolons
*/
Expand Down Expand Up @@ -452,6 +459,7 @@ export {
isValidRoomName,
isValidTaxID,
isValidValidateCode,
isValidCompanyName,
isValidDisplayName,
isValidLegalName,
doesContainReservedWord,
Expand Down
8 changes: 8 additions & 0 deletions src/pages/ReimbursementAccount/CompanyStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,18 @@ function CompanyStep({reimbursementAccount, reimbursementAccountDraft, getDefaul
];
const errors = ValidationUtils.getFieldRequiredErrors(values, requiredFields);

if (values.companyName && !ValidationUtils.isValidCompanyName(values.companyName)) {
errors.companyName = 'bankAccount.error.companyName';
}

if (values.addressStreet && !ValidationUtils.isValidAddress(values.addressStreet)) {
errors.addressStreet = 'bankAccount.error.addressStreet';
}

if (values.addressCity && !ValidationUtils.isValidAddress(values.addressCity)) {
errors.addressCity = 'bankAccount.error.addressCity';
}

if (values.addressZipCode && !ValidationUtils.isValidZipCode(values.addressZipCode)) {
errors.addressZipCode = 'bankAccount.error.zipCode';
}
Expand Down

0 comments on commit 5cb22df

Please sign in to comment.