mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4068] StartTaskComponent - add description empty space validator (#4341)
* [ADF-4068] StartTaskComponent - add description empty space validator * [ADF-4068] StartTaskCloudComponent - add unit tests * [ADF-4068] - lint
This commit is contained in:
committed by
Eugenio Romano
parent
bfec78aec9
commit
b967b77946
@@ -213,4 +213,14 @@ describe('StartTaskCloudComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(name.valid).toBeTruthy();
|
expect(name.valid).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
it('should emit error when description have only white spaces', () => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
let description = component.taskForm.controls['description'];
|
||||||
|
description.setValue(' ');
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(description.valid).toBeFalsy();
|
||||||
|
description.setValue('');
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(description.valid).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -131,7 +131,7 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
|
|||||||
this.taskForm = this.formBuilder.group({
|
this.taskForm = this.formBuilder.group({
|
||||||
name: new FormControl(this.name, [Validators.required, Validators.maxLength(this.getMaxNameLength()), this.whitespaceValidator]),
|
name: new FormControl(this.name, [Validators.required, Validators.maxLength(this.getMaxNameLength()), this.whitespaceValidator]),
|
||||||
priority: new FormControl(),
|
priority: new FormControl(),
|
||||||
description: new FormControl()
|
description: new FormControl('', [this.whitespaceValidator])
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
public whitespaceValidator(control: FormControl) {
|
public whitespaceValidator(control: FormControl) {
|
||||||
const isWhitespace = (control.value || '').trim().length === 0;
|
const isWhitespace = (control.value || '').trim().length === 0;
|
||||||
const isValid = !isWhitespace;
|
const isValid = control.value.length === 0 || !isWhitespace;
|
||||||
return isValid ? null : { 'whitespace': true };
|
return isValid ? null : { 'whitespace': true };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,5 +217,4 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
|
|||||||
get priorityController(): AbstractControl {
|
get priorityController(): AbstractControl {
|
||||||
return this.taskForm.get('priority');
|
return this.taskForm.get('priority');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user