Skip to content

Commit

Permalink
Merge pull request #38 from sakura1116vg/fix-indent-README.md
Browse files Browse the repository at this point in the history
fix indent README.md
  • Loading branch information
deankarn committed Apr 30, 2019
2 parents c78c4d6 + a04bd52 commit 1174b88
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Use go get.
Then import the form package into your own code.

import "github.com/go-playground/form"

Usage
-----

Expand Down Expand Up @@ -215,8 +215,8 @@ Registering Custom Types
Decoder
```go
decoder.RegisterCustomTypeFunc(func(vals []string) (interface{}, error) {
return time.Parse("2006-01-02", vals[0])
}, time.Time{})
return time.Parse("2006-01-02", vals[0])
}, time.Time{})
```
ADDITIONAL: if a struct type is registered, the function will only be called if a url.Value exists for
the struct and not just the struct fields eg. url.Values{"User":"Name%3Djoeybloggs"} will call the
Expand All @@ -226,16 +226,16 @@ custom type function with 'User' as the type, however url.Values{"User.Name":"jo
Encoder
```go
encoder.RegisterCustomTypeFunc(func(x interface{}) ([]string, error) {
return []string{x.(time.Time).Format("2006-01-02")}, nil
}, time.Time{})
return []string{x.(time.Time).Format("2006-01-02")}, nil
}, time.Time{})
```

Ignoring Fields
--------------
you can tell form to ignore fields using `-` in the tag
```go
type MyStruct struct {
Field string `form:"-"`
Field string `form:"-"`
}
```

Expand All @@ -244,14 +244,14 @@ Omitempty
you can tell form to omit empty fields using `,omitempty` or `FieldName,omitempty` in the tag
```go
type MyStruct struct {
Field string `form:",omitempty"`
Field string `form:",omitempty"`
Field2 string `form:"CustomFieldName,omitempty"`
}
```

Notes
------
To maximize compatibility with other systems the Encoder attempts
To maximize compatibility with other systems the Encoder attempts
to avoid using array indexes in url.Values if at all possible.

eg.
Expand Down

0 comments on commit 1174b88

Please sign in to comment.