Skip to content

Commit

Permalink
Raise warning for potentially malformed student
Browse files Browse the repository at this point in the history
If you miss the space after the hyphen in them yaml list of students,
it will siltenty assume another list format during unmarshaling and
have each of the items with the hypen (not even sure if this is
correct or should fail instead). Raise a warning as this could be a
mistake.

I don't think there is much common use of either mail, id or username
starting with a hyphen, so I think its fair to raise a warning.
  • Loading branch information
wallento authored and obcode committed Nov 1, 2024
1 parent 7bbd3c5 commit 4cf428a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions config/students.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ func mkStudents(studs []string) []*Student {
for _, stud := range studs {
rawStud := stud
student := &Student{Raw: rawStud}

if strings.HasPrefix(stud, "-") {
log.Warn().Str("student in config", stud).Msg("student identifier starts with '-', did you miss the space after hyphen?")
}

// E-Mail?
if ev.NewSyntaxValidator().Validate(ev.NewInput(evmail.FromString(stud))).IsValid() {
log.Debug().Str("student in config", stud).Msg("is valid email")
Expand Down

0 comments on commit 4cf428a

Please sign in to comment.