RadzenDataAnnotationValidator exception on usage with RadzenNumeric #1387

Closed
opened 2026-01-29 17:52:55 +00:00 by claunia · 0 comments
Owner

Originally created by @LukasMuellerEnso on GitHub (Sep 13, 2024).

-- I don't have professional subscription. Just want to report the bug --

Describe the bug
Using the RadzenDataAnnotationValidator with a RadzenNumeric and binding a Property of type double or int will cause a System.ArgumentException "Expression of type 'System.Double' cannot be used for return type 'System Object'".

To Reproduce

  1. Have a Model-class with a property and data annotations like
    class Model
    {
    [Required(ErrorMessage = "Size is required")]
    [Range(0.0, Double.MaxValue, MinimumIsExclusive = true)]
    public double Size{ get; set; }
    }

  2. Have component and there a binding to a RadzenNumeric and a DataAnnotationValidator
    <RadzenNumeric Name="SizeComp" @bind-Value=@model.Size/>

  3. Let it run an change the value of the RadzenNumeric. A System.ArgumentException will occur.

Expected behavior
No exception

Problem source

  • Exception occurs in "RadzenDataAnnotationValidator.cs" on line 51. Problem is the getter and how the value of the component is requested.
  • For me as work-around it worked, to replace line 51-53 with (made my own Validator):
    var value = component.GetValue();
    But not sure, if that could have any other impacts since i'm new to Radzen and don't know the full structure yet.

Desktop (please complete the following information):

  • OS: Win11
  • Browser Chrome
  • Radzen-Version: 5.1.11
Originally created by @LukasMuellerEnso on GitHub (Sep 13, 2024). -- I don't have professional subscription. Just want to report the bug -- **Describe the bug** Using the RadzenDataAnnotationValidator with a RadzenNumeric and binding a Property of type double or int will cause a System.ArgumentException "Expression of type 'System.Double' cannot be used for return type 'System Object'". **To Reproduce** 1. Have a Model-class with a property and data annotations like class Model { [Required(ErrorMessage = "Size is required")] [Range(0.0, Double.MaxValue, MinimumIsExclusive = true)] public double Size{ get; set; } } 2. Have component and there a binding to a RadzenNumeric and a DataAnnotationValidator <RadzenNumeric Name="SizeComp" @bind-Value=@model.Size/> <RadzenDataAnnotationValidator Component="SizeComp"/> 3. Let it run an change the value of the RadzenNumeric. A System.ArgumentException will occur. **Expected behavior** No exception **Problem source** - Exception occurs in "RadzenDataAnnotationValidator.cs" on line 51. Problem is the getter and how the value of the component is requested. - For me as work-around it worked, to replace line 51-53 with (made my own Validator): var value = component.GetValue(); But not sure, if that could have any other impacts since i'm new to Radzen and don't know the full structure yet. **Desktop (please complete the following information):** - OS: Win11 - Browser Chrome - Radzen-Version: 5.1.11
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1387