From dc26e0aefe6b936e5fea763664d0c999e164481e Mon Sep 17 00:00:00 2001 From: Steve Elliott Date: Mon, 23 Jan 2023 13:35:30 -0500 Subject: [PATCH] Add ability to pass in an array of IValidator, to validate multiple validators. --- .../FluentValidationsValidator.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Blazored.FluentValidation/FluentValidationsValidator.cs b/src/Blazored.FluentValidation/FluentValidationsValidator.cs index ae8e6f9..8e9ddd0 100644 --- a/src/Blazored.FluentValidation/FluentValidationsValidator.cs +++ b/src/Blazored.FluentValidation/FluentValidationsValidator.cs @@ -14,6 +14,7 @@ public class FluentValidationValidator : ComponentBase [CascadingParameter] private EditContext? CurrentEditContext { get; set; } [Parameter] public IValidator? Validator { get; set; } + [Parameter] public IValidator[]? Validators { get; set; } [Parameter] public bool DisableAssemblyScanning { get; set; } [Parameter] public Action>? Options { get; set; } internal Action>? ValidateOptions { get; set; } @@ -79,6 +80,12 @@ protected override void OnInitialized() $"inside an {nameof(EditForm)}."); } + if (Validators?.Any() == true) + { + foreach (var validator in Validators) + CurrentEditContext.AddFluentValidation(ServiceProvider, DisableAssemblyScanning, validator, this); + } + CurrentEditContext.AddFluentValidation(ServiceProvider, DisableAssemblyScanning, Validator, this); } } \ No newline at end of file