Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Binding requirements for gin

Cette révision appartient à :
akuma06 2017-07-03 01:47:31 +02:00
Parent f3a323d7b8
révision d84c294c1b
2 fichiers modifiés avec 45 ajouts et 45 suppressions

Voir le fichier

@ -3,21 +3,21 @@ package torrentValidator
// TorrentRequest struct // TorrentRequest struct
// Same json name as the constant! // Same json name as the constant!
type TorrentRequest struct { type TorrentRequest struct {
Name string `validate:"required" json:"name,omitempty"` Name string `validate:"required" form:"name" json:"name,omitempty"`
Magnet string `json:"magnet,omitempty"` Magnet string `json:"magnet,omitempty" form:"magnet"`
Category string `validate:"required" json:"c"` Category string `validate:"required" form:"c" json:"c"`
Remake bool `json:"remake,omitempty"` Remake bool `json:"remake,omitempty" form:"remake"`
Description string `json:"desc,omitempty"` Description string `json:"desc,omitempty" form:"desc"`
Status int `json:"status,omitempty"` Status int `json:"status,omitempty" form:"status"`
Hidden bool `json:"hidden,omitempty"` Hidden bool `json:"hidden,omitempty" form:"hidden"`
CaptchaID string `json:"-"` CaptchaID string `json:"-" form:"captchaID"`
WebsiteLink string `validate:"uri" json:"website_link,omitempty"` WebsiteLink string `validate:"uri" json:"website_link,omitempty" form:"website_link"`
SubCategory int `json:"sub_category,omitempty"` SubCategory int `json:"sub_category,omitempty" form:"sub_category"`
Languages []string `json:"languages,omitempty"` Languages []string `json:"languages,omitempty" form:"languages"`
Infohash string `json:"hash,omitempty"` Infohash string `json:"hash,omitempty" form:"hash"`
CategoryID int `json:"-"` CategoryID int `json:"-" form:"category_id"`
SubCategoryID int `json:"-"` SubCategoryID int `json:"-" form:"subcategory_id"`
Filesize int64 `json:"filesize,omitempty"` Filesize int64 `json:"filesize,omitempty"`
Filepath string `json:"-"` Filepath string `json:"-"`
FileList []uploadedFile `json:"filelist,omitempty"` FileList []uploadedFile `json:"filelist,omitempty"`

Voir le fichier

@ -2,59 +2,59 @@ package userValidator
// RegistrationForm is used when creating a user. // RegistrationForm is used when creating a user.
type RegistrationForm struct { type RegistrationForm struct {
Username string `validate:"required,min=3,max=20"` Username string `validate:"required,min=3,max=20" form:"username" json:"username"`
Email string Email string `form:"email" json:"email"`
Password string `validate:"required,min=6,max=72,eqfield=ConfirmPassword"` Password string `validate:"required,min=6,max=72,eqfield=ConfirmPassword" form:"password" json:"password"`
ConfirmPassword string `validate:"required" omit:"true"` // Omit when binding to user model since user model doesn't have those field ConfirmPassword string `validate:"required" omit:"true" form:"password_confirmation" json:"password_confirmation"` // Omit when binding to user model since user model doesn't have those field
CaptchaID string `validate:"required" omit:"true"` CaptchaID string `validate:"required" omit:"true" form:"captchaID" json:"captchaID"`
TermsAndConditions string `validate:"eq=true" omit:"true"` TermsAndConditions string `validate:"eq=true" omit:"true" form:"t_and_c" json:"t_and_c"`
} }
// LoginForm is used when a user logs in. // LoginForm is used when a user logs in.
type LoginForm struct { type LoginForm struct {
Username string `validate:"required" json:"username"` Username string `validate:"required" json:"username" form:"username"`
Password string `validate:"required" json:"password"` Password string `validate:"required" json:"password" form:"password"`
} }
// UserForm is used when updating a user. // UserForm is used when updating a user.
type UserForm struct { type UserForm struct {
Username string `validate:"required" json:"username" needed:"true" len_min:"3" len_max:"20"` Username string `validate:"required" form:"username" json:"username" needed:"true" len_min:"3" len_max:"20"`
Email string `json:"email"` Email string `json:"email" form:"email"`
Language string `validate:"default=en-us" json:"language"` Language string `validate:"default=en-us" form:"language" json:"language"`
CurrentPassword string `validate:"required,min=6,max=72" json:"current_password" omit:"true"` CurrentPassword string `validate:"required,min=6,max=72" form:"current_password" json:"current_password" omit:"true"`
Password string `validate:"required,min=6,max=72" json:"password" len_min:"6" len_max:"72" equalInput:"ConfirmPassword"` Password string `validate:"required,min=6,max=72" form:"password" json:"password" len_min:"6" len_max:"72" equalInput:"ConfirmPassword"`
ConfirmPassword string `validate:"required" json:"password_confirmation" omit:"true"` ConfirmPassword string `validate:"required" form:"password_confirmation" json:"password_confirmation" omit:"true"`
Status int `validate:"default=0" json:"status"` Status int `validate:"default=0" form:"status" json:"status"`
Theme string `json:"theme"` Theme string `form:"theme" json:"theme"`
} }
// UserSettingsForm is used when updating a user. // UserSettingsForm is used when updating a user.
type UserSettingsForm struct { type UserSettingsForm struct {
NewTorrent bool `validate:json:"new_torrent"` NewTorrent bool `validate:"-" json:"new_torrent" form:"new_torrent"`
NewTorrentEmail bool `validate:json:"new_torrent_email"` NewTorrentEmail bool `validate:"-" json:"new_torrent_email" form:"new_torrent_email"`
NewComment bool `validate:json:"new_comment"` NewComment bool `validate:"-" json:"new_comment" form:"new_comment"`
NewCommentEmail bool `validate:json:"new_comment_email"` NewCommentEmail bool `validate:"-" json:"new_comment_email" form:"new_comment_email"`
NewResponses bool `validate:json:"new_responses"` NewResponses bool `validate:"-" json:"new_responses" form:"new_responses"`
NewResponsesEmail bool `validate:json:"new_responses_email"` NewResponsesEmail bool `validate:"-" json:"new_responses_email" form:"new_responses_email"`
NewFollower bool `validate:json:"new_follower"` NewFollower bool `validate:"-" json:"new_follower" form:"new_follower"`
NewFollowerEmail bool `validate:json:"new_follower_email"` NewFollowerEmail bool `validate:"-" json:"new_follower_email" form:"new_follower_email"`
Followed bool `validate:json:"followed"` Followed bool `validate:"-" json:"followed" form:"followed"`
FollowedEmail bool `validate:json:"followed_email"` FollowedEmail bool `validate:"-" json:"followed_email" form:"followed_email"`
} }
// PasswordForm is used when updating a user password. // PasswordForm is used when updating a user password.
type PasswordForm struct { type PasswordForm struct {
CurrentPassword string `validate:"required"` CurrentPassword string `validate:"required" form:"current_password"`
Password string `validate:"required"` Password string `validate:"required" form:"password"`
} }
// SendPasswordResetForm is used when sending a password reset token. // SendPasswordResetForm is used when sending a password reset token.
type SendPasswordResetForm struct { type SendPasswordResetForm struct {
Email string `validate:"required"` Email string `validate:"required" form:"email"`
} }
// PasswordResetForm is used when reseting a password. // PasswordResetForm is used when reseting a password.
type PasswordResetForm struct { type PasswordResetForm struct {
PasswordResetToken string `validate:"required"` PasswordResetToken string `validate:"required" form:"token"`
Password string `validate:"required"` Password string `validate:"required" form:"password"`
} }