Fix project name validation (#22547)

* Fix project name validation

* Add/update tests

* Address comments

* Fix error
This commit is contained in:
Sakshi Sharma
2023-03-31 08:46:58 -07:00
committed by GitHub
parent 6cc5e9a70d
commit 9d8006562d
11 changed files with 124 additions and 153 deletions

View File

@@ -187,7 +187,7 @@ export class NewProjectDialog extends DialogBase {
this.register(projectNameTextBox.onTextChanged(text => {
const errorMessage = isValidBasenameErrorMessage(text);
if (errorMessage) {
if (errorMessage !== undefined) {
// Set validation error message if project name is invalid
return void projectNameTextBox.updateProperty('validationErrorMessage', errorMessage);
} else {

View File

@@ -9,7 +9,7 @@ import * as constants from '../common/constants';
import { directoryExist, showInfoMessageWithLearnMoreLink } from '../common/utils';
import { defaultProjectSaveLocation } from '../common/projectLocationHelper';
import { WorkspaceService } from '../services/workspaceService';
import { isValidBasename, isValidBasenameErrorMessage } from '../common/pathUtilsHelper';
import { isValidBasenameErrorMessage } from '../common/pathUtilsHelper';
/**
* Create flow for a New Project using only VS Code-native APIs such as QuickPick
@@ -40,7 +40,7 @@ export async function createNewProjectWithQuickpick(workspaceService: WorkspaceS
{
title: constants.EnterProjectName,
validateInput: (value) => {
return isValidBasename(value) ? undefined : isValidBasenameErrorMessage(value);
return isValidBasenameErrorMessage(value);
},
ignoreFocusOut: true
});