# Radzen.FluentValidation A small Blazor integration that connects FluentValidation with Radzen forms. It provides a Radzen-compatible validator component (RadzenFluentValidator) that attaches to a RadzenTemplateForm, uses FluentValidation validators (sync or async), and displays validation messages in Radzen style (inline or as tooltip popups). ## Features - Integrates FluentValidation with RadzenTemplateForm. - Per-field validation and message display. - Supports synchronous and asynchronous validation. - Optional tooltip popup display with configurable position. - Supports custom IValidator and IValidatorSelector injection. ## Installation - Add the project to your solution or reference the compiled assembly. - Ensure you have Radzen.Blazor and FluentValidation referenced in your Blazor project. Register FluentValidation validators in DI (example in Startup.cs / Program.cs): ```cs // Register your validators services.AddTransient, MyModelValidator>(); ``` ## Usage Example model and validator: ```cs public class MyModel { public string Name { get; set; } } public class MyModelValidator : AbstractValidator { public MyModelValidator() { RuleFor(x => x.Name).NotEmpty().WithMessage("Name is required."); } } ``` Example Blazor (Razor) usage with RadzenTemplateForm: ```razor @using Radzen.Blazor @using Radzen.FluentValidation @* Name field *@ @code { private MyModel model = new MyModel(); void OnSubmit() { // form submit logic } } ``` Notes: - The `Component` parameter should match how you identify/find the Radzen field within the form (the component name used by your IRadzenForm implementation). - Use `AsyncMode=true` to run validators via `ValidateAsync`. - You can set `Validator` explicitly or let the component resolve an `IValidator` from DI. - `Selector` can be provided to control which FluentValidation rules run. ## Behavior - The component attaches to the form's EditContext and uses a ValidationMessageStore to publish FluentValidation errors to Blazor's validation system. - Shows combined messages for a field and updates when validation state changes. ## Contributing Contributions are welcome. Open issues or PRs with improvements or bug fixes. ## License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.