xamarin / XamarinCommunityToolkit

The Xamarin Community Toolkit is a collection of Animations, Behaviors, Converters, and Effects for mobile development with Xamarin.Forms. It simplifies and demonstrates common developer tasks building iOS, Android, and UWP apps with Xamarin.Forms.
MIT License
1.58k stars 471 forks source link

[Bug] NumericValidationBehavior throws an exception #1984

Closed mmiller-d8 closed 1 year ago

mmiller-d8 commented 1 year ago

Description

In the Maui Community Tookit, the NumericValidationBehavior throws an exception if the entry field is empty.

Looking at the source, the first line in ValidateAsync throws an ArgumentNullException if the value is null. Unless I’m missing something, there’s no way to catch that and it crashes the app.

It should just return false. Ideally, there would be an IsRequired property that would allow it to return true if the value was null or empty.

Steps to Reproduce

  1. Create a page with an entry field.
  2. Add a NumericValidationBehavior and set the validation behavior to on lose focus
  3. Tap the entry field and then tap something else to take way it's focus
  4. Boom. It crashes the app

Expected Behavior

You can leave a field empty without crashing the app

Actual Behavior

It crashes the app

Basic Information

Workaround

No. I downloaded the source and created a local version with the change.

mmiller-d8 commented 1 year ago

This looks like it was in the wrong area. Moved it to #1988