Skip to content

Commit 635e674

Browse files
authored
fix(errors): correct error message for invalid JSON pointer start (#118)
Signed-off-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
1 parent 5530ce2 commit 635e674

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const (
1616
ErrPointer pointerError = "JSON pointer error"
1717

1818
// ErrInvalidStart states that a JSON pointer must start with a separator ("/").
19-
ErrInvalidStart pointerError = `JSON pointer must be empty or start with a "` + pointerSeparator
19+
ErrInvalidStart pointerError = `JSON pointer must be empty or start with a "` + pointerSeparator + `"`
2020

2121
// ErrUnsupportedValueType indicates that a value of the wrong type is being set.
2222
ErrUnsupportedValueType pointerError = "only structs, pointers, maps and slices are supported for setting values"

pointer_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ func TestOtherThings(t *testing.T) {
444444
t.Run("single string pointer should be valid", func(t *testing.T) {
445445
_, err := New("abc")
446446
require.Error(t, err)
447+
assert.EqualError(t, err, `JSON pointer must be empty or start with a "/"
448+
JSON pointer error`)
447449
})
448450

449451
t.Run("empty string pointer should be valid", func(t *testing.T) {

0 commit comments

Comments
 (0)