diff --git a/src/libs/ValidationUtils.ts b/src/libs/ValidationUtils.ts index 688e22f453cd..d2d9efa8ae4a 100644 --- a/src/libs/ValidationUtils.ts +++ b/src/libs/ValidationUtils.ts @@ -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; } @@ -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 */ @@ -452,6 +459,7 @@ export { isValidRoomName, isValidTaxID, isValidValidateCode, + isValidCompanyName, isValidDisplayName, isValidLegalName, doesContainReservedWord, diff --git a/src/pages/ReimbursementAccount/CompanyStep.js b/src/pages/ReimbursementAccount/CompanyStep.js index a35fa596160a..9f985e15a95e 100644 --- a/src/pages/ReimbursementAccount/CompanyStep.js +++ b/src/pages/ReimbursementAccount/CompanyStep.js @@ -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'; }