From 559753c64aacfeb27f6db184af80b3e63c62a30f Mon Sep 17 00:00:00 2001 From: Erling Hauan Date: Fri, 22 Nov 2024 15:07:36 +0100 Subject: [PATCH] Move DATA_MODEL_NAME_MAX_LENGTH into the hook where it is used --- frontend/packages/shared/src/constants.js | 1 - .../packages/shared/src/hooks/useValidateSchemaName.test.ts | 3 +-- frontend/packages/shared/src/hooks/useValidateSchemaName.ts | 4 +++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/packages/shared/src/constants.js b/frontend/packages/shared/src/constants.js index 67b503f50be..c43fd18c64f 100644 --- a/frontend/packages/shared/src/constants.js +++ b/frontend/packages/shared/src/constants.js @@ -20,5 +20,4 @@ export const PROTECTED_TASK_NAME_CUSTOM_RECEIPT = 'CustomReceipt'; export const PREVIEW_MOCK_PARTY_ID = '51001'; export const PREVIEW_MOCK_INSTANCE_GUID = 'f1e23d45-6789-1bcd-8c34-56789abcdef0'; export const MEDIA_QUERY_MAX_WIDTH = '(max-width: 1024px)'; -export const DATA_MODEL_NAME_MAX_LENGTH = 100; export const DATA_MODEL_NAME_REGEX = /^[a-zA-Z][a-zA-Z0-9_\-æÆøØåÅ]*$/; diff --git a/frontend/packages/shared/src/hooks/useValidateSchemaName.test.ts b/frontend/packages/shared/src/hooks/useValidateSchemaName.test.ts index 968b82a1111..16ceb0f6de6 100644 --- a/frontend/packages/shared/src/hooks/useValidateSchemaName.test.ts +++ b/frontend/packages/shared/src/hooks/useValidateSchemaName.test.ts @@ -1,7 +1,6 @@ -import { useValidateSchemaName } from './useValidateSchemaName'; +import { DATA_MODEL_NAME_MAX_LENGTH, useValidateSchemaName } from './useValidateSchemaName'; import { textMock } from '@studio/testing/mocks/i18nMock'; import { act, renderHook } from '@testing-library/react'; -import { DATA_MODEL_NAME_MAX_LENGTH } from 'app-shared/constants'; // Test data const existingModelName = 'existingModelName'; diff --git a/frontend/packages/shared/src/hooks/useValidateSchemaName.ts b/frontend/packages/shared/src/hooks/useValidateSchemaName.ts index 4232eb9f09b..e95c031270b 100644 --- a/frontend/packages/shared/src/hooks/useValidateSchemaName.ts +++ b/frontend/packages/shared/src/hooks/useValidateSchemaName.ts @@ -1,6 +1,6 @@ import { useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { DATA_MODEL_NAME_MAX_LENGTH, DATA_MODEL_NAME_REGEX } from 'app-shared/constants'; +import { DATA_MODEL_NAME_REGEX } from 'app-shared/constants'; export const useValidateSchemaName = ( existingDataModelNames: string[], @@ -40,6 +40,8 @@ export const useValidateSchemaName = ( return { validateName, nameError, setNameError }; }; +export const DATA_MODEL_NAME_MAX_LENGTH = 100; + const isCSharpReservedKeyword = (word: string): boolean => { const cSharpKeywords = new Set([ 'abstract',