mirror of
https://github.com/typicode/json-server.git
synced 2025-07-28 20:52:08 +08:00
@ -7,7 +7,7 @@ describe('validateData', () => {
|
||||
})
|
||||
|
||||
test('should throw an error if data is an array', () => {
|
||||
assert.throws(() => validateData([]), /Data must be an object. Found array./)
|
||||
assert.throws(() => validateData([]), /Data must be an object. Found array/)
|
||||
})
|
||||
|
||||
test("shouldn't throw an error", () => {
|
||||
|
@ -17,8 +17,10 @@ module.exports = (obj) => {
|
||||
Object.keys(obj).forEach(validateKey)
|
||||
} else {
|
||||
throw new Error(
|
||||
`Data must be an object. Found ${Array.isArray(obj) ? 'array' : typeof obj}.` +
|
||||
'See https://github.com/typicode/json-server for example.'
|
||||
`Data must be an object. Found ${
|
||||
Array.isArray(obj) ? 'array' : typeof obj
|
||||
}
|
||||
'See https://github.com/typicode/json-server for example.`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user