Skip to content

Commit 0a6d739

Browse files
committed
Checking for no value on secret
1 parent 7bdd1f0 commit 0a6d739

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/UserControls/AddEditSecret.xaml.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,27 @@ public AddEditSecret(string secretName)
2020
public string SecretName => txtName.Text.Trim();
2121
public string SecretValue => txtSecret.Text.Trim();
2222

23-
private void Save_Click(object sender, RoutedEventArgs e)
23+
private async void Save_Click(object sender, RoutedEventArgs e)
2424
{
2525
// Secret names can only contain alphanumeric characters ([a-z], [A-Z], [0-9]) or underscores (_). Spaces are not allowed. Must start with a letter ([a-z], [A-Z]) or underscores (_).
2626
Regex rx = new Regex("^[a-zA-Z_][a-zA-Z0-9_]*$");
2727
if (rx.IsMatch(txtName.Text))
2828
{
29-
DialogResult = true;
30-
Close();
29+
if (string.IsNullOrWhiteSpace(txtSecret.Text.Trim()))
30+
{
31+
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
32+
Community.VisualStudio.Toolkit.MessageBox mb = new();
33+
mb.ShowError("Secret value cannot be empty.", "Invalid Secret Value");
34+
}
35+
else
36+
{
37+
DialogResult = true;
38+
Close();
39+
}
3140
}
3241
else
3342
{
43+
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
3444
Community.VisualStudio.Toolkit.MessageBox mb = new();
3545
mb.ShowError("Secret names can only contain alphanumeric characters ([a-z], [A-Z], [0-9]) or underscores (_). Spaces are not allowed. Must start with a letter ([a-z], [A-Z]) or underscores (_).", "Invalid Secret Name");
3646
}

0 commit comments

Comments
 (0)