mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-17 22:32:26 +08:00
mutliple -> multiple
This commit is contained in:
parent
2f293b7df9
commit
2e7b3851a5
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user