mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-08 14:51:32 +00:00
[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:
committed by
Eugenio Romano
parent
aa6ba28427
commit
46150a65f2
@@ -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>
|
||||
|
@@ -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);
|
||||
}));
|
||||
});
|
||||
|
@@ -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)]
|
||||
|
Reference in New Issue
Block a user