From e36ceb4ed9a165fedc8199862de1ecb978eec28c Mon Sep 17 00:00:00 2001 From: amentis Date: Mon, 20 May 2024 17:24:59 +0300 Subject: [PATCH] add tenant code validator pattern --- .../app/ui/admin/tenant/editor/tenant-editor.component.html | 1 + .../src/app/ui/admin/tenant/editor/tenant-editor.model.ts | 2 +- dmp-frontend/src/assets/i18n/en.json | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dmp-frontend/src/app/ui/admin/tenant/editor/tenant-editor.component.html b/dmp-frontend/src/app/ui/admin/tenant/editor/tenant-editor.component.html index 4b7e2b845..b7b84a946 100644 --- a/dmp-frontend/src/app/ui/admin/tenant/editor/tenant-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/tenant/editor/tenant-editor.component.html @@ -44,6 +44,7 @@ {{formGroup.get('code').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} + {{'TENANT-EDITOR.VALIDATION.INVALID-CODE' | translate}}
diff --git a/dmp-frontend/src/app/ui/admin/tenant/editor/tenant-editor.model.ts b/dmp-frontend/src/app/ui/admin/tenant/editor/tenant-editor.model.ts index 9472b4749..4cfd3526b 100644 --- a/dmp-frontend/src/app/ui/admin/tenant/editor/tenant-editor.model.ts +++ b/dmp-frontend/src/app/ui/admin/tenant/editor/tenant-editor.model.ts @@ -43,7 +43,7 @@ export class TenantEditorModel extends BaseEditorModel implements TenantPersist const baseValidationArray: Validation[] = new Array(); baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] }); baseValidationArray.push({ key: 'name', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'name')] }); - baseValidationArray.push({ key: 'code', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'code')] }); + baseValidationArray.push({ key: 'code', validators: [Validators.required, Validators.pattern('^[a-z0-9\_\]+$'), BackendErrorValidator(this.validationErrorModel, 'code')] }); baseValidationArray.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] }); baseValidationArray.push({ key: 'hash', validators: [] }); diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 3637858f8..223e035f8 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -1369,6 +1369,9 @@ }, "TENANT-EDITOR": { "NEW": "New Tenant", + "VALIDATION": { + "INVALID-CODE": "Invalid code" + }, "FIELDS": { "NAME": "Name", "CODE": "Code",