diff --git a/README.md b/README.md index 8af0cd22..ab726a4e 100644 --- a/README.md +++ b/README.md @@ -937,7 +937,7 @@ import ( type Workplace struct { Employee string `form:"employee"` Location string `form:"address,default=headquarter"` - Peripherals []string `form:"peripherals,mutliple_default,default=monitor,mouse,keyboard` + Peripherals []string `form:"peripherals,multiple_default,default=monitor,mouse,keyboard` } @@ -953,7 +953,7 @@ func startPage(c *gin.Context) { // If `POST`, first checks the `content-type` for `JSON` or `XML`, then uses `Form` (`form-data`). // See more at https://github.com/gin-gonic/gin/blob/master/binding/binding.go#L48 // If default value defined, and the Request does not contain the key, the default value will be used. Empty value from request overrides that behaviour - // If mutliple_default is in front of default, the 'default' value is returned as a slice, the position of mutliple_default is important + // If multiple_default is in front of default, the 'default' value is returned as a slice, the position of multiple_default is important if c.ShouldBind(&workplace) == nil { log.Println(workplace.Employee) log.Println(workplace.Location) diff --git a/binding/form_mapping.go b/binding/form_mapping.go index 458a09fe..8e0020e6 100644 --- a/binding/form_mapping.go +++ b/binding/form_mapping.go @@ -142,7 +142,7 @@ func tryToSetValue(value reflect.Value, field reflect.StructField, setter setter var opt string for len(opts) > 0 { opt, opts = head(opts, ",") - if k, _ := head(opt, "="); k == "mutliple_default" { + if k, _ := head(opt, "="); k == "multiple_default" { _, values := head(opts, "=") setOpt.isDefaultExists = true setOpt.defaultValue = values diff --git a/binding/form_mapping_test.go b/binding/form_mapping_test.go index 27cd651c..253d52e7 100644 --- a/binding/form_mapping_test.go +++ b/binding/form_mapping_test.go @@ -76,9 +76,9 @@ func TestMappingDefault(t *testing.T) { func TestMappingMultipleDefault(t *testing.T) { var s struct { - Int int `form:",mutliple_default,default=9"` - Slice []int `form:",mutliple_default,default=9"` - Array [1]int `form:",mutliple_default,default=9"` + Int int `form:",multiple_default,default=9"` + Slice []int `form:",multiple_default,default=9"` + Array [1]int `form:",multiple_default,default=9"` } err := mappingByPtr(&s, formSource{}, "form") assert.NoError(t, err)