Skip to content

Commit a983ba3

Browse files
committed
Support null values in NumericValidationBehavior
1 parent 49a1241 commit a983ba3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/CommunityToolkit.Maui.UnitTests/Behaviors/NumericValidationBehaviorTests.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@ public async Task IsNull()
8585
Text = text
8686
};
8787
entry.Behaviors.Add(behavior);
88+
89+
//Act
90+
await behavior.ForceValidate(TestContext.Current.CancellationToken);
8891

89-
await Assert.ThrowsAsync<ArgumentNullException>(async () => await behavior.ForceValidate(TestContext.Current.CancellationToken));
92+
// Assert
93+
Assert.False(behavior.IsValid);
9094
}
9195

9296
[Fact(Timeout = (int)TestDuration.Short)]

src/CommunityToolkit.Maui/Behaviors/Validators/NumericValidationBehavior.shared.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ public int MaximumDecimalPlaces
7676
/// <inheritdoc/>
7777
protected override ValueTask<bool> ValidateAsync(string? value, CancellationToken token)
7878
{
79-
ArgumentNullException.ThrowIfNull(value);
80-
8179
if (!(double.TryParse(value, out var numeric)
8280
&& numeric >= MinimumValue
8381
&& numeric <= MaximumValue))

0 commit comments

Comments
 (0)