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

Voir le fichier

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