Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Automatic Import] Fix UI validation for Integration and Datastream name #204943

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,6 @@ describe('isValidName', () => {
expect(isValidName('anotherValidName')).toBe(true);
});

it('should return false for names with numbers', () => {
expect(isValidName('invalid123')).toBe(false);
expect(isValidName('123invalid')).toBe(false);
expect(isValidName('invalid_123')).toBe(false);
});

it('should return false for empty string', () => {
expect(isValidName('')).toBe(false);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function buildPackage(integration: Integration): Promise<Buffer> {

if (!isValidName(integration.name)) {
throw new Error(
`Invalid integration name: ${integration.name}, Should only contain letters and underscores`
`Invalid integration name: ${integration.name}, Should only contain letters, numbers and underscores`
);
}

Expand All @@ -49,7 +49,7 @@ export async function buildPackage(integration: Integration): Promise<Buffer> {
const dataStreamName = dataStream.name;
if (!isValidName(dataStreamName)) {
throw new Error(
`Invalid datastream name: ${dataStreamName}, Should only contain letters and underscores`
`Invalid datastream name: ${dataStreamName}, Should only contain letters, numbers and underscores`
);
}
const specificDataStreamDir = joinPath(dataStreamsDir, dataStreamName);
Expand Down Expand Up @@ -77,7 +77,7 @@ export async function buildPackage(integration: Integration): Promise<Buffer> {
return zipBuffer;
}
export function isValidName(input: string): boolean {
const regex = /^[a-zA-Z_]+$/;
const regex = /^[a-zA-Z0-9_]+$/;
bhapas marked this conversation as resolved.
Show resolved Hide resolved
return input.length > 0 && regex.test(input);
}
function createDirectories(
Expand Down
Loading