summaryrefslogtreecommitdiffstats
path: root/modules/base/base.go
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-04-13 01:57:42 -0400
committerUnknown <joe2010xtmf@163.com>2014-04-13 01:57:42 -0400
commit5c2da610a2cfd3fa9666d20739e054c3588b4d05 (patch)
treeb78f9ce7181a1c204787daedf8b8224f3f77ffa1 /modules/base/base.go
parent33f2d33a4688cec0fc18bb38f7fae49aedc40504 (diff)
downloadgitea-5c2da610a2cfd3fa9666d20739e054c3588b4d05.tar.gz
gitea-5c2da610a2cfd3fa9666d20739e054c3588b4d05.zip
Move binding as subrepo
Diffstat (limited to 'modules/base/base.go')
-rw-r--r--modules/base/base.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/modules/base/base.go b/modules/base/base.go
index 7c08dcc5ce..84cf41c8d6 100644
--- a/modules/base/base.go
+++ b/modules/base/base.go
@@ -8,3 +8,49 @@ type (
// Type TmplData represents data in the templates.
TmplData map[string]interface{}
)
+
+// __________.__ .___.__
+// \______ \__| ____ __| _/|__| ____ ____
+// | | _/ |/ \ / __ | | |/ \ / ___\
+// | | \ | | \/ /_/ | | | | \/ /_/ >
+// |______ /__|___| /\____ | |__|___| /\___ /
+// \/ \/ \/ \//_____/
+
+// Errors represents the contract of the response body when the
+// binding step fails before getting to the application.
+type BindingErrors struct {
+ Overall map[string]string `json:"overall"`
+ Fields map[string]string `json:"fields"`
+}
+
+// Total errors is the sum of errors with the request overall
+// and errors on individual fields.
+func (err BindingErrors) Count() int {
+ return len(err.Overall) + len(err.Fields)
+}
+
+func (this *BindingErrors) Combine(other BindingErrors) {
+ for key, val := range other.Fields {
+ if _, exists := this.Fields[key]; !exists {
+ this.Fields[key] = val
+ }
+ }
+ for key, val := range other.Overall {
+ if _, exists := this.Overall[key]; !exists {
+ this.Overall[key] = val
+ }
+ }
+}
+
+const (
+ BindingRequireError string = "Required"
+ BindingAlphaDashError string = "AlphaDash"
+ BindingMinSizeError string = "MinSize"
+ BindingMaxSizeError string = "MaxSize"
+ BindingEmailError string = "Email"
+ BindingUrlError string = "Url"
+ BindingDeserializationError string = "DeserializationError"
+ BindingIntegerTypeError string = "IntegerTypeError"
+ BindingBooleanTypeError string = "BooleanTypeError"
+ BindingFloatTypeError string = "FloatTypeError"
+)