Skip to content

Commit

Permalink
Move DATA_MODEL_NAME_MAX_LENGTH into the hook where it is used
Browse files Browse the repository at this point in the history
  • Loading branch information
ErlingHauan committed Nov 22, 2024
1 parent a1014bc commit 559753c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion frontend/packages/shared/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_\-æÆøØåÅ]*$/;
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
4 changes: 3 additions & 1 deletion frontend/packages/shared/src/hooks/useValidateSchemaName.ts
Original file line number Diff line number Diff line change
@@ -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[],
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 559753c

Please sign in to comment.