mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 08:19:07 +00:00
feat: prevent user from using doc id attribute
This commit is contained in:
parent
91d6b8ca44
commit
1dae937ea5
@ -33,6 +33,17 @@ export const transformContentTypesToModels = (
|
||||
? { documentId: { type: 'string', default: createId } }
|
||||
: {};
|
||||
|
||||
// Prevent user from creating a documentId attribute
|
||||
const reservedAttributeNames = ['documentId', 'document_id'];
|
||||
reservedAttributeNames.forEach((reservedAttributeName) => {
|
||||
if (reservedAttributeName in contentType.attributes) {
|
||||
throw new Error(
|
||||
`The attribute "${reservedAttributeName}" is reserved and cannot be used in a model` +
|
||||
`Please rename "${contentType.modelName}" attribute "${reservedAttributeName}" to something else.`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const model = {
|
||||
...contentType,
|
||||
// reuse new model def
|
||||
|
Loading…
x
Reference in New Issue
Block a user