Skip to content

[BUG] NumericValidationBehavior throws ArgumentNullException #2984

@Niels-R

Description

@Niels-R

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

Assume an Entry with the Flags property set to ValidateOnAttaching and Text bound to a nullable string property.
When loading the page view, an ArgumentNullException is thrown.

System.ArgumentNullException: Value cannot be null. (Parameter 'value')
   at System.ArgumentNullException.Throw(String paramName)
   at System.ArgumentNullException.ThrowIfNull(Object argument, String paramName)
   at CommunityToolkit.Maui.Behaviors.NumericValidationBehavior.ValidateAsync(String value, CancellationToken token) in /_/src/CommunityToolkit.Maui/Behaviors/Validators/NumericValidationBehavior.shared.cs:line 79
   at CommunityToolkit.Maui.Behaviors.ValidationBehavior`1[[System.String, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ValidateAsync(Object value, CancellationToken token) in /_/src/CommunityToolkit.Maui/Behaviors/Validators/ValidationBehavior.shared.cs:line 463
   at CommunityToolkit.Maui.Behaviors.ValidationBehavior.UpdateStateAsync(VisualElement view, ValidationFlags flags, Boolean isForced, Nullable`1 parentToken) in /_/src/CommunityToolkit.Maui/Behaviors/Validators/ValidationBehavior.shared.cs:line 382

Expected Behavior

  • No exception
  • IsValid set to False

Steps To Reproduce

  1. Open the project in the linked repository
  2. Run the application in the Android emulator
  3. Observe the exception being thrown on the loading of MainPage

Link to public reproduction project repository

https://github.com/Niels-R/ExceptionExample

Environment

- .NET MAUI CommunityToolkit: 13.0.0
- OS: macOS Tahoe 26.0.1 (25A362)
- .NET MAUI: 10.0.11

Anything else?

This bug has been reported before, but without a working sample to reproduce.

#979

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions