mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-03 01:28:51 +00:00
e6ffbea888
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>
22 lines
590 B
Go
22 lines
590 B
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package structs
|
|
|
|
import (
|
|
"gitea.dev/modules/translation/i18n"
|
|
"gitea.dev/modules/web/binding"
|
|
)
|
|
|
|
// ValidateContext is a special context for form validation middleware
|
|
type ValidateContext struct {
|
|
Locale i18n.LocaleTranslation
|
|
}
|
|
|
|
type FormDefaultValidator struct{}
|
|
|
|
func (FormDefaultValidator) Validate(ctx *ValidateContext, errs binding.Errors) binding.Errors {
|
|
// this default validator only needs to return the errs as is because the "binding" function has already validated
|
|
return errs
|
|
}
|