mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 17:22:45 -05:00
Add validation for new file names for sql projects (#21601)
* Add validation for new file names for sql projects * Addres comments and add validation for new project dialog * Address comments * Address comments on test * Fix tests * Remove extra error messages and rename file * Address comments * Fix tests * Add test file back
This commit is contained in:
@@ -731,3 +731,35 @@ export async function getTargetPlatformFromServerVersion(serverInfo: azdataType.
|
||||
|
||||
return targetPlatform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a given character is a valid filename character
|
||||
* @param c Character to validate
|
||||
*/
|
||||
export function isValidFilenameCharacter(c: string): boolean {
|
||||
return getDataWorkspaceExtensionApi().isValidFilenameCharacter(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces invalid filename characters in a string with underscores
|
||||
* @param s The string to be sanitized for a filename
|
||||
*/
|
||||
export function sanitizeStringForFilename(s: string): string {
|
||||
return getDataWorkspaceExtensionApi().sanitizeStringForFilename(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the string is a valid filename
|
||||
* @param name filename to check
|
||||
*/
|
||||
export function isValidBasename(name?: string): boolean {
|
||||
return getDataWorkspaceExtensionApi().isValidBasename(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns specific error message if file name is invalid
|
||||
* @param name filename to check
|
||||
*/
|
||||
export function isValidBasenameErrorMessage(name?: string): string {
|
||||
return getDataWorkspaceExtensionApi().isValidBasenameErrorMessage(name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user