Skip to content

Commit eba6335

Browse files
authored
Add long text validation and apply it to use case and justification (#1083)
1 parent 816f102 commit eba6335

File tree

6 files changed

+23
-7
lines changed

6 files changed

+23
-7
lines changed
Loading
Loading

src/main/webapp/app/components/newAccountForm/NewAccountForm.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import client from 'app/shared/api/clientInstance';
4040
import { notifyError } from 'app/shared/utils/NotificationUtils';
4141
import {
4242
EMAIL_VAL,
43+
LONG_TEXT_VAL,
4344
SHORT_TEXT_VAL,
4445
TEXT_VAL,
4546
} from 'app/shared/utils/FormValidationUtils';
@@ -663,7 +664,7 @@ export class NewAccountForm extends React.Component<INewAccountForm> {
663664
placeholder={this.useCasePlaceholder}
664665
rows={6}
665666
validate={{
666-
...TEXT_VAL,
667+
...LONG_TEXT_VAL,
667668
required: {
668669
value: true,
669670
errorMessage: 'Your use case is required.',
@@ -753,6 +754,13 @@ export class NewAccountForm extends React.Component<INewAccountForm> {
753754
rows={6}
754755
type={'textarea'}
755756
required={this.apiAccessRequested}
757+
validate={{
758+
...LONG_TEXT_VAL,
759+
required: {
760+
value: true,
761+
errorMessage: 'Your justification is required.',
762+
},
763+
}}
756764
/>
757765
</div>
758766
)}

src/main/webapp/app/config/constants.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ export enum ACCOUNT_TITLES {
725725
COUNTRY = 'Country',
726726
API_TOKEN = 'API Token',
727727
LICENSE_TYPE = 'License',
728-
ADDITIONAL_INFO_USER_CASE = 'Use Case',
728+
ADDITIONAL_INFO_USE_CASE = 'Use Case',
729729
}
730730

731731
export enum API_CALL_STATUS {

src/main/webapp/app/pages/userPage/UserPage.tsx

+11-5
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ import { SimpleConfirmModal } from 'app/shared/modal/SimpleConfirmModal';
6969
import DocumentTitle from 'react-document-title';
7070
import { Link } from 'react-router-dom';
7171
import { RouterStore } from 'mobx-react-router';
72-
import { SHORT_TEXT_VAL, TEXT_VAL } from 'app/shared/utils/FormValidationUtils';
72+
import {
73+
LONG_TEXT_VAL,
74+
SHORT_TEXT_VAL,
75+
TEXT_VAL,
76+
} from 'app/shared/utils/FormValidationUtils';
7377
import AuthenticationStore from 'app/store/AuthenticationStore';
7478
import ButtonWithTooltip from 'app/shared/button/ButtonWithTooltip';
7579
import {
@@ -401,7 +405,7 @@ export default class UserPage extends React.Component<IUserPage> {
401405
if (this.user) {
402406
const updatedUserCompany: UserCompany = {
403407
...this.user.additionalInfo?.userCompany,
404-
useCase: values.additionalInfoUserCase,
408+
useCase: values.additionalInfoUseCase,
405409
};
406410
const updatedAdditionalInfo: AdditionalInfoDTO = {
407411
...this.user.additionalInfo,
@@ -898,17 +902,19 @@ export default class UserPage extends React.Component<IUserPage> {
898902
disabled={this.user.company != null}
899903
/>
900904
<AvField
901-
name="additionalInfoUserCase"
905+
name="additionalInfoUseCase"
902906
label={
903907
<BoldAccountTitle
904-
title={ACCOUNT_TITLES.ADDITIONAL_INFO_USER_CASE}
908+
title={ACCOUNT_TITLES.ADDITIONAL_INFO_USE_CASE}
905909
licenseType={this.selectedLicense}
906910
/>
907911
}
908912
value={
909913
this.user.additionalInfo?.userCompany?.useCase
910914
}
911-
validate={TEXT_VAL}
915+
rows={3}
916+
type={'textarea'}
917+
validate={LONG_TEXT_VAL}
912918
/>
913919
<AvField
914920
name="city"

src/main/webapp/app/shared/utils/FormValidationUtils.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ export const TEXT_VAL = textValidation(2, 255);
7777

7878
export const SHORT_TEXT_VAL = textValidation(2, 50);
7979

80+
export const LONG_TEXT_VAL = textValidation(2);
81+
8082
export const EMAIL_VAL = {
8183
required: {
8284
value: true,

0 commit comments

Comments
 (0)