Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input validation #1

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions RoR2VersionSelector/RoR2VersionSelector.cs
Original file line number Diff line number Diff line change
@@ -91,10 +91,32 @@ private void RoR2VersionSelector_Load(object sender, EventArgs e)
UpdateInitialState();
}

private Boolean ValidateInput()
{
if (TextBoxUsername.Text.Length == 0)
{
MessageBox.Show("Please specify username.", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Information);
return false;
}

if (!Enum.IsDefined(typeof(RoR2Versions), ComboBoxVersionSelector.Text))
{
MessageBox.Show("Please specify valid version.", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Information);
return false;
}

return true;
}

private async void ButtonDownloadDepot_Click(object sender, EventArgs e)
{
if (!ValidateInput())
{
return;
}
ButtonDownloadDepot.Enabled = false;


var startInfo = new ProcessStartInfo
{
FileName = "cmd.exe",