Fixed typo
Cette révision appartient à :
Parent
1d8bfa901c
révision
50a0ebfc1f
2 fichiers modifiés avec 6 ajouts et 6 suppressions
|
@ -45,9 +45,9 @@ func IsAgreed(t_and_c string) bool {
|
||||||
|
|
||||||
// RegistrationForm is used when creating a user.
|
// RegistrationForm is used when creating a user.
|
||||||
type RegistrationForm struct {
|
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"`
|
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"`
|
Confirm_Password string `form:"password_confirmation" omit:"true" needed:"true"`
|
||||||
CaptchaID string `form:"captchaID" 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"`
|
T_and_C bool `form:"t_and_c" omit:"true" needed:"true" equal:"true" hum_name:"Terms and Conditions"`
|
||||||
|
|
|
@ -68,19 +68,19 @@ func ValidateForm(form interface{}, errorForm map[string][]string) (map[string][
|
||||||
if tag.Get("len_min") != "" { // Check minimum length
|
if tag.Get("len_min") != "" { // Check minimum length
|
||||||
lenMin, _ := strconv.Atoi(tag.Get("len_min"))
|
lenMin, _ := strconv.Atoi(tag.Get("len_min"))
|
||||||
if formElem.Field(i).Len() < lenMin {
|
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
|
if tag.Get("len_max") != "" { // Check minimum length
|
||||||
lenMax, _ := strconv.Atoi(tag.Get("len_max"))
|
lenMax, _ := strconv.Atoi(tag.Get("len_max"))
|
||||||
if formElem.Field(i).Len() > lenMax {
|
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") != "" {
|
if tag.Get("equalInput") != "" {
|
||||||
otherInput := formElem.FieldByName(tag.Get("equalForm"))
|
otherInput := formElem.FieldByName(tag.Get("equalInput"))
|
||||||
if formElem.Field(i).Interface() != otherInput.Interface() {
|
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() {
|
switch typeField.Type.Name() {
|
||||||
|
|
Référencer dans un nouveau ticket