mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-31 09:04:59 +00:00
16 lines
No EOL
637 B
C#
16 lines
No EOL
637 B
C#
using System.Globalization;
|
|
using System.Text.RegularExpressions;
|
|
using System.Windows.Controls;
|
|
|
|
namespace SourceGit.Views.Validations {
|
|
public class RelativePath : ValidationRule {
|
|
public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
|
|
var path = value as string;
|
|
if (string.IsNullOrEmpty(path)) return ValidationResult.ValidResult;
|
|
|
|
var regex = new Regex(@"^[\w\-\._/]+$");
|
|
var succ = regex.IsMatch(path.Trim());
|
|
return !succ ? new ValidationResult(false, App.Text("BadRelativePath")) : ValidationResult.ValidResult;
|
|
}
|
|
}
|
|
} |