package domain import "time" // Theme represents the UI theme preference. type Theme string const ( ThemeLight Theme = "light" ThemeDark Theme = "dark" ThemeSystem Theme = "system" ) // validThemes is the set of allowed theme values. var validThemes = map[Theme]bool{ ThemeLight: true, ThemeDark: true, ThemeSystem: true, } // DigestFrequency represents the email digest frequency preference. type DigestFrequency string const ( DigestNone DigestFrequency = "none" DigestDaily DigestFrequency = "daily" DigestWeekly DigestFrequency = "weekly" ) // validDigests is the set of allowed digest frequency values. var validDigests = map[DigestFrequency]bool{ DigestNone: true, DigestDaily: true, DigestWeekly: true, } // validLanguages is the set of allowed BCP-47 language tags. var validLanguages = map[string]bool{ "en": true, "fr": true, "es": true, "de": true, "ja": true, } // NotificationPreferences holds notification-related preferences. type NotificationPreferences struct { Email bool Push bool Digest DigestFrequency } // UserPreferences represents a user's preference settings. type UserPreferences struct { UserID string Theme Theme Language string Notifications NotificationPreferences UpdatedAt time.Time } // DefaultPreferences returns the default preferences for a given user ID. func DefaultPreferences(userID string) *UserPreferences { return &UserPreferences{ UserID: userID, Theme: ThemeSystem, Language: "en", Notifications: NotificationPreferences{ Email: true, Push: true, Digest: DigestWeekly, }, } } // Validate checks that all preference values are valid. // Returns a domain error if any value is invalid. func (p *UserPreferences) Validate() error { if !validThemes[p.Theme] { return ErrInvalidTheme } if !validLanguages[p.Language] { return ErrInvalidLanguage } if !validDigests[p.Notifications.Digest] { return ErrInvalidDigest } return nil }