enhance: new regex for tag name (#290)

* `(?!\.)` should not starts with `.`
* `(?!/)` should not starts with `/`
* `(?!.*\.$)` should not end with `.`
* `(?!.*/$)` should not end with '/`
* `(?!.*\.\.)` should not contains `..`
This commit is contained in:
leo 2024-07-29 14:38:09 +08:00
parent 7a3a4070a3
commit 29ce95e81e
No known key found for this signature in database

View file

@ -12,7 +12,7 @@ namespace SourceGit.ViewModels
} }
[Required(ErrorMessage = "Tag name is required!")] [Required(ErrorMessage = "Tag name is required!")]
[RegularExpression(@"^[^/]{1}[\w\-\./]*$", ErrorMessage = "Bad tag name format!")] [RegularExpression(@"^(?!\.)(?!/)(?!.*\.$)(?!.*/$)(?!.*\.\.)[\w\-\./]+$", ErrorMessage = "Bad tag name format!")]
[CustomValidation(typeof(CreateTag), nameof(ValidateTagName))] [CustomValidation(typeof(CreateTag), nameof(ValidateTagName))]
public string TagName public string TagName
{ {