diff --git a/service/user/form/formValidator.go b/service/user/form/formValidator.go index 2bc05c4c..7a0a5783 100644 --- a/service/user/form/formValidator.go +++ b/service/user/form/formValidator.go @@ -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"` diff --git a/util/modelHelper/modelHelper.go b/util/modelHelper/modelHelper.go index 72a98522..785f7de5 100644 --- a/util/modelHelper/modelHelper.go +++ b/util/modelHelper/modelHelper.go @@ -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() {