diff --git a/packages/core/content-type-builder/server/services/utils/convert-custom-field-type.js b/packages/core/content-type-builder/server/services/utils/convert-custom-field-type.js index 44cd175739..75c2f2a4e4 100644 --- a/packages/core/content-type-builder/server/services/utils/convert-custom-field-type.js +++ b/packages/core/content-type-builder/server/services/utils/convert-custom-field-type.js @@ -1,4 +1,8 @@ 'use strict'; +const { DEFAULT_TYPES } = require('../constants'); + +const notAllowedTypes = ['component', 'relation', 'dynamiczone', 'media']; +const allowedTypes = DEFAULT_TYPES.filter(type => !notAllowedTypes.includes(type)); /** * @description @@ -8,9 +12,9 @@ const convertCustomFieldType = attributes => { Object.values(attributes).forEach(attribute => { if (attribute.customField) { - if (['component', 'relation', 'dynamiczone'].includes(attribute.type)) { - // When the registered custom fiel is using an invalid strapi type - throw new Error(`Type: ${attribute.type} is not a valid Custom Field type`); + if (!allowedTypes.includes(attribute.type)) { + // When the custom field was registered with an invalid strapi type + throw new Error(`Type: "${attribute.type}" is not a valid Custom Field type`); } // Use the custom field uid sent from the admin to get its equivalent on the server // The getter will throw an error if the custom field is not found