1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00
wakapi/models/language_mapping.go

22 lines
745 B
Go
Raw Normal View History

2020-10-25 09:22:10 +03:00
package models
type LanguageMapping struct {
2020-10-27 00:34:50 +03:00
ID uint `json:"id" gorm:"primary_key"`
User *User `json:"-" gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
UserID string `json:"-" gorm:"not null; index:idx_language_mapping_user; uniqueIndex:idx_language_mapping_composite"`
Extension string `json:"extension" gorm:"uniqueIndex:idx_language_mapping_composite; type:varchar(16)"`
Language string `json:"language" gorm:"type:varchar(64)"`
2020-10-25 09:22:10 +03:00
}
func (m *LanguageMapping) IsValid() bool {
return m.validateLanguage() && m.validateExtension()
2020-10-25 09:22:10 +03:00
}
func (m *LanguageMapping) validateLanguage() bool {
return len(m.Language) >= 1
}
func (m *LanguageMapping) validateExtension() bool {
return len(m.Extension) >= 1
2020-10-25 09:22:10 +03:00
}