Add validation constraints for repository creation fields#36671
Add validation constraints for repository creation fields#36671lunny wants to merge 5 commits intogo-gitea:mainfrom
Conversation
|
Other fields like |
Only the |
These restrictions have been added to enforce stricter validation and prevent potential issues or unnecessary problems. |
There was a problem hiding this comment.
Pull request overview
This pull request adds input validation constraints to repository creation form fields and API options, limiting the size of various string fields to prevent potential issues with excessively long input values.
Changes:
- Added MaxSize validation to License (100), Gitignores (255), IssueLabels (255), Readme (255), and ForkSingleBranch (255) fields
- Added enum validation with In() to ObjectFormatName (sha1, sha256) and TrustModel (default, collaborator, committer, collaboratorcommitter) fields
- Applied validation consistently to both web form structs (CreateRepoForm) and API structs (CreateRepoOption)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| services/forms/repo_form.go | Added MaxSize and In() validation tags to CreateRepoForm fields for web form validation |
| modules/structs/repo.go | Added MaxSize and In() validation tags to CreateRepoOption fields for API validation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Update PR title please to reflect that it's not only license. |
Adds validation constraints to repository creation inputs, enforcing max-length limits for labels/gitignores/license/readme and enum validation for trust model and object format. Updates both the API option struct and the web form struct to keep validation consistent.