diff --git a/demo-shell/resources/i18n/en.json b/demo-shell/resources/i18n/en.json index faa36877ce..bd8ffa4930 100644 --- a/demo-shell/resources/i18n/en.json +++ b/demo-shell/resources/i18n/en.json @@ -1,6 +1,5 @@ { "APP": { - "CREATE_LIBRARY": "Create Library", "INFO_DRAWER": { "TITLE": "Details", "COMMENTS": "Comments", diff --git a/demo-shell/src/app/components/files/files.component.html b/demo-shell/src/app/components/files/files.component.html index 7c7f708daf..7cffcaf3d4 100644 --- a/demo-shell/src/app/components/files/files.component.html +++ b/demo-shell/src/app/components/files/files.component.html @@ -87,7 +87,7 @@ diff --git a/lib/content-services/dialogs/library/library.dialog.html b/lib/content-services/dialogs/library/library.dialog.html index 0a8ea1624a..092661cb58 100644 --- a/lib/content-services/dialogs/library/library.dialog.html +++ b/lib/content-services/dialogs/library/library.dialog.html @@ -19,6 +19,10 @@ {{ 'LIBRARY.ERRORS.TITLE_TOO_LONG' | translate }} + + {{ 'LIBRARY.ERRORS.TITLE_TOO_SHORT' | translate }} + + {{ form.controls['title'].errors?.message | translate }} diff --git a/lib/content-services/dialogs/library/library.dialog.spec.ts b/lib/content-services/dialogs/library/library.dialog.spec.ts index 5864a059a3..15f46d7cfb 100644 --- a/lib/content-services/dialogs/library/library.dialog.spec.ts +++ b/lib/content-services/dialogs/library/library.dialog.spec.ts @@ -259,4 +259,20 @@ describe('LibraryDialogComponent', () => { expect(component.form.controls.id.value).toBe('library-title'); })); + + it('should invalidate library title if is too short', fakeAsync(() => { + findSitesSpy.and.returnValue(Promise.resolve(findSitesResponse)); + spyOn(alfrescoApi.sitesApi, 'getSite').and.callFake(() => { + return new Promise((resolve, reject) => reject()); + }); + + fixture.detectChanges(); + component.form.controls.title.setValue('l'); + tick(500); + flush(); + fixture.detectChanges(); + + expect(component.form.controls.title.errors['minlength']).toBeTruthy(); + expect(component.form.valid).toBe(false); + })); }); diff --git a/lib/content-services/dialogs/library/library.dialog.ts b/lib/content-services/dialogs/library/library.dialog.ts index da469ec571..7080a606fd 100644 --- a/lib/content-services/dialogs/library/library.dialog.ts +++ b/lib/content-services/dialogs/library/library.dialog.ts @@ -87,6 +87,7 @@ export class LibraryDialogComponent implements OnInit, OnDestroy { title: [ Validators.required, this.forbidOnlySpaces, + Validators.minLength(2), Validators.maxLength(256) ], description: [Validators.maxLength(512)] diff --git a/lib/content-services/i18n/en.json b/lib/content-services/i18n/en.json index dfdf72289c..a10468edb7 100644 --- a/lib/content-services/i18n/en.json +++ b/lib/content-services/i18n/en.json @@ -328,6 +328,7 @@ "ID_TOO_LONG": "Use 72 characters or less for the URL name", "DESCRIPTION_TOO_LONG": "Use 512 characters or less for description", "TITLE_TOO_LONG": "Use 256 characters or less for title", + "TITLE_TOO_SHORT": "Title must be at least 2 characters long", "ILLEGAL_CHARACTERS": "Use numbers and letters only", "ONLY_SPACES": "Library name can't contain only spaces", "LIBRARY_UPDATE_ERROR": "There was an error updating library properties"