diff --git a/src/app/core/validators/noWhitespace.validator.ts b/src/app/core/validators/noWhitespace.validator.ts
new file mode 100644
index 000000000..696232327
--- /dev/null
+++ b/src/app/core/validators/noWhitespace.validator.ts
@@ -0,0 +1,10 @@
+import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms';
+
+export function noWhitespace(): ValidatorFn {
+ return (title: AbstractControl): ValidationErrors | null => {
+ if (title.value && title.value.trim() === '') {
+ return { whitespace: true };
+ }
+ return null;
+ };
+}
diff --git a/src/app/phase-bug-reporting/new-issue/new-issue.component.html b/src/app/phase-bug-reporting/new-issue/new-issue.component.html
index 5af3d8332..dd98459dd 100644
--- a/src/app/phase-bug-reporting/new-issue/new-issue.component.html
+++ b/src/app/phase-bug-reporting/new-issue/new-issue.component.html
@@ -7,6 +7,7 @@
New Issue
Title required.
+ Title cannot contain only whitespaces.
Title cannot exceed 256 characters.
= 206"> {{ 256 - title.value?.length }} characters remaining.
diff --git a/src/app/phase-bug-reporting/new-issue/new-issue.component.ts b/src/app/phase-bug-reporting/new-issue/new-issue.component.ts
index 58234c92c..cbd3e3c40 100644
--- a/src/app/phase-bug-reporting/new-issue/new-issue.component.ts
+++ b/src/app/phase-bug-reporting/new-issue/new-issue.component.ts
@@ -6,6 +6,7 @@ import { Issue } from '../../core/models/issue.model';
import { ErrorHandlingService } from '../../core/services/error-handling.service';
import { IssueService } from '../../core/services/issue.service';
import { LabelService } from '../../core/services/label.service';
+import { noWhitespace } from '../../core/validators/noWhitespace.validator';
import { SUBMIT_BUTTON_TEXT } from '../../shared/view-issue/view-issue.component';
@Component({
@@ -28,7 +29,7 @@ export class NewIssueComponent implements OnInit {
ngOnInit() {
this.newIssueForm = this.formBuilder.group({
- title: ['', [Validators.required, Validators.maxLength(256)]],
+ title: ['', [Validators.required, Validators.maxLength(256), noWhitespace()]],
description: [''],
severity: ['', Validators.required],
type: ['', Validators.required]
@@ -41,6 +42,7 @@ export class NewIssueComponent implements OnInit {
if (this.newIssueForm.invalid) {
return;
}
+
this.isFormPending = true;
this.issueService
.createIssue(this.title.value, Issue.updateDescription(this.description.value), this.severity.value, this.type.value)