Skip to content

Commit

Permalink
EPMRPP-97895 || Add validation on entered URL
Browse files Browse the repository at this point in the history
  • Loading branch information
BlazarQSO committed Dec 18, 2024
1 parent 68a3557 commit 3cf2aab
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/src/common/utils/validation/commonValidators.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export const descriptionEntity = bindMessageToValidator(
'descriptionEntityHint',
);

export const btsUrl = bindMessageToValidator(validate.url, 'btsUrlHint');
export const btsJiraUrl = bindMessageToValidator(validate.jiraUrl, 'btsUrlHint');
export const btsRallyUrl = bindMessageToValidator(validate.rallyUrl, 'btsUrlHint');
export const btsIntegrationName = bindMessageToValidator(
validate.btsIntegrationName,
'btsIntegrationNameHint',
Expand Down
8 changes: 8 additions & 0 deletions app/src/common/utils/validation/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ import {
export const required = isNotEmpty;
export const isNotEmptyArray = composeValidators([isNotEmpty, minLength(1)]);
export const url = composeValidators([isNotEmpty, regex(/^(ftp|http|https):\/\/[^ "]+$/)]);
export const jiraUrl = composeValidators([
isNotEmpty,
regex(/https:\/\/[^?]*.atlassian.(net|com)\/.*/),
]);
export const rallyUrl = composeValidators([
isNotEmpty,
regex(/^(https:\/\/rally1.rallydev.com\/).*/),
]);
export const email = composeValidators([regex(/^[a-z0-9.+_-]+@[a-z0-9_.-]+?\.[a-z0-9]{2,}$/i)]);
export const requiredEmail = composeValidators([isNotEmpty, email]);
export const login = composeValidators([isNotEmpty, regex(/^[0-9a-zA-Z-_.]{1,128}$/)]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class JiraConnectionFormFields extends Component {
<FieldElement
name="url"
label={formatMessage(COMMON_BTS_MESSAGES.linkToBtsLabel)}
validate={commonValidators.btsUrl}
validate={commonValidators.btsJiraUrl}
disabled={disabled || editAuthMode}
className={cx('fields')}
isRequired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class RallyConnectionFormFields extends Component {
</FieldElement>
<FieldElement
name="url"
validate={commonValidators.btsUrl}
validate={commonValidators.btsRallyUrl}
disabled={disabled || editAuthMode}
label={formatMessage(COMMON_BTS_MESSAGES.linkToBtsLabel)}
className={cx('fields')}
Expand Down

0 comments on commit 3cf2aab

Please sign in to comment.