2020-10-25 09:22:10 +03:00
|
|
|
package models
|
|
|
|
|
2020-11-01 22:14:10 +03:00
|
|
|
type LanguageMapping struct {
|
2020-10-27 00:34:50 +03:00
|
|
|
ID uint `json:"id" gorm:"primary_key"`
|
2020-11-06 19:09:41 +03:00
|
|
|
User *User `json:"-" gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
|
2020-11-01 22:14:10 +03:00
|
|
|
UserID string `json:"-" gorm:"not null; index:idx_language_mapping_user; uniqueIndex:idx_language_mapping_composite"`
|
2020-11-06 16:07:07 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-11-06 16:07:07 +03:00
|
|
|
func (m *LanguageMapping) IsValid() bool {
|
|
|
|
return m.validateLanguage() && m.validateExtension()
|
2020-10-25 09:22:10 +03:00
|
|
|
}
|
|
|
|
|
2020-11-06 16:07:07 +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
|
|
|
}
|