From d51ed8defd8dfda32645e414aba72d30e7211811 Mon Sep 17 00:00:00 2001 From: konrad Date: Sat, 24 Nov 2018 12:44:40 +0000 Subject: [PATCH] make validation less verbose (#23) --- pkg/models/list.go | 6 +++--- pkg/models/list_tasks.go | 6 +++--- pkg/models/list_users.go | 4 ++-- pkg/models/namespace.go | 4 ++-- pkg/models/namespace_users.go | 4 ++-- pkg/models/team_list.go | 4 ++-- pkg/models/team_namespace.go | 4 ++-- pkg/models/teams.go | 8 ++++---- pkg/models/user.go | 4 ++-- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pkg/models/list.go b/pkg/models/list.go index 02591408..97bcdc92 100644 --- a/pkg/models/list.go +++ b/pkg/models/list.go @@ -5,7 +5,7 @@ import "sort" // List represents a list of tasks type List struct { ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"list"` - Title string `xorm:"varchar(250)" json:"title" valid:"required,runelength(5|250)"` + Title string `xorm:"varchar(250)" json:"title" valid:"required,runelength(3|250)"` Description string `xorm:"varchar(1000)" json:"description" valid:"runelength(0|1000)"` OwnerID int64 `xorm:"int(11) INDEX" json:"-"` NamespaceID int64 `xorm:"int(11) INDEX" json:"-" param:"namespace"` @@ -13,8 +13,8 @@ type List struct { Owner User `xorm:"-" json:"owner"` Tasks []*ListTask `xorm:"-" json:"tasks"` - Created int64 `xorm:"created" json:"created" valid:"range(0|0)"` - Updated int64 `xorm:"updated" json:"updated" valid:"range(0|0)"` + Created int64 `xorm:"created" json:"created"` + Updated int64 `xorm:"updated" json:"updated"` CRUDable `xorm:"-" json:"-"` Rights `xorm:"-" json:"-"` diff --git a/pkg/models/list_tasks.go b/pkg/models/list_tasks.go index d867c293..85bf08c9 100644 --- a/pkg/models/list_tasks.go +++ b/pkg/models/list_tasks.go @@ -3,7 +3,7 @@ package models // ListTask represents an task in a todolist type ListTask struct { ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"listtask"` - Text string `xorm:"varchar(250)" json:"text" valid:"runelength(5|250)"` + Text string `xorm:"varchar(250)" json:"text" valid:"runelength(3|250)"` Description string `xorm:"varchar(250)" json:"description" valid:"runelength(0|250)"` Done bool `xorm:"INDEX" json:"done"` DueDateUnix int64 `xorm:"int(11) INDEX" json:"dueDate"` @@ -11,8 +11,8 @@ type ListTask struct { CreatedByID int64 `xorm:"int(11)" json:"-"` // ID of the user who put that task on the list ListID int64 `xorm:"int(11) INDEX" json:"listID" param:"list"` - Created int64 `xorm:"created" json:"created" valid:"range(0|0)"` - Updated int64 `xorm:"updated" json:"updated" valid:"range(0|0)"` + Created int64 `xorm:"created" json:"created"` + Updated int64 `xorm:"updated" json:"updated"` CreatedBy User `xorm:"-" json:"createdBy"` diff --git a/pkg/models/list_users.go b/pkg/models/list_users.go index 1a80afd7..fd0f8630 100644 --- a/pkg/models/list_users.go +++ b/pkg/models/list_users.go @@ -7,8 +7,8 @@ type ListUser struct { ListID int64 `xorm:"int(11) not null INDEX" json:"list_id" param:"list"` Right UserRight `xorm:"int(11) INDEX" json:"right" valid:"length(0|2)"` - Created int64 `xorm:"created" json:"created" valid:"range(0|0)"` - Updated int64 `xorm:"updated" json:"updated" valid:"range(0|0)"` + Created int64 `xorm:"created" json:"created"` + Updated int64 `xorm:"updated" json:"updated"` CRUDable `xorm:"-" json:"-"` Rights `xorm:"-" json:"-"` diff --git a/pkg/models/namespace.go b/pkg/models/namespace.go index d7f2c172..debec602 100644 --- a/pkg/models/namespace.go +++ b/pkg/models/namespace.go @@ -11,8 +11,8 @@ type Namespace struct { Owner User `xorm:"-" json:"owner"` - Created int64 `xorm:"created" json:"created" valid:"range(0|0)"` - Updated int64 `xorm:"updated" json:"updated" valid:"range(0|0)"` + Created int64 `xorm:"created" json:"created"` + Updated int64 `xorm:"updated" json:"updated"` CRUDable `xorm:"-" json:"-"` Rights `xorm:"-" json:"-"` diff --git a/pkg/models/namespace_users.go b/pkg/models/namespace_users.go index 70c71012..a48f03ba 100644 --- a/pkg/models/namespace_users.go +++ b/pkg/models/namespace_users.go @@ -7,8 +7,8 @@ type NamespaceUser struct { NamespaceID int64 `xorm:"int(11) not null INDEX" json:"namespace_id" param:"namespace"` Right UserRight `xorm:"int(11) INDEX" json:"right" valid:"length(0|2)"` - Created int64 `xorm:"created" json:"created" valid:"range(0|0)"` - Updated int64 `xorm:"updated" json:"updated" valid:"range(0|0)"` + Created int64 `xorm:"created" json:"created"` + Updated int64 `xorm:"updated" json:"updated"` CRUDable `xorm:"-" json:"-"` Rights `xorm:"-" json:"-"` diff --git a/pkg/models/team_list.go b/pkg/models/team_list.go index 55f99328..c69f38a5 100644 --- a/pkg/models/team_list.go +++ b/pkg/models/team_list.go @@ -7,8 +7,8 @@ type TeamList struct { ListID int64 `xorm:"int(11) not null INDEX" json:"list_id" param:"list"` Right TeamRight `xorm:"int(11) INDEX" json:"right" valid:"length(0|2)"` - Created int64 `xorm:"created" json:"created" valid:"range(0|0)"` - Updated int64 `xorm:"updated" json:"updated" valid:"range(0|0)"` + Created int64 `xorm:"created" json:"created"` + Updated int64 `xorm:"updated" json:"updated"` CRUDable `xorm:"-" json:"-"` Rights `xorm:"-" json:"-"` diff --git a/pkg/models/team_namespace.go b/pkg/models/team_namespace.go index bf678149..991aee95 100644 --- a/pkg/models/team_namespace.go +++ b/pkg/models/team_namespace.go @@ -7,8 +7,8 @@ type TeamNamespace struct { NamespaceID int64 `xorm:"int(11) not null INDEX" json:"namespace_id" param:"namespace"` Right TeamRight `xorm:"int(11) INDEX" json:"right" valid:"length(0|2)"` - Created int64 `xorm:"created" json:"created" valid:"range(0|0)"` - Updated int64 `xorm:"updated" json:"updated" valid:"range(0|0)"` + Created int64 `xorm:"created" json:"created"` + Updated int64 `xorm:"updated" json:"updated"` CRUDable `xorm:"-" json:"-"` Rights `xorm:"-" json:"-"` diff --git a/pkg/models/teams.go b/pkg/models/teams.go index 169f4376..b7417ef2 100644 --- a/pkg/models/teams.go +++ b/pkg/models/teams.go @@ -10,8 +10,8 @@ type Team struct { CreatedBy User `xorm:"-" json:"created_by"` Members []*TeamUser `xorm:"-" json:"members"` - Created int64 `xorm:"created" json:"created" valid:"range(0|0)"` - Updated int64 `xorm:"updated" json:"updated" valid:"range(0|0)"` + Created int64 `xorm:"created" json:"created"` + Updated int64 `xorm:"updated" json:"updated"` CRUDable `xorm:"-" json:"-"` Rights `xorm:"-" json:"-"` @@ -42,8 +42,8 @@ type TeamMember struct { UserID int64 `xorm:"int(11) not null INDEX" json:"user_id" param:"user"` Admin bool `xorm:"tinyint(1) INDEX" json:"admin"` - Created int64 `xorm:"created" json:"created" valid:"range(0|0)"` - Updated int64 `xorm:"updated" json:"updated" valid:"range(0|0)"` + Created int64 `xorm:"created" json:"created"` + Updated int64 `xorm:"updated" json:"updated"` CRUDable `xorm:"-" json:"-"` Rights `xorm:"-" json:"-"` diff --git a/pkg/models/user.go b/pkg/models/user.go index d26f19f1..5bd31e09 100644 --- a/pkg/models/user.go +++ b/pkg/models/user.go @@ -23,8 +23,8 @@ type User struct { PasswordResetToken string `xorm:"varchar(450)" json:"-"` EmailConfirmToken string `xorm:"varchar(450)" json:"-"` - Created int64 `xorm:"created" json:"created" valid:"range(0|0)"` - Updated int64 `xorm:"updated" json:"updated" valid:"range(0|0)"` + Created int64 `xorm:"created" json:"created"` + Updated int64 `xorm:"updated" json:"updated"` } // TableName returns the table name for users