From 73704ed653a4d3b1ec12c9d35dc2f254b8d34f92 Mon Sep 17 00:00:00 2001 From: hybrid2102 Date: Wed, 10 Jan 2024 10:54:12 +0100 Subject: [PATCH] reset validation on car unselect --- .../BlazorApp1/Components/Pages/Home.razor | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/FluentValidationProblem/BlazorApp1/Components/Pages/Home.razor b/FluentValidationProblem/BlazorApp1/Components/Pages/Home.razor index 991e46c..223db3c 100644 --- a/FluentValidationProblem/BlazorApp1/Components/Pages/Home.razor +++ b/FluentValidationProblem/BlazorApp1/Components/Pages/Home.razor @@ -3,7 +3,7 @@ @using MudBlazor @rendermode InteractiveServer - + @@ -41,7 +41,9 @@ -@code{ +@code { + private FluentValidationValidator? _fluentValidationValidator; + List _allCars = new(); Person _person = new(); private EditContext _editContext; @@ -65,9 +67,10 @@ _person.Cars.Remove(car); _editContext.NotifyFieldChanged(new FieldIdentifier(car, "Name")); _editContext.NotifyFieldChanged(new FieldIdentifier(_person, "Cars")); + _fluentValidationValidator?.Validate(); } } - + private void NameChanged(Car car) { _editContext.NotifyFieldChanged(new FieldIdentifier(car, "Name"));