🐛 Fix validation conditions

This commit is contained in:
LittleSheep 2024-07-23 18:05:54 +08:00
parent fba515fc70
commit 5af3e280b9
3 changed files with 7 additions and 7 deletions

View File

@ -20,7 +20,7 @@ func createArticle(c *fiber.Ctx) error {
var data struct { var data struct {
Title string `json:"title" validate:"required,max=1024"` Title string `json:"title" validate:"required,max=1024"`
Description *string `json:"description" validate:"max=2048"` Description *string `json:"description"`
Content string `json:"content" validate:"required"` Content string `json:"content" validate:"required"`
Attachments []uint `json:"attachments"` Attachments []uint `json:"attachments"`
Tags []models.Tag `json:"tags"` Tags []models.Tag `json:"tags"`
@ -85,7 +85,7 @@ func editArticle(c *fiber.Ctx) error {
var data struct { var data struct {
Title string `json:"title" validate:"required,max=1024"` Title string `json:"title" validate:"required,max=1024"`
Description *string `json:"description" validate:"max=2048"` Description *string `json:"description"`
Content string `json:"content" validate:"required"` Content string `json:"content" validate:"required"`
Attachments []uint `json:"attachments"` Attachments []uint `json:"attachments"`
Tags []models.Tag `json:"tags"` Tags []models.Tag `json:"tags"`

View File

@ -24,7 +24,7 @@ func MapAPIs(app *fiber.App, baseURL string) {
articles := api.Group("/articles").Name("Article API") articles := api.Group("/articles").Name("Article API")
{ {
articles.Post("/", createArticle) articles.Post("/", createArticle)
articles.Put("/:articleId", editArticle) articles.Put("/:postId", editArticle)
} }
posts := api.Group("/posts").Name("Posts API") posts := api.Group("/posts").Name("Posts API")

View File

@ -19,9 +19,9 @@ func createStory(c *fiber.Ctx) error {
user := c.Locals("user").(models.Account) user := c.Locals("user").(models.Account)
var data struct { var data struct {
Title *string `json:"title" validate:"max=1024"` Title *string `json:"title"`
Content string `json:"content" validate:"required,max=4096"` Content string `json:"content" validate:"required,max=4096"`
Location *string `json:"location" validate:"max=2048"` Location *string `json:"location"`
Attachments []uint `json:"attachments"` Attachments []uint `json:"attachments"`
Tags []models.Tag `json:"tags"` Tags []models.Tag `json:"tags"`
Categories []models.Category `json:"categories"` Categories []models.Category `json:"categories"`
@ -103,9 +103,9 @@ func editStory(c *fiber.Ctx) error {
user := c.Locals("user").(models.Account) user := c.Locals("user").(models.Account)
var data struct { var data struct {
Title *string `json:"title" validate:"max=1024"` Title *string `json:"title"`
Content string `json:"content" validate:"required,max=4096"` Content string `json:"content" validate:"required,max=4096"`
Location *string `json:"location" validate:"max=2048"` Location *string `json:"location"`
Attachments []uint `json:"attachments"` Attachments []uint `json:"attachments"`
Tags []models.Tag `json:"tags"` Tags []models.Tag `json:"tags"`
Categories []models.Category `json:"categories"` Categories []models.Category `json:"categories"`