diff options
Diffstat (limited to 'modules/auth/auth.go')
-rw-r--r-- | modules/auth/auth.go | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/modules/auth/auth.go b/modules/auth/auth.go index ecae5b06..2e4c80c5 100644 --- a/modules/auth/auth.go +++ b/modules/auth/auth.go @@ -10,9 +10,9 @@ import ( "time" "github.com/Unknwon/com" - "github.com/Unknwon/macaron" - "github.com/macaron-contrib/binding" - "github.com/macaron-contrib/session" + "github.com/go-macaron/binding" + "github.com/go-macaron/session" + "gopkg.in/macaron.v1" "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/base" @@ -181,7 +181,7 @@ func AssignForm(form interface{}, data map[string]interface{}) { } } -func getSize(field reflect.StructField, prefix string) string { +func getRuleBody(field reflect.StructField, prefix string) string { for _, rule := range strings.Split(field.Tag.Get("binding"), ";") { if strings.HasPrefix(rule, prefix) { return rule[len(prefix) : len(rule)-1] @@ -191,15 +191,19 @@ func getSize(field reflect.StructField, prefix string) string { } func GetSize(field reflect.StructField) string { - return getSize(field, "Size(") + return getRuleBody(field, "Size(") } func GetMinSize(field reflect.StructField) string { - return getSize(field, "MinSize(") + return getRuleBody(field, "MinSize(") } func GetMaxSize(field reflect.StructField) string { - return getSize(field, "MaxSize(") + return getRuleBody(field, "MaxSize(") +} + +func GetInclude(field reflect.StructField) string { + return getRuleBody(field, "Include(") } // FIXME: struct contains a struct @@ -260,6 +264,8 @@ func validate(errs binding.Errors, data map[string]interface{}, f Form, l macaro data["ErrorMsg"] = trName + l.Tr("form.email_error") case binding.ERR_URL: data["ErrorMsg"] = trName + l.Tr("form.url_error") + case binding.ERR_INCLUDE: + data["ErrorMsg"] = trName + l.Tr("form.include_error", GetInclude(field)) default: data["ErrorMsg"] = l.Tr("form.unknown_error") + " " + errs[0].Classification } |