mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-21 01:25:37 -05:00
Fix project name validation (#22547)
* Fix project name validation * Add/update tests * Address comments * Fix error
This commit is contained in:
@@ -785,7 +785,7 @@ export function isValidBasename(name?: string): boolean {
|
||||
* Returns specific error message if file name is invalid
|
||||
* @param name filename to check
|
||||
*/
|
||||
export function isValidBasenameErrorMessage(name?: string): string {
|
||||
export function isValidBasenameErrorMessage(name?: string): string | undefined {
|
||||
return getDataWorkspaceExtensionApi().isValidBasenameErrorMessage(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -677,7 +677,7 @@ export class ProjectsController {
|
||||
prompt: constants.newObjectNamePrompt(itemType.friendlyName),
|
||||
value: `${suggestedName}${counter}`,
|
||||
validateInput: (value) => {
|
||||
return utils.isValidBasename(value) ? undefined : utils.isValidBasenameErrorMessage(value);
|
||||
return utils.isValidBasenameErrorMessage(value);
|
||||
},
|
||||
ignoreFocusOut: true,
|
||||
});
|
||||
@@ -1339,7 +1339,7 @@ export class ProjectsController {
|
||||
prompt: constants.autorestProjectName,
|
||||
value: defaultName,
|
||||
validateInput: (value) => {
|
||||
return utils.isValidBasename(value.trim()) ? undefined : utils.isValidBasenameErrorMessage(value.trim());
|
||||
return utils.isValidBasenameErrorMessage(value);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -303,7 +303,7 @@ export class CreateProjectFromDatabaseDialog {
|
||||
|
||||
this.projectNameTextBox.onTextChanged(text => {
|
||||
const errorMessage = isValidBasenameErrorMessage(text);
|
||||
if (errorMessage) {
|
||||
if (errorMessage !== undefined) {
|
||||
// Set validation error message if project name is invalid
|
||||
void this.projectNameTextBox!.updateProperty('validationErrorMessage', errorMessage);
|
||||
} else {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
import * as constants from '../common/constants';
|
||||
import { exists, getVscodeMssqlApi, isValidBasename, isValidBasenameErrorMessage, sanitizeStringForFilename } from '../common/utils';
|
||||
import { exists, getVscodeMssqlApi, isValidBasenameErrorMessage, sanitizeStringForFilename } from '../common/utils';
|
||||
import { IConnectionInfo } from 'vscode-mssql';
|
||||
import { defaultProjectNameFromDb, defaultProjectSaveLocation } from '../tools/newProjectTool';
|
||||
import { ImportDataModel } from '../models/api/import';
|
||||
@@ -72,7 +72,7 @@ export async function createNewProjectFromDatabaseWithQuickpick(connectionInfo?:
|
||||
title: constants.projectNamePlaceholderText,
|
||||
value: defaultProjectNameFromDb(sanitizeStringForFilename(selectedDatabase)),
|
||||
validateInput: (value) => {
|
||||
return isValidBasename(value) ? undefined : isValidBasenameErrorMessage(value);
|
||||
return isValidBasenameErrorMessage(value);
|
||||
},
|
||||
ignoreFocusOut: true
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user