Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Cette révision appartient à :
akuma06 2017-05-07 20:21:46 +02:00
Parent 2c4f3fab43
révision 65e24c25e9
2 fichiers modifiés avec 6 ajouts et 6 suppressions

Voir le fichier

@ -45,9 +45,9 @@ func IsAgreed(t_and_c string) bool {
// RegistrationForm is used when creating a user.
type RegistrationForm struct {
Username string `form:"username" needed:"true" min_len:"3" max_len:"20"`
Username string `form:"username" needed:"true" len_min:"3" len_max:"20"`
Email string `form:"email" needed:"true"`
Password string `form:"password" needed:"true" min_len:"6" max_len:"25"`
Password string `form:"password" needed:"true" len_min:"6" len_max:"25" equalInput:"Confirm_Password"`
Confirm_Password string `form:"password_confirmation" omit:"true" needed:"true"`
CaptchaID string `form:"captchaID" omit:"true" needed:"true"`
T_and_C bool `form:"t_and_c" omit:"true" needed:"true" equal:"true" hum_name:"Terms and Conditions"`

Voir le fichier

@ -68,19 +68,19 @@ func ValidateForm(form interface{}, errorForm map[string][]string) (map[string][
if tag.Get("len_min") != "" { // Check minimum length
lenMin, _ := strconv.Atoi(tag.Get("len_min"))
if formElem.Field(i).Len() < lenMin {
errorForm[tag.Get("form")] = append(errorForm[tag.Get("form")], fmt.Sprintf("Minimal length of %s required for the input: %s", lenMin, inputName))
errorForm[tag.Get("form")] = append(errorForm[tag.Get("form")], fmt.Sprintf("Minimal length of %s required for the input: %s", strconv.Itoa(lenMin), inputName))
}
}
if tag.Get("len_max") != "" { // Check minimum length
lenMax, _ := strconv.Atoi(tag.Get("len_max"))
if formElem.Field(i).Len() > lenMax {
errorForm[tag.Get("form")] = append(errorForm[tag.Get("form")], fmt.Sprintf("Maximal length of %s required for the input: %s", lenMax, inputName))
errorForm[tag.Get("form")] = append(errorForm[tag.Get("form")], fmt.Sprintf("Maximal length of %s required for the input: %s", strconv.Itoa(lenMax), inputName))
}
}
if tag.Get("equalInput") != "" {
otherInput := formElem.FieldByName(tag.Get("equalForm"))
otherInput := formElem.FieldByName(tag.Get("equalInput"))
if formElem.Field(i).Interface() != otherInput.Interface() {
errorForm[tag.Get("form")] = append(errorForm[tag.Get("form")], fmt.Sprintf("Wrong value for the input: %s", inputName))
errorForm[tag.Get("form")] = append(errorForm[tag.Get("form")], fmt.Sprintf("Must be same %s", inputName))
}
}
switch typeField.Type.Name() {