From 69a5d8201c3d0a80b36f74e87d55379f12f6361a Mon Sep 17 00:00:00 2001 From: Riccardo Ferretti Date: Wed, 24 Feb 2021 17:03:22 +0100 Subject: [PATCH] improved validation on template creation --- packages/foam-vscode/src/features/create-from-template.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/foam-vscode/src/features/create-from-template.ts b/packages/foam-vscode/src/features/create-from-template.ts index 65c3e977a..facaceef4 100644 --- a/packages/foam-vscode/src/features/create-from-template.ts +++ b/packages/foam-vscode/src/features/create-from-template.ts @@ -115,7 +115,11 @@ async function createNewTemplate(): Promise { defaultTemplate.fsPath.length - 3, ], validateInput: value => - value.length ? undefined : 'Please enter a value!', + value.trim().length === 0 + ? 'Please enter a value' + : existsSync(value) + ? 'File already exists' + : undefined, }); if (filename === undefined) { return;