Skip to content

Commit

Permalink
Merge pull request #29740 from dukenv0307/fix/19821
Browse files Browse the repository at this point in the history
Fix:  Large legal name are not saved and no error message is displayed
  • Loading branch information
srikarparsi authored Oct 19, 2023
2 parents 79845f9 + 694ef36 commit 219d29d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ const CONST = {
RESERVED_FIRST_NAMES: ['Expensify', 'Concierge'],
},

LEGAL_NAME: {
MAX_LENGTH: 40,
},

PULL_REQUEST_NUMBER,

MERCHANT_NAME_MAX_LENGTH: 255,
Expand Down
15 changes: 11 additions & 4 deletions src/pages/settings/Profile/PersonalDetails/LegalNamePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Navigation from '../../../../libs/Navigation/Navigation';
import ROUTES from '../../../../ROUTES';
import usePrivatePersonalDetails from '../../../../hooks/usePrivatePersonalDetails';
import FullscreenLoadingIndicator from '../../../../components/FullscreenLoadingIndicator';
import * as ErrorUtils from '../../../../libs/ErrorUtils';

const propTypes = {
/* Onyx Props */
Expand Down Expand Up @@ -53,16 +54,22 @@ function LegalNamePage(props) {
const errors = {};

if (!ValidationUtils.isValidLegalName(values.legalFirstName)) {
errors.legalFirstName = 'privatePersonalDetails.error.hasInvalidCharacter';
ErrorUtils.addErrorMessage(errors, 'legalFirstName', 'privatePersonalDetails.error.hasInvalidCharacter');
} else if (_.isEmpty(values.legalFirstName)) {
errors.legalFirstName = 'common.error.fieldRequired';
}
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}]);
}

if (!ValidationUtils.isValidLegalName(values.legalLastName)) {
errors.legalLastName = 'privatePersonalDetails.error.hasInvalidCharacter';
ErrorUtils.addErrorMessage(errors, 'legalLastName', 'privatePersonalDetails.error.hasInvalidCharacter');
} else if (_.isEmpty(values.legalLastName)) {
errors.legalLastName = 'common.error.fieldRequired';
}
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}]);
}

return errors;
}, []);
Expand Down Expand Up @@ -96,7 +103,7 @@ function LegalNamePage(props) {
accessibilityLabel={props.translate('privatePersonalDetails.legalFirstName')}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT}
defaultValue={legalFirstName}
maxLength={CONST.DISPLAY_NAME.MAX_LENGTH}
maxLength={CONST.LEGAL_NAME.MAX_LENGTH + CONST.SEARCH_MAX_LENGTH}
spellCheck={false}
/>
</View>
Expand All @@ -108,7 +115,7 @@ function LegalNamePage(props) {
accessibilityLabel={props.translate('privatePersonalDetails.legalLastName')}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT}
defaultValue={legalLastName}
maxLength={CONST.DISPLAY_NAME.MAX_LENGTH}
maxLength={CONST.LEGAL_NAME.MAX_LENGTH + CONST.SEARCH_MAX_LENGTH}
spellCheck={false}
/>
</View>
Expand Down

0 comments on commit 219d29d

Please sign in to comment.