

/*
using BlazorServerProject.Pages;
using FluentValidation;
using Microsoft.AspNetCore.Components.Forms;

using FluentValidation;
using Microsoft.AspNetCore.Components.Forms;

namespace BlazorServerProject.Extensions // Ensure this matches your project's structure
{
    public static class EditContextFluentValidationExtensions
    {
        public static EditContext AddFluentValidation(this EditContext editContext, IValidator validator)
        {
            var messages = new ValidationMessageStore(editContext);
            
            editContext.OnValidationRequested += (sender, eventArgs) =>
                ValidateModel((EditContext)sender, messages, validator);
            
            editContext.OnFieldChanged += (sender, eventArgs) =>
                ValidateModel((EditContext)sender, messages, validator);

            return editContext;
        }

        private static void ValidateModel(EditContext editContext, ValidationMessageStore messages, IValidator validator)
        {
            // Create a validation context using the model
            var validationContext = new ValidationContext<object>(editContext.Model);
            var validationResult = validator.Validate(validationContext);
            messages.Clear();
            
            foreach (var error in validationResult.Errors)
            {
                messages.Add(new FieldIdentifier(editContext.Model, error.PropertyName), error.ErrorMessage);
            }

            editContext.NotifyValidationStateChanged();
        }
    }
}
*/


