Skip to content

Commit 03fcde5

Browse files
fix: replace direct hasOwnProperty calls with Object.prototype.hasOwnProperty.call in validateResponseFormat
1 parent de80065 commit 03fcde5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/ra-core/src/dataProvider/validateResponseFormat.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function validateResponseFormat(response, type, logger = console.error) {
1010
logger(`The dataProvider returned an empty response for '${type}'.`);
1111
throw new Error('ra.notification.data_provider_error');
1212
}
13-
if (!response.hasOwnProperty('data')) {
13+
if (!Object.prototype.hasOwnProperty.call(response, 'data')) {
1414
logger(
1515
`The response to '${type}' must be like { data: ... }, but the received response does not have a 'data' key. The dataProvider is probably wrong for '${type}'.`
1616
);
@@ -29,7 +29,7 @@ function validateResponseFormat(response, type, logger = console.error) {
2929
fetchActionsWithArrayOfIdentifiedRecordsResponse.includes(type) &&
3030
Array.isArray(response.data) &&
3131
response.data.length > 0 &&
32-
!response.data[0].hasOwnProperty('id')
32+
!Object.prototype.hasOwnProperty.call(response.data[0], 'id')
3333
) {
3434
logger(
3535
`The response to '${type}' must be like { data : [{ id: 123, ...}, ...] }, but the received data items do not have an 'id' key. The dataProvider is probably wrong for '${type}'`
@@ -38,7 +38,7 @@ function validateResponseFormat(response, type, logger = console.error) {
3838
}
3939
if (
4040
fetchActionsWithRecordResponse.includes(type) &&
41-
!response.data.hasOwnProperty('id')
41+
!Object.prototype.hasOwnProperty.call(response.data, 'id')
4242
) {
4343
logger(
4444
`The response to '${type}' must be like { data: { id: 123, ... } }, but the received data does not have an 'id' key. The dataProvider is probably wrong for '${type}'`
@@ -47,8 +47,8 @@ function validateResponseFormat(response, type, logger = console.error) {
4747
}
4848
if (
4949
fetchActionsWithTotalResponse.includes(type) &&
50-
!response.hasOwnProperty('total') &&
51-
!response.hasOwnProperty('pageInfo')
50+
!Object.prototype.hasOwnProperty.call(response, 'total') &&
51+
!Object.prototype.hasOwnProperty.call(response, 'pageInfo')
5252
) {
5353
logger(
5454
`The response to '${type}' must be like { data: [...], total: 123 } or { data: [...], pageInfo: {...} }, but the received response has neither a 'total' nor a 'pageInfo' key. The dataProvider is probably wrong for '${type}'`

0 commit comments

Comments
 (0)