Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display type correctly for array if obj passed as an array #1394

Merged
merged 2 commits into from Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/server/validate-data.js
Expand Up @@ -7,7 +7,7 @@ describe('validateData', () => {
})

test('should throw an error if data is an array', () => {
assert.throws(() => validateData([]), /must be an object/)
assert.throws(() => validateData([]), /Data must be an object. Found array./)
})

test("shouldn't throw an error", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/server/router/validate-data.js
Expand Up @@ -17,7 +17,7 @@ module.exports = (obj) => {
Object.keys(obj).forEach(validateKey)
} else {
throw new Error(
`Data must be an object. Found ${typeof obj}.` +
`Data must be an object. Found ${Array.isArray(obj) ? 'array' : typeof obj}.` +
'See https://github.com/typicode/json-server for example.'
)
}
Expand Down