Skip to content

Commit

Permalink
Remove magic number, improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sarpsahinalp committed May 6, 2024
1 parent 6cab626 commit 3a6e398
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/main/webapp/app/course/manage/course-update.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export class CourseUpdateComponent implements OnInit {
readonly COMPLAINT_RESPONSE_TEXT_LIMIT = 65535;
readonly COMPLAINT_TEXT_LIMIT = 65535;

readonly COURSE_TITLE_LIMIT = 255;

constructor(
private eventManager: EventManager,
private courseManagementService: CourseManagementService,
Expand Down Expand Up @@ -163,7 +165,7 @@ export class CourseUpdateComponent implements OnInit {
{
id: new FormControl(this.course.id),
title: new FormControl(this.course.title, {
validators: [Validators.required, Validators.maxLength(255)],
validators: [Validators.required, Validators.maxLength(this.COURSE_TITLE_LIMIT)],
updateOn: 'blur',
}),
shortName: new FormControl(
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/i18n/de/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@
"unableToImportProgrammingExercise": "Fehler beim Importieren der Programmieraufgabe.",
"titleAlreadyExists": "Es existiert bereits eine Programmieraufgabe mit demselben Titel, bitte nutze einen anderen Titel.",
"shortnameAlreadyExists": "Es existiert bereits eine Programmieraufgabe mit demselben Kurznamen, bitte nutze einen anderen Kurznamen.",
"courseTitleTooLong": "Der Kursname ist zu lang (max. 255 Zeichen)."
"courseTitleTooLong": "Der Kurstitel ist zu lang (max. 255 Zeichen), bitte nutze einen kürzeren Kurstitel."
}
}
2 changes: 1 addition & 1 deletion src/main/webapp/i18n/en/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@
"unableToImportProgrammingExercise": "Unable to import programming exercise.",
"titleAlreadyExists": "A programming exercise with the same title already exists. Please choose a different title.",
"shortnameAlreadyExists": "A programming exercise with the same short name already exists. Please choose a different short name.",
"courseTitleTooLong": "The course title is too long (max. 255 characters)."
"courseTitleTooLong": "The course title is too long (max. 255 characters). Please choose a shorter title."
}
}

0 comments on commit 3a6e398

Please sign in to comment.