code.gitea.io/gitea@v1.21.7/services/forms/repo_branch_form.go (about)

     1  // Copyright 2017 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package forms
     5  
     6  import (
     7  	"net/http"
     8  
     9  	"code.gitea.io/gitea/modules/context"
    10  	"code.gitea.io/gitea/modules/web/middleware"
    11  
    12  	"gitea.com/go-chi/binding"
    13  )
    14  
    15  // NewBranchForm form for creating a new branch
    16  type NewBranchForm struct {
    17  	NewBranchName string `binding:"Required;MaxSize(100);GitRefName"`
    18  	CurrentPath   string
    19  	CreateTag     bool
    20  }
    21  
    22  // Validate validates the fields
    23  func (f *NewBranchForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
    24  	ctx := context.GetValidateContext(req)
    25  	return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
    26  }
    27  
    28  // RenameBranchForm form for rename a branch
    29  type RenameBranchForm struct {
    30  	From string `binding:"Required;MaxSize(100);GitRefName"`
    31  	To   string `binding:"Required;MaxSize(100);GitRefName"`
    32  }
    33  
    34  // Validate validates the fields
    35  func (f *RenameBranchForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
    36  	ctx := context.GetValidateContext(req)
    37  	return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
    38  }