stufflog graphql server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

42 lines
1001 B

package models
import "unicode"
// A Project is a vague category for issues. It's use depend on the user's judgement, as it could represent
// an entire hobby/job or a single project within one.
type Project struct {
ID string `db:"project_id"`
Name string `db:"name"`
Description string `db:"description"`
DailyPoints int `db:"daily_points"`
}
type ProjectFilter struct {
ProjectIDs []string
Search *string
Permission *ProjectFilterPermission
}
type ProjectFilterPermission struct {
UserID string
MinLevel int
MaxLevel int
}
func (project *Project) ValidKey() bool {
if len(project.ID) < 1 || len(project.ID) > 16 {
return false
}
for _, r := range project.ID {
if !unicode.IsNumber(r) && !unicode.IsUpper(r) && !unicode.Is(unicode.Hiragana, r) && !unicode.Is(unicode.Katakana, r) && !unicode.Is(unicode.Han, r) {
return false
}
}
return true
}
func (pfp *ProjectFilterPermission) Valid() bool {
return pfp.UserID != "" && pfp.MinLevel > 0
}