Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit a3445e6

Browse files
committed
does validate single digit numbers
1 parent 88d1ad6 commit a3445e6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/ServiceStack.Text/DynamicNumber.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ public static bool TryParse(string strValue, out object result)
674674
if (strValue.Length == 1)
675675
{
676676
int singleDigit = strValue[0];
677-
if (singleDigit >= 48 || singleDigit <= 57) // 0 - 9
677+
if (singleDigit >= 48 && singleDigit <= 57) // 0 - 9
678678
{
679679
result = singleDigit - 48; // 0
680680
return true;

tests/ServiceStack.Text.Tests/DynamicNumberTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,5 +203,13 @@ public void Can_get_Nullable_number()
203203
Assert.That(number.ToString(null1), Is.EqualTo("1"));
204204
}
205205

206+
[Test]
207+
public void Can_text_for_numbers()
208+
{
209+
object x = null;
210+
Assert.That(DynamicNumber.TryParse("(", out x), Is.False);
211+
}
212+
213+
206214
}
207215
}

0 commit comments

Comments
 (0)