}, func(ut ut.Translator, fe validator.FieldError) string {
t, _ := ut.T("numeric_it", fe.Field())
+ return t
+ })
+ validate.RegisterTranslation("mydate", trans, func(ut ut.Translator) error {
+ return ut.Add("mydate", "Data non valida.", true)
+ }, func(ut ut.Translator, fe validator.FieldError) string {
+ t, _ := ut.T("mydate", fe.Field())
+
return t
})
}
} else if refv.Kind() == reflect.Float32 || refv.Kind() == reflect.Float64 {
vg.Value = fmt.Sprintf("%v", v)
vg.Value = strings.ReplaceAll(vg.Value, ".", ",")
+ /* TODO */
+ } else if strings.Contains(vg.Validation, "mydate") {
+ vg.Value = v.(time.Time).Format("02/01/2006")
} else {
vg.Value = fmt.Sprintf("%v", v)
}
/* tolgo la formattazione */
campi[elem.DBName] = strings.ReplaceAll(elem.Value, ".", "")
campi[elem.DBName] = strings.ReplaceAll(campi[elem.DBName].(string), ",", ".")
+ } else if strings.Contains(elem.Validation, "mydate") && elem.Value != "" {
+ /* metto la data in formato sql */
+ t, err := time.Parse("02/01/2006", elem.Value)
+ if err == nil {
+ campi[elem.DBName] = t.Format("2006-01-02")
+ } else {
+ fmt.Println(err)
+ }
} else {
campi[elem.DBName] = elem.Value
}