mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
18 lines
759 B
C#
18 lines
759 B
C#
using System;
|
|
using System.Globalization;
|
|
using System.Windows.Controls;
|
|
|
|
namespace SourceGit.Views.Validations {
|
|
|
|
public class GitURL : ValidationRule {
|
|
public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
|
|
string url = value as string;
|
|
bool valid = !string.IsNullOrEmpty(url)
|
|
&& (url.StartsWith("http://", StringComparison.Ordinal)
|
|
|| url.StartsWith("https://", StringComparison.Ordinal)
|
|
|| url.StartsWith("git@", StringComparison.Ordinal)
|
|
|| url.StartsWith("file://", StringComparison.Ordinal));
|
|
return valid ? ValidationResult.ValidResult : new ValidationResult(false, App.Text("BadRemoteUri"));
|
|
}
|
|
}
|
|
}
|