diff --git a/contributingGuides/FORMS.md b/contributingGuides/FORMS.md index ffec5f20254c..d87f9f889090 100644 --- a/contributingGuides/FORMS.md +++ b/contributingGuides/FORMS.md @@ -161,7 +161,7 @@ function validate(values) { errors = ErrorUtils.addErrorMessage(errors, 'firstName', 'personalDetails.error.hasInvalidCharacter'); } - if (ValidationUtils.doesContainReservedWord(values.firstName, CONST.DISPLAY_NAME.RESERVED_FIRST_NAMES)) { + if (ValidationUtils.doesContainReservedWord(values.firstName, CONST.DISPLAY_NAME.RESERVED_NAMES)) { errors = ErrorUtils.addErrorMessage(errors, 'firstName', 'personalDetails.error.containsReservedWord'); } diff --git a/src/CONST.ts b/src/CONST.ts index ff3934c31943..86a2f66fc4a2 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -92,7 +92,7 @@ const CONST = { DISPLAY_NAME: { MAX_LENGTH: 50, - RESERVED_FIRST_NAMES: ['Expensify', 'Concierge'], + RESERVED_NAMES: ['Expensify', 'Concierge'], }, LEGAL_NAME: { diff --git a/src/languages/en.ts b/src/languages/en.ts index fc426002809a..e01aa9fc59e3 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1135,7 +1135,7 @@ export default { }, personalDetails: { error: { - containsReservedWord: 'First name cannot contain the words Expensify or Concierge', + containsReservedWord: 'Name cannot contain the words Expensify or Concierge', hasInvalidCharacter: 'Name cannot contain a comma or semicolon', }, }, diff --git a/src/pages/settings/Profile/DisplayNamePage.js b/src/pages/settings/Profile/DisplayNamePage.js index 8ea471283004..3269fc401c01 100644 --- a/src/pages/settings/Profile/DisplayNamePage.js +++ b/src/pages/settings/Profile/DisplayNamePage.js @@ -60,13 +60,16 @@ function DisplayNamePage(props) { if (!ValidationUtils.isValidDisplayName(values.firstName)) { ErrorUtils.addErrorMessage(errors, 'firstName', 'personalDetails.error.hasInvalidCharacter'); } - if (ValidationUtils.doesContainReservedWord(values.firstName, CONST.DISPLAY_NAME.RESERVED_FIRST_NAMES)) { + if (ValidationUtils.doesContainReservedWord(values.firstName, CONST.DISPLAY_NAME.RESERVED_NAMES)) { ErrorUtils.addErrorMessage(errors, 'firstName', 'personalDetails.error.containsReservedWord'); } // Then we validate the last name field if (!ValidationUtils.isValidDisplayName(values.lastName)) { - errors.lastName = 'personalDetails.error.hasInvalidCharacter'; + ErrorUtils.addErrorMessage(errors, 'lastName', 'personalDetails.error.hasInvalidCharacter'); + } + if (ValidationUtils.doesContainReservedWord(values.lastName, CONST.DISPLAY_NAME.RESERVED_NAMES)) { + ErrorUtils.addErrorMessage(errors, 'lastName', 'personalDetails.error.containsReservedWord'); } return errors; }; diff --git a/src/pages/settings/Profile/PersonalDetails/LegalNamePage.js b/src/pages/settings/Profile/PersonalDetails/LegalNamePage.js index 365ea62184ab..2943bcf19992 100644 --- a/src/pages/settings/Profile/PersonalDetails/LegalNamePage.js +++ b/src/pages/settings/Profile/PersonalDetails/LegalNamePage.js @@ -60,6 +60,9 @@ function LegalNamePage(props) { } else if (_.isEmpty(values.legalFirstName)) { errors.legalFirstName = 'common.error.fieldRequired'; } + if (ValidationUtils.doesContainReservedWord(values.legalFirstName, CONST.DISPLAY_NAME.RESERVED_NAMES)) { + ErrorUtils.addErrorMessage(errors, 'legalFirstName', 'personalDetails.error.containsReservedWord'); + } if (values.legalFirstName.length > CONST.LEGAL_NAME.MAX_LENGTH) { ErrorUtils.addErrorMessage(errors, 'legalFirstName', ['common.error.characterLimitExceedCounter', {length: values.legalFirstName.length, limit: CONST.LEGAL_NAME.MAX_LENGTH}]); } @@ -69,6 +72,9 @@ function LegalNamePage(props) { } else if (_.isEmpty(values.legalLastName)) { errors.legalLastName = 'common.error.fieldRequired'; } + if (ValidationUtils.doesContainReservedWord(values.legalLastName, CONST.DISPLAY_NAME.RESERVED_NAMES)) { + ErrorUtils.addErrorMessage(errors, 'legalLastName', 'personalDetails.error.containsReservedWord'); + } if (values.legalLastName.length > CONST.LEGAL_NAME.MAX_LENGTH) { ErrorUtils.addErrorMessage(errors, 'legalLastName', ['common.error.characterLimitExceedCounter', {length: values.legalLastName.length, limit: CONST.LEGAL_NAME.MAX_LENGTH}]); }