package logic import ( "strings" "git.milar.in/milarin/anilist" "git.milar.in/milarin/slices" ) var AllMediaListStatuses = []anilist.MediaListStatus{ anilist.MediaListStatusCurrent, anilist.MediaListStatusPlanning, anilist.MediaListStatusCompleted, anilist.MediaListStatusDropped, anilist.MediaListStatusPaused, anilist.MediaListStatusRepeating, } func ParseMediaListStatus(str string) (anilist.MediaListStatus, error) { s := anilist.MediaListStatus(strings.ToUpper(str)) allStatusesStr := slices.Map(AllMediaListStatuses, func(status anilist.MediaListStatus) string { return string(status) }) if !slices.Contains(AllMediaListStatuses, s) { return s, ErrInvalidAnimeStatus.New(s, strings.Join(allStatusesStr, ",")) } return s, nil }