blazor-validation icon indicating copy to clipboard operation
blazor-validation copied to clipboard

Validator for base interface

Open ABIOLI-COM opened this issue 1 year ago • 1 comments

Hi Peter. I'm trying to use this library, but I have a validator for a base interface and two different implementation classes, so that my situation is something like:

public class MyValidator : AbstractValidator<IBaseInterface> {...}

And then I have two 'validatable' classes like in:

public class A : IBaseInterface {...}
public class B : IBaseInterface {...}

I think that the automatic discovery you implemented in this library records only the direct types, so when I have a Blazor form based on an instance of class A, for example, I see that validation doesn't automatically kick in.
I would like to have the possibility to register manually custom behaviors like this case, something like:

builder.Services.RegisterValidator<A, MyValidator>();
builder.Services.RegisterValidator<B, MyValidator>();

...unless I have some other error that I don't see, of course... :-)

Thank you (again :-) ) Andrea

ABIOLI-COM avatar Oct 18 '22 16:10 ABIOLI-COM

@ABIOLI-COM

<Morris.Blazor.Validation.Validate ValidationProperties=@(ValidationProperties.Set.FluentValidator<YourInterfaceValidator>()) />

@mrpmorris It would be much nicer if it were.

<Morris.Blazor.Validation.Validate FluentValidator=typeof(YourInterfaceValidator) />

StevenTCramer avatar Apr 16 '24 17:04 StevenTCramer