Fix validation logic

This commit is contained in:
Andre Rodrigues
2013-12-08 15:09:05 +01:00
parent 0a484c00f7
commit 7c64c17c38
2 changed files with 24 additions and 5 deletions
+3 -3
View File
@@ -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");
}