feat: add validation tags to request DTOs
This commit is contained in:
@@ -1,51 +1,51 @@
|
|||||||
package dto
|
package dto
|
||||||
|
|
||||||
type LoginRequest struct {
|
type LoginRequest struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username" validate:"required,min=3,max=50"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password" validate:"required,min=8,max=128"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RegisterRequest struct {
|
type RegisterRequest struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username" validate:"required,min=3,max=50"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email" validate:"required,email,max=254"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password" validate:"required,min=8,max=128"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResendVerificationRequest struct {
|
type ResendVerificationRequest struct {
|
||||||
Email string `json:"email"`
|
Email string `json:"email" validate:"required,email,max=254"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ForgotPasswordRequest struct {
|
type ForgotPasswordRequest struct {
|
||||||
UsernameOrEmail string `json:"username_or_email"`
|
UsernameOrEmail string `json:"username_or_email" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResetPasswordRequest struct {
|
type ResetPasswordRequest struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token" validate:"required"`
|
||||||
NewPassword string `json:"new_password"`
|
NewPassword string `json:"new_password" validate:"required,min=8,max=128"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateEmailRequest struct {
|
type UpdateEmailRequest struct {
|
||||||
Email string `json:"email"`
|
Email string `json:"email" validate:"required,email,max=254"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateUsernameRequest struct {
|
type UpdateUsernameRequest struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username" validate:"required,min=3,max=50"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdatePasswordRequest struct {
|
type UpdatePasswordRequest struct {
|
||||||
CurrentPassword string `json:"current_password"`
|
CurrentPassword string `json:"current_password" validate:"required"`
|
||||||
NewPassword string `json:"new_password"`
|
NewPassword string `json:"new_password" validate:"required,min=8,max=128"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfirmAccountDeletionRequest struct {
|
type ConfirmAccountDeletionRequest struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token" validate:"required"`
|
||||||
DeletePosts bool `json:"delete_posts"`
|
DeletePosts bool `json:"delete_posts"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RefreshTokenRequest struct {
|
type RefreshTokenRequest struct {
|
||||||
RefreshToken string `json:"refresh_token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." binding:"required"`
|
RefreshToken string `json:"refresh_token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RevokeTokenRequest struct {
|
type RevokeTokenRequest struct {
|
||||||
RefreshToken string `json:"refresh_token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." binding:"required"`
|
RefreshToken string `json:"refresh_token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." validate:"required"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package dto
|
package dto
|
||||||
|
|
||||||
type CreatePostRequest struct {
|
type CreatePostRequest struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title" validate:"omitempty,min=3,max=200"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url" validate:"required,url,max=2048"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content" validate:"omitempty,max=10000"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdatePostRequest struct {
|
type UpdatePostRequest struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title" validate:"required,min=3,max=200"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content" validate:"omitempty,max=10000"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user