[ADF-3855] Add minimum length to library title (#4139)

* [ADF-3855] Add minimum length to library title

* update name test
This commit is contained in:
davidcanonieto
2019-01-14 12:47:34 +00:00
committed by Eugenio Romano
parent aa6ba28427
commit 46150a65f2
6 changed files with 23 additions and 2 deletions

View File

@@ -19,6 +19,10 @@
{{ 'LIBRARY.ERRORS.TITLE_TOO_LONG' | translate }}
</mat-error>
<mat-error *ngIf="form.controls['title'].hasError('minlength')">
{{ 'LIBRARY.ERRORS.TITLE_TOO_SHORT' | translate }}
</mat-error>
<mat-error *ngIf="form.controls['title'].errors?.message">
{{ form.controls['title'].errors?.message | translate }}
</mat-error>

View File

@@ -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);
}));
});

View File

@@ -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)]