Skip to content

Commit

Permalink
Added whitespace validation TEAMMATES#12679
Browse files Browse the repository at this point in the history
  • Loading branch information
ArunErram committed Feb 6, 2024
1 parent 887af1c commit 2b1acc9
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, Input } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Course } from '../../../types/api-output';
import { FEEDBACK_SESSION_NAME_MAX_LENGTH } from '../../../types/field-validator';
import { FormControl, FormGroup, Validators } from '@angular/forms';

/**
* Copy current session modal.
Expand All @@ -27,6 +28,11 @@ export class CopySessionModalComponent {

constructor(public activeModal: NgbActiveModal) {}

formCopySessionModel = new FormGroup({
newFeedbackSessionName: new FormControl('', [Validators.required, this.noWhitespaceValidator])
});


/**
* Fires the copy event.
*/
Expand All @@ -48,4 +54,10 @@ export class CopySessionModalComponent {
this.copyToCourseSet.add(courseId);
}
}
noWhitespaceValidator(control: { value: any; }) {
const isWhitespace = (control.value || '').trim().length === 0;
const isValid = !isWhitespace;
return isValid ? null : { 'whitespace': true };
}

}

0 comments on commit 2b1acc9

Please sign in to comment.