mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-03 17:48:45 +00:00
refactor: move go-chi/binding into Gitea (#39528)
The `gitea.com/go-chi/binding` package only exists for Gitea, so it moves into `modules/web/binding` to fix its bugs directly. Split out of https://github.com/go-gitea/gitea/pull/39504. - GET and HEAD always bind the query - JSON `null` slice elements and nested `TrimSpace` fields bind correctly - Integer fields reject out-of-range values instead of wrapping - An empty JSON body binds nothing and an unknown binding rule is an error Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: bircni <bircni@icloud.com>
This commit is contained in:
@@ -65,6 +65,6 @@ type AdminEditUserForm struct {
|
||||
// AdminDashboardForm form for admin dashboard operations
|
||||
type AdminDashboardForm struct {
|
||||
middleware.FormDefaultValidator
|
||||
Op string `binding:"required"`
|
||||
Op string `binding:"Required"`
|
||||
From string
|
||||
}
|
||||
|
||||
@@ -57,5 +57,5 @@ type CreateTeamForm struct {
|
||||
Permission string
|
||||
RepoAccess string
|
||||
CanCreateOrgRepo bool
|
||||
Visibility string `binding:"OmitEmpty;In(public,limited,private)"`
|
||||
Visibility string `binding:"In(public,limited,private)"`
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ type CreateIssueForm struct {
|
||||
type CreateCommentForm struct {
|
||||
middleware.FormDefaultValidator
|
||||
Content string
|
||||
Status string `binding:"OmitEmpty;In(reopen,close)"`
|
||||
Status string `binding:"In(reopen,close)"`
|
||||
Files []string
|
||||
}
|
||||
|
||||
@@ -571,12 +571,6 @@ type AddTimeManuallyForm struct {
|
||||
Minutes int `binding:"Range(0,1000)"`
|
||||
}
|
||||
|
||||
// SaveTopicForm form for save topics for repository
|
||||
type SaveTopicForm struct {
|
||||
middleware.FormDefaultValidator
|
||||
Topics []string `binding:"topics;Required;"`
|
||||
}
|
||||
|
||||
// AddDeployTokenForm form for adding a deploy token to a repository
|
||||
type AddDeployTokenForm struct {
|
||||
middleware.FormDefaultValidator
|
||||
|
||||
@@ -38,7 +38,7 @@ type InstallForm struct {
|
||||
SMTPAddr string `binding:"TrimSpace"`
|
||||
SMTPPort string `binding:"TrimSpace"`
|
||||
SMTPFrom string `binding:"TrimSpace"`
|
||||
SMTPUser string `binding:"TrimSpace;OmitEmpty;MaxSize(254)" locale:"install.mailer_user"`
|
||||
SMTPUser string `binding:"TrimSpace;MaxSize(254)" locale:"install.mailer_user"`
|
||||
SMTPPasswd string
|
||||
RegisterConfirm bool
|
||||
MailNotify bool
|
||||
@@ -183,7 +183,7 @@ type AvatarForm struct {
|
||||
middleware.FormDefaultValidator
|
||||
Source string
|
||||
Avatar *multipart.FileHeader
|
||||
Gravatar string `binding:"OmitEmpty;Email;MaxSize(254)"`
|
||||
Gravatar string `binding:"Email;MaxSize(254)"`
|
||||
}
|
||||
|
||||
// AddEmailForm form for adding new email
|
||||
@@ -215,12 +215,12 @@ type AddOpenIDForm struct {
|
||||
// AddKeyForm form for adding SSH/GPG key
|
||||
type AddKeyForm struct {
|
||||
middleware.FormDefaultValidator
|
||||
Type string `binding:"OmitEmpty"`
|
||||
Type string
|
||||
Title string `binding:"Required;MaxSize(50)"`
|
||||
Content string `binding:"Required"`
|
||||
Signature string `binding:"OmitEmpty"`
|
||||
KeyID string `binding:"OmitEmpty"`
|
||||
Fingerprint string `binding:"OmitEmpty"`
|
||||
Signature string
|
||||
KeyID string
|
||||
Fingerprint string
|
||||
IsWritable bool
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user