Skip to content

Commit

Permalink
Merged in bugfix/SHIBUI-1568-unique-source-names (pull request #582)
Browse files Browse the repository at this point in the history
Created validation for unique source names

Approved-by: Bill Smith
Approved-by: Dmitriy Kopylenko
  • Loading branch information
rmathis committed Jul 5, 2022
2 parents 160a160 + f403266 commit 5d5dc4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ message.must-be-number=Must be a number.
message.name-must-be-unique=Name must be unique.
message.uri-valid-format=URI must be valid format.
message.id-unique=ID must be unique.
message.name-unique=Service provider name must be unique.
message.array-items-must-be-unique=Items in list must be unique.
message.valid-duration=Must be a valid duration.
message.valid-name=No special characters or whitespace allowed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const SourceBase = {

const sources = current ? data.filter(s => s.id !== current.id) : data;
const entityIds = sources.map(s => s.entityId);
const names = sources.map(s => s.serviceProviderName);
const pattern = group?.validationRegex ? new RegExp(group?.validationRegex) : null;

return (formData, errors) => {
Expand All @@ -32,6 +33,10 @@ export const SourceBase = {
errors.entityId.addError('message.id-unique');
}

if (names.indexOf(formData.serviceProviderName) > -1) {
errors.serviceProviderName.addError('message.name-unique');
}

if (pattern && !pattern?.test(formData.entityId)) {
errors.entityId.addError(translator('message.group-pattern-fail', {regex: group?.validationRegex}));
}
Expand Down

0 comments on commit 5d5dc4d

Please sign in to comment.