org.go 916 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package auth
  5. import (
  6. "net/http"
  7. "reflect"
  8. "github.com/go-martini/martini"
  9. "github.com/gogits/gogs/modules/base"
  10. "github.com/gogits/gogs/modules/middleware/binding"
  11. )
  12. type CreateOrganizationForm struct {
  13. OrgName string `form:"orgname" binding:"Required;AlphaDashDot;MaxSize(30)"`
  14. Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
  15. }
  16. func (f *CreateOrganizationForm) Name(field string) string {
  17. names := map[string]string{
  18. "OrgName": "Organization name",
  19. "Email": "E-mail address",
  20. }
  21. return names[field]
  22. }
  23. func (f *CreateOrganizationForm) Validate(errs *binding.Errors, req *http.Request, ctx martini.Context) {
  24. data := ctx.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData)
  25. validate(errs, data, f)
  26. }