forked from forgejo/forgejo
Move binding as subrepo
This commit is contained in:
parent
33f2d33a46
commit
5c2da610a2
18 changed files with 1594 additions and 445 deletions
|
@ -11,8 +11,6 @@ import (
|
|||
|
||||
"github.com/go-martini/martini"
|
||||
|
||||
"github.com/gogits/binding"
|
||||
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
)
|
||||
|
@ -39,7 +37,7 @@ func (f *RegisterForm) Name(field string) string {
|
|||
return names[field]
|
||||
}
|
||||
|
||||
func (f *RegisterForm) Validate(errors *binding.Errors, req *http.Request, context martini.Context) {
|
||||
func (f *RegisterForm) Validate(errors *base.BindingErrors, req *http.Request, context martini.Context) {
|
||||
if req.Method == "GET" || errors.Count() == 0 {
|
||||
return
|
||||
}
|
||||
|
@ -72,7 +70,7 @@ func (f *LogInForm) Name(field string) string {
|
|||
return names[field]
|
||||
}
|
||||
|
||||
func (f *LogInForm) Validate(errors *binding.Errors, req *http.Request, context martini.Context) {
|
||||
func (f *LogInForm) Validate(errors *base.BindingErrors, req *http.Request, context martini.Context) {
|
||||
if req.Method == "GET" || errors.Count() == 0 {
|
||||
return
|
||||
}
|
||||
|
@ -100,7 +98,7 @@ func getMinMaxSize(field reflect.StructField) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func validate(errors *binding.Errors, data base.TmplData, form Form) {
|
||||
func validate(errors *base.BindingErrors, data base.TmplData, form Form) {
|
||||
typ := reflect.TypeOf(form)
|
||||
val := reflect.ValueOf(form)
|
||||
|
||||
|
@ -121,17 +119,17 @@ func validate(errors *binding.Errors, data base.TmplData, form Form) {
|
|||
if err, ok := errors.Fields[field.Name]; ok {
|
||||
data["Err_"+field.Name] = true
|
||||
switch err {
|
||||
case binding.RequireError:
|
||||
case base.BindingRequireError:
|
||||
data["ErrorMsg"] = form.Name(field.Name) + " cannot be empty"
|
||||
case binding.AlphaDashError:
|
||||
case base.BindingAlphaDashError:
|
||||
data["ErrorMsg"] = form.Name(field.Name) + " must be valid alpha or numeric or dash(-_) characters"
|
||||
case binding.MinSizeError:
|
||||
case base.BindingMinSizeError:
|
||||
data["ErrorMsg"] = form.Name(field.Name) + " must contain at least " + getMinMaxSize(field) + " characters"
|
||||
case binding.MaxSizeError:
|
||||
case base.BindingMaxSizeError:
|
||||
data["ErrorMsg"] = form.Name(field.Name) + " must contain at most " + getMinMaxSize(field) + " characters"
|
||||
case binding.EmailError:
|
||||
case base.BindingEmailError:
|
||||
data["ErrorMsg"] = form.Name(field.Name) + " is not a valid e-mail address"
|
||||
case binding.UrlError:
|
||||
case base.BindingUrlError:
|
||||
data["ErrorMsg"] = form.Name(field.Name) + " is not a valid URL"
|
||||
default:
|
||||
data["ErrorMsg"] = "Unknown error: " + err
|
||||
|
@ -196,7 +194,7 @@ func (f *InstallForm) Name(field string) string {
|
|||
return names[field]
|
||||
}
|
||||
|
||||
func (f *InstallForm) Validate(errors *binding.Errors, req *http.Request, context martini.Context) {
|
||||
func (f *InstallForm) Validate(errors *base.BindingErrors, req *http.Request, context martini.Context) {
|
||||
if req.Method == "GET" || errors.Count() == 0 {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue