mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-16 02:55:08 +00:00
refactor: clean up form binding & validation (#38873)
Clarify the "validation" and "error display" logic. All the copied&pasted `Validate` functions are removed.
This commit is contained in:
@@ -3,16 +3,10 @@
|
||||
|
||||
package forms
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"gitea.dev/modules/web/middleware"
|
||||
"gitea.dev/services/context"
|
||||
|
||||
"gitea.com/go-chi/binding"
|
||||
)
|
||||
import "gitea.dev/modules/web/middleware"
|
||||
|
||||
type PackageCleanupRuleForm struct {
|
||||
middleware.FormDefaultValidator
|
||||
ID int64
|
||||
Enabled bool
|
||||
Type string `binding:"Required;In(alpine,arch,cargo,chef,composer,conan,conda,container,cran,debian,generic,go,helm,maven,npm,nuget,pub,pypi,rpm,rubygems,swift,terraform,vagrant)"`
|
||||
@@ -23,8 +17,3 @@ type PackageCleanupRuleForm struct {
|
||||
MatchFullName bool
|
||||
Action string `binding:"Required;In(save,remove)"`
|
||||
}
|
||||
|
||||
func (f *PackageCleanupRuleForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
|
||||
ctx := context.GetValidateContext(req)
|
||||
return middleware.Validate(ctx, errs, f)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user