code.gitea.io/gitea@v1.21.7/services/forms/org.go (about) 1 // Copyright 2014 The Gogs Authors. All rights reserved. 2 // Copyright 2019 The Gitea Authors. All rights reserved. 3 // SPDX-License-Identifier: MIT 4 5 package forms 6 7 import ( 8 "net/http" 9 10 "code.gitea.io/gitea/modules/context" 11 "code.gitea.io/gitea/modules/structs" 12 "code.gitea.io/gitea/modules/web/middleware" 13 14 "gitea.com/go-chi/binding" 15 ) 16 17 // ________ .__ __ .__ 18 // \_____ \_______ _________ ____ |__|____________ _/ |_|__| ____ ____ 19 // / | \_ __ \/ ___\__ \ / \| \___ /\__ \\ __\ |/ _ \ / \ 20 // / | \ | \/ /_/ > __ \| | \ |/ / / __ \| | | ( <_> ) | \ 21 // \_______ /__| \___ (____ /___| /__/_____ \(____ /__| |__|\____/|___| / 22 // \/ /_____/ \/ \/ \/ \/ \/ 23 24 // CreateOrgForm form for creating organization 25 type CreateOrgForm struct { 26 OrgName string `binding:"Required;Username;MaxSize(40)" locale:"org.org_name_holder"` 27 Visibility structs.VisibleType 28 RepoAdminChangeTeamAccess bool 29 } 30 31 // Validate validates the fields 32 func (f *CreateOrgForm) Validate(req *http.Request, errs binding.Errors) binding.Errors { 33 ctx := context.GetValidateContext(req) 34 return middleware.Validate(errs, ctx.Data, f, ctx.Locale) 35 } 36 37 // UpdateOrgSettingForm form for updating organization settings 38 type UpdateOrgSettingForm struct { 39 Name string `binding:"Required;Username;MaxSize(40)" locale:"org.org_name_holder"` 40 FullName string `binding:"MaxSize(100)"` 41 Email string `binding:"MaxSize(255)"` 42 Description string `binding:"MaxSize(255)"` 43 Website string `binding:"ValidUrl;MaxSize(255)"` 44 Location string `binding:"MaxSize(50)"` 45 Visibility structs.VisibleType 46 MaxRepoCreation int 47 RepoAdminChangeTeamAccess bool 48 } 49 50 // Validate validates the fields 51 func (f *UpdateOrgSettingForm) Validate(req *http.Request, errs binding.Errors) binding.Errors { 52 ctx := context.GetValidateContext(req) 53 return middleware.Validate(errs, ctx.Data, f, ctx.Locale) 54 } 55 56 // ___________ 57 // \__ ___/___ _____ _____ 58 // | |_/ __ \\__ \ / \ 59 // | |\ ___/ / __ \| Y Y \ 60 // |____| \___ >____ /__|_| / 61 // \/ \/ \/ 62 63 // CreateTeamForm form for creating team 64 type CreateTeamForm struct { 65 TeamName string `binding:"Required;AlphaDashDot;MaxSize(30)"` 66 Description string `binding:"MaxSize(255)"` 67 Permission string 68 RepoAccess string 69 CanCreateOrgRepo bool 70 } 71 72 // Validate validates the fields 73 func (f *CreateTeamForm) Validate(req *http.Request, errs binding.Errors) binding.Errors { 74 ctx := context.GetValidateContext(req) 75 return middleware.Validate(errs, ctx.Data, f, ctx.Locale) 76 }