Skip to content

Commit

Permalink
fix casing
Browse files Browse the repository at this point in the history
  • Loading branch information
calypsomatic committed Feb 5, 2024
1 parent 7a7c52c commit 75b7196
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ describe('RenameColumnModal', () => {
const input = screen.getByLabelText(/New Name/);
await userEvent.type(input, 'namespace:attribute:colon');
// Assert
expect(renameModal.getByText(/Column name may only include a single colon indicating namespace/));
expect(renameModal.getByText(/Column name may only include a single colon/));
});
});
17 changes: 6 additions & 11 deletions src/workspace-data/data-table/shared/RenameColumnModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,14 @@ export const RenameColumnModal = (props: RenameColumnModalProps): ReactNode => {
const gcpColumnNameErrors =
dataProvider.providerName === 'Entity Service'
? validate.single(newAttributeName, {
exclusion: {
within: ['name', 'entityType', `${entityType}_id`],
message: `Column name cannot be "name", "entityType" or "${entityType}_id".`,
},
format: {
pattern: `^(?!name$|entityType$|${entityType}_id$)[A-Za-z0-9_-]*:?[A-Za-z0-9]+$`,
flags: 'i',
pattern: '[A-Za-z0-9_-]*:?[A-Za-z0-9_-]+$',
message: Utils.cond(
[
newAttributeName.includes(':'),
() => 'Column name may only include a single colon indicating namespace.',
],
[
['name', 'entitytype', `${entityType}_id`].includes(newAttributeName),
() => `Column name cannot be "name", "entityType" or "${entityType}_id".`,
],
[newAttributeName.includes(':'), () => 'Column name may only include a single colon.'],
() => 'Column name may only contain alphanumeric characters, underscores, and dashes.'
),
},
Expand All @@ -69,7 +65,6 @@ export const RenameColumnModal = (props: RenameColumnModalProps): ReactNode => {
? validate.single(newAttributeName, {
format: {
pattern: '^(?!sys_)[A-Za-z0-9_-]+$',
flags: 'i',
message: Utils.cond(
[newAttributeName.startsWith('sys_'), () => 'Column name cannot start with "sys_"'],
() => 'Column name may only contain alphanumeric characters, underscores, and dashes.'
Expand Down

0 comments on commit 75b7196

Please sign in to comment.