diff --git a/Octokit/Models/Request/LabelUpdate.cs b/Octokit/Models/Request/LabelUpdate.cs index fa8b76ea..9486aedb 100644 --- a/Octokit/Models/Request/LabelUpdate.cs +++ b/Octokit/Models/Request/LabelUpdate.cs @@ -1,7 +1,12 @@ -namespace Octokit +using System; +using System.Text.RegularExpressions; + +namespace Octokit { public class LabelUpdate { + private string _color; + public LabelUpdate(string name, string color) { Name = name; @@ -16,6 +21,20 @@ /// /// Color of the label (required). /// - public string Color { get; set; } + public string Color + { + get { return _color; } + set + { + if (string.IsNullOrEmpty(value) + || value.Length != 6 + || !Regex.IsMatch(value, @"\A\b[0-9a-fA-F]+\b\Z")) + { + throw new ArgumentOutOfRangeException("value", "Color should be an hexadecimal string of length 6"); + } + + _color = value; + } + } } } diff --git a/Octokit/Models/Request/NewLabel.cs b/Octokit/Models/Request/NewLabel.cs index 8b123f12..5f37f8b7 100644 --- a/Octokit/Models/Request/NewLabel.cs +++ b/Octokit/Models/Request/NewLabel.cs @@ -29,9 +29,9 @@ namespace Octokit get { return _color; } set { - if (!string.IsNullOrEmpty(value) - && value.Length == 6 - && Regex.IsMatch(value, @"\A\b[0-9a-fA-F]+\b\Z")) + if (string.IsNullOrEmpty(value) + || value.Length != 6 + || !Regex.IsMatch(value, @"\A\b[0-9a-fA-F]+\b\Z")) { throw new ArgumentOutOfRangeException("value", "Color should be an hexadecimal string of length 6"); }