mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-03 12:00:51 +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:
@@ -53,7 +53,7 @@ type EditUserOption struct {
|
||||
// Whether the user must change password on next login
|
||||
MustChangePassword *bool `json:"must_change_password"`
|
||||
// The user's personal website URL
|
||||
Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"`
|
||||
Website *string `json:"website" binding:"ValidUrl;MaxSize(255)"`
|
||||
// The user's location or address
|
||||
Location *string `json:"location" binding:"MaxSize(50)"`
|
||||
// The user's personal description or bio
|
||||
|
||||
@@ -5,8 +5,7 @@ package structs
|
||||
|
||||
import (
|
||||
"gitea.dev/modules/translation/i18n"
|
||||
|
||||
"gitea.com/go-chi/binding" //nolint:depguard // avoid cycle import
|
||||
"gitea.dev/modules/web/binding"
|
||||
)
|
||||
|
||||
// ValidateContext is a special context for form validation middleware
|
||||
|
||||
@@ -63,7 +63,7 @@ type CreateTeamOption struct {
|
||||
// Whether the team can create repositories in the organization
|
||||
CanCreateOrgRepo bool `json:"can_create_org_repo"`
|
||||
// Team visibility within the organization. Defaults to "private".
|
||||
Visibility TeamVisibility `json:"visibility" binding:"OmitEmpty;In(public,limited,private)"`
|
||||
Visibility TeamVisibility `json:"visibility" binding:"In(public,limited,private)"`
|
||||
}
|
||||
|
||||
// EditTeamOption options for editing a team
|
||||
@@ -85,5 +85,5 @@ type EditTeamOption struct {
|
||||
CanCreateOrgRepo *bool `json:"can_create_org_repo"`
|
||||
// Team visibility within the organization. When omitted, visibility is
|
||||
// left unchanged.
|
||||
Visibility *TeamVisibility `json:"visibility" binding:"OmitEmpty;In(public,limited,private)"`
|
||||
Visibility *TeamVisibility `json:"visibility" binding:"In(public,limited,private)"`
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ type CreateRepoOption struct {
|
||||
type EditRepoOption struct {
|
||||
// name of the repository
|
||||
// unique: true
|
||||
Name *string `json:"name,omitempty" binding:"OmitEmpty;AlphaDashDot;MaxSize(100);"`
|
||||
Name *string `json:"name,omitempty" binding:"AlphaDashDot;MaxSize(100)"`
|
||||
// a short description of the repository.
|
||||
Description *string `json:"description,omitempty" binding:"MaxSize(2048)"`
|
||||
// a URL with more information about the repository.
|
||||
|
||||
@@ -89,7 +89,7 @@ type UserSettings struct {
|
||||
// swagger:model
|
||||
type UserSettingsOptions struct {
|
||||
FullName *string `json:"full_name" binding:"MaxSize(100)"`
|
||||
Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"`
|
||||
Website *string `json:"website" binding:"ValidUrl;MaxSize(255)"`
|
||||
Description *string `json:"description" binding:"MaxSize(255)"`
|
||||
Location *string `json:"location" binding:"MaxSize(50)"`
|
||||
Language *string `json:"language"`
|
||||
|
||||
Reference in New Issue
Block a user