mirror of
https://github.com/strapi/strapi.git
synced 2025-08-11 10:18:28 +00:00
18 lines
421 B
JavaScript
18 lines
421 B
JavaScript
![]() |
const checkFieldsAreCorrectlNested = fields => {
|
||
|
if (!Array.isArray(fields)) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
let failed = false;
|
||
|
for (let indexA = 0; indexA < fields.length; indexA++) {
|
||
|
failed = fields
|
||
|
.slice(indexA + 1)
|
||
|
.some(fieldB => fieldB.startsWith(fields[indexA]) || fields[indexA].startsWith(fieldB));
|
||
|
if (failed) break;
|
||
|
}
|
||
|
|
||
|
return !failed;
|
||
|
};
|
||
|
|
||
|
module.exports = checkFieldsAreCorrectlNested;
|