Skip to content

Commit

Permalink
Added validation for attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jun 29, 2021
1 parent 5db234d commit 235c7c6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 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 @@ -494,6 +494,7 @@ message.uri-valid-format=URI must be valid format.
message.id-unique=ID 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.
message.required=Missing required property.

message.org-name-required=Organization Name is required.
Expand Down
3 changes: 2 additions & 1 deletion ui/public/assets/schema/attribute/attribute.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"description": "tooltip.entity-attribute-name",
"type": "string",
"minLength": 1,
"maxLength": 255
"maxLength": 255,
"pattern": "^[a-zA-Z0-9:]*$"
},
"attributeType": {
"title": "label.entity-attribute-type",
Expand Down
4 changes: 3 additions & 1 deletion ui/src/app/metadata/domain/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ export const transformErrors = (errors) => {
if (e.name === 'pattern') {
if (e.property.includes('email')) {
e.message = 'message.valid-email';
} else if (e.property.includes('name')) {
e.message = 'message.valid-name';
} else {
e.message = 'message.valid-duration';
e.message = 'message.duration';
}
}

Expand Down

0 comments on commit 235c7c6

Please sign in to comment.