This repository was archived by the owner on Mar 25, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +14
-4
lines changed Expand file tree Collapse file tree 6 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ export function forbiddenValuesValidator(
5
5
forbiddenValues : Array < string >
6
6
) : ValidatorFn {
7
7
return ( c : AbstractControl ) => {
8
- const isValid = ! forbiddenValues . find ( _ => _ === c . value ) ;
8
+ const isValid = ! forbiddenValues . find ( _ => _ === c . value && c . value . trim ( ) ) ;
9
9
10
10
if ( isValid ) {
11
11
return null ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ <h3 *ngIf="!loading" class="mat-dialog-title">
12
12
[forbiddenValues] ="forbiddenKeys || [] "
13
13
[placeholder] ="'TAGS.TAG_KEY' | translate "
14
14
[maxlength] ="maxKeyLength "
15
+ pattern ="^\S.*$ "
15
16
autofocus
16
17
required
17
18
#keyField ="ngModel "
@@ -31,8 +32,13 @@ <h3 *ngIf="!loading" class="mat-dialog-title">
31
32
[(ngModel)] ="value "
32
33
[placeholder] ="'TAGS.TAG_VALUE' | translate "
33
34
[maxlength] ="maxValueLength "
35
+ pattern ="^\S.*$ "
34
36
required
37
+ #valueField ="ngModel "
35
38
>
39
+ < mat-error *ngIf ="valueField.invalid && valueField.errors['pattern'] ">
40
+ {{ 'TAGS.TAG_START_FROM_SPACE' | translate }}
41
+ </ mat-error >
36
42
< mat-hint align ="end ">
37
43
< cs-character-count
38
44
[value] ="value "
Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ export class TagEditComponent {
45
45
public get keyFieldErrorMessage ( ) : string {
46
46
if ( this . keyField . errors && this . keyField . errors . forbiddenValuesValidator ) {
47
47
return 'TAGS.TAG_ALREADY_EXISTS' ;
48
+ } else if ( this . keyField . errors && this . keyField . errors . pattern ) {
49
+ return 'TAGS.TAG_START_FROM_SPACE' ;
48
50
}
49
51
50
52
return '' ;
Original file line number Diff line number Diff line change 21
21
22
22
.left {
23
23
margin-right : 15px ;
24
- max-width : 70%
24
+ max-width : 70% ;
25
25
}
26
26
27
27
.buttons {
Original file line number Diff line number Diff line change 1571
1571
"TAG_KEY" : " Key" ,
1572
1572
"TAG_VALUE" : " Value" ,
1573
1573
"TAG_ALREADY_EXISTS" : " Tag already exists" ,
1574
- "EDIT_TAG" : " Edit tag"
1574
+ "EDIT_TAG" : " Edit tag" ,
1575
+ "TAG_START_FROM_SPACE" : " Field value must start with 'non-space' character"
1575
1576
},
1576
1577
"DISK_OFFERING_STORAGE_TYPE" : {
1577
1578
"SHARED" : " Shared" ,
Original file line number Diff line number Diff line change 1567
1567
"TAG_KEY" : " Ключ" ,
1568
1568
"TAG_VALUE" : " Значение" ,
1569
1569
"TAG_ALREADY_EXISTS" : " Тег уже существует" ,
1570
- "EDIT_TAG" : " Редактировать тег"
1570
+ "EDIT_TAG" : " Редактировать тег" ,
1571
+ "TAG_START_FROM_SPACE" : " Значение не может начинаться с пробела"
1571
1572
},
1572
1573
"DISK_OFFERING_STORAGE_TYPE" : {
1573
1574
"SHARED" : " Общее" ,
You can’t perform that action at this time.
0 commit comments