RadzenCompareValidator throwing an error (edit) -- Bug in 4.30.3 and higher

I have just started receiving an error in code that has been working for weeks, after updating from Radzen 4.23.2 to 4.30.2 (still working) to 4.31.0.

The following code checks the Birthdate value against an _oldest and _youngest value, letting the user know if the customer is too young or too old:

<div class="row">
    <div class="col-md-4 align-items-center d-flex">
        <RadzenLabel Text="Date of Birth"/>
    </div>
    <div class="col-md-8">
        <RadzenDatePicker style="width: 100%;" @bind-Value="@Birthdate" Name="birthDate" DateFormat="MM/dd/yyyy"/>
        <RadzenRequiredValidator Popup="true" Style="position: absolute" Component="birthDate" Text="Birthdate is required!"/>
        <RadzenCompareValidator Visible="@(Birthdate < _oldest)" Value="@Birthdate" Component="birthDate" Text="Student must be 110 or younger!" Style="position: absolute"/>
        <RadzenCompareValidator Visible="@(Birthdate > _youngest)" Value="@Birthdate" Component="birthDate" Text="Student must be 12 or older" Style="position: absolute"/>
    </div>
</div>

The first error to throw is this one:

The error occurs when leaving the DropDown.

The code that sets the values above is here:

private StudentVm Student { get; } = new();
private DateTime Birthdate { get; set; } = DateTime.Today;
private DateTime _youngest;
private DateTime _oldest;

protected override void OnInitialized()
{
    Student.LastModifiedDate = DateTime.Today;
    Student.ClassId = ClassId;
    Student.UserId = "";
    Student.BirthDate = DateTime.Now.AddYears(-12);
    _youngest = Student.BirthDate;
    _oldest = DateTime.Now.AddYears(-110);
}

If I comment out the two RadzenCompareValidator lines, leaving just the RadzenDropDown and the RadzenRequiredValidator, the code works.

Anyone have any thoughts on this?

After some testing, I can say that it works properly in 4.23.2 and 4.30.2, it breaks in 4.30.3, and it remains broken in 4.31.0.

Thanks,
William

Hi @Carthax,

We have made a few changes in RadzenCompareValidator to trigger validation when related components change. It isn't clear however what could be null in your case. Can you provide a complete reproduction? You can modify the online demo until it fails.

@korchev ,

I tried creating a working example on the online demo, and I realized the problem was that I had put a DateTime Birthdate in my list of page variables and had left it null. I was using it for my comparison instead of the Student.BirthDate value.

Once I changed to using the correct comparison value, the problem appears to be resolved.

Thank you for the assist!

Regards,
William