Skip to content

Commit e56bbb1

Browse files
author
Dean Karn
authored
fix idx error message (#54)
1 parent 6f87027 commit e56bbb1

File tree

7 files changed

+85
-9
lines changed

7 files changed

+85
-9
lines changed

.github/CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Contribution Guidelines
2+
3+
## Quality Standard
4+
5+
To ensure the continued stability of this package, tests are required that cover the change in order for a pull request to be merged.
6+
7+
## Reporting issues
8+
9+
Please open an issue or join the gitter chat [![Join the chat at https://gitter.im/go-playground/validator](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-playground/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) for any issues, questions or possible enhancements to the package.

.github/ISSUE_TEMPLATE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### Package version eg. v9, v10:
2+
3+
4+
5+
### Issue, Question or Enhancement:
6+
7+
8+
9+
### Code sample, to showcase or reproduce:
10+
11+
```go
12+
13+
```

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Fixes Or Enhances
2+
3+
4+
**Make sure that you've checked the boxes below before you submit PR:**
5+
- [ ] Tests exist or have been written that cover this particular change.
6+
7+
@go-playground/admins

.github/workflows/workflow.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
pull_request:
6+
name: Test
7+
jobs:
8+
test:
9+
strategy:
10+
matrix:
11+
go-version: [1.15.x, 1.16.x]
12+
os: [ubuntu-latest, macos-latest, windows-latest]
13+
runs-on: ${{ matrix.os }}
14+
steps:
15+
- name: Install Go
16+
uses: actions/setup-go@v2
17+
with:
18+
go-version: ${{ matrix.go-version }}
19+
20+
- name: Checkout code
21+
uses: actions/checkout@v2
22+
23+
- name: Restore Cache
24+
uses: actions/cache@v2
25+
with:
26+
path: ~/go/pkg/mod
27+
key: ${{ runner.os }}-v1-go-${{ hashFiles('**/go.sum') }}
28+
restore-keys: |
29+
${{ runner.os }}-v1-go-
30+
31+
- name: Test
32+
run: go test -race -covermode=atomic -coverprofile="profile.cov" ./...
33+
34+
- name: Send Coverage
35+
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.16.x'
36+
uses: shogo82148/actions-goveralls@v1
37+
with:
38+
path-to-profile: profile.cov
39+
40+
golangci:
41+
name: lint
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v2
45+
- name: golangci-lint
46+
uses: golangci/golangci-lint-action@v2
47+
with:
48+
version: v1.37.1

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package form
22
============
3-
<img align="right" src="https://raw.githubusercontent.com/go-playground/form/master/logo.jpg">![Project status](https://img.shields.io/badge/version-4.1.2-green.svg)
4-
[![Build Status](https://travis-ci.org/go-playground/form.svg?branch=master)](https://travis-ci.org/go-playground/form)
3+
<img align="right" src="https://raw.githubusercontent.com/go-playground/form/master/logo.jpg">![Project status](https://img.shields.io/badge/version-4.1.3-green.svg)
4+
[![Build Status](https://github.com/go-playground/form/actions/workflows/workflow.yml/badge.svg)](https://github.com/go-playground/form/actions/workflows/workflow.yml)
55
[![Coverage Status](https://coveralls.io/repos/github/go-playground/form/badge.svg?branch=master)](https://coveralls.io/github/go-playground/form?branch=master)
66
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/form)](https://goreportcard.com/report/github.com/go-playground/form)
77
[![GoDoc](https://godoc.org/github.com/go-playground/form?status.svg)](https://godoc.org/github.com/go-playground/form)

decoder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ func (d *decoder) setFieldByType(current reflect.Value, namespace []byte, idx in
317317
}
318318
var f float64
319319
if f, err = strconv.ParseFloat(arr[idx], 32); err != nil {
320-
d.setError(namespace, fmt.Errorf("Invalid Float Value '%s' Type '%v' Namespace '%s'", arr[0], v.Type(), string(namespace)))
320+
d.setError(namespace, fmt.Errorf("Invalid Float Value '%s' Type '%v' Namespace '%s'", arr[idx], v.Type(), string(namespace)))
321321
return
322322
}
323323
v.SetFloat(f)
@@ -329,7 +329,7 @@ func (d *decoder) setFieldByType(current reflect.Value, namespace []byte, idx in
329329
}
330330
var f float64
331331
if f, err = strconv.ParseFloat(arr[idx], 64); err != nil {
332-
d.setError(namespace, fmt.Errorf("Invalid Float Value '%s' Type '%v' Namespace '%s'", arr[0], v.Type(), string(namespace)))
332+
d.setError(namespace, fmt.Errorf("Invalid Float Value '%s' Type '%v' Namespace '%s'", arr[idx], v.Type(), string(namespace)))
333333
return
334334
}
335335
v.SetFloat(f)

decoder_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,6 @@ func TestDecoderStruct(t *testing.T) {
552552
}
553553
Time time.Time
554554
TimePtr *time.Time
555-
unexposed string
556555
Invalid interface{}
557556
ExistingMap map[string]string `form:"mp"`
558557
MapNoValue map[int]int
@@ -1157,7 +1156,7 @@ func TestDecoderPanicsAndBadValues(t *testing.T) {
11571156

11581157
decoder := NewDecoder()
11591158

1160-
PanicMatches(t, func() { decoder.Decode(&test, values) }, "Invalid formatting for key 'Phone[0.Number' missing ']' bracket")
1159+
PanicMatches(t, func() { _ = decoder.Decode(&test, values) }, "Invalid formatting for key 'Phone[0.Number' missing ']' bracket")
11611160

11621161
i := 1
11631162
err := decoder.Decode(i, values)
@@ -1187,19 +1186,19 @@ func TestDecoderPanicsAndBadValues(t *testing.T) {
11871186
"Phone0].Number": []string{"1(111)111-1111"},
11881187
}
11891188

1190-
PanicMatches(t, func() { decoder.Decode(&test, values) }, "Invalid formatting for key 'Phone0].Number' missing '[' bracket")
1189+
PanicMatches(t, func() { _ = decoder.Decode(&test, values) }, "Invalid formatting for key 'Phone0].Number' missing '[' bracket")
11911190

11921191
values = url.Values{
11931192
"Phone[[0.Number": []string{"1(111)111-1111"},
11941193
}
11951194

1196-
PanicMatches(t, func() { decoder.Decode(&test, values) }, "Invalid formatting for key 'Phone[[0.Number' missing ']' bracket")
1195+
PanicMatches(t, func() { _ = decoder.Decode(&test, values) }, "Invalid formatting for key 'Phone[[0.Number' missing ']' bracket")
11971196

11981197
values = url.Values{
11991198
"Phone0]].Number": []string{"1(111)111-1111"},
12001199
}
12011200

1202-
PanicMatches(t, func() { decoder.Decode(&test, values) }, "Invalid formatting for key 'Phone0]].Number' missing '[' bracket")
1201+
PanicMatches(t, func() { _ = decoder.Decode(&test, values) }, "Invalid formatting for key 'Phone0]].Number' missing '[' bracket")
12031202
}
12041203

12051204
func TestDecoderMapKeys(t *testing.T) {

0 commit comments

Comments
 (0)