C
Join ServerC#
help
❔ fluentvalidation custom validation inherit existing validation `MinimumLengthValidator`
PPetrus1/29/2023
Hello i trying to create custom validation by inherit fluentvalidator build in validator
the validator just overwrite default error message and doesnt do anything complicated
when i try register validator i get error
MinimumLengthValidator
(https://github.com/FluentValidation/FluentValidation/blob/main/src/FluentValidation/Validators/LengthValidator.cs#L111) but cant find any fitting to SetValidator
the validator just overwrite default error message and doesnt do anything complicated
public class Test<T> : MinimumLengthValidator<T>
{
public override string Name => "Test";
private readonly string _propertyPath;
public Test(int min, string propertyPath) : base(max)
{
_propertyPath = propertyPath;
}
public Test(Func<T, int> max, string propertyPath) : base(min)
{
_propertyPath = propertyPath;
}
protected override string GetDefaultMessageTemplate(string errorCode) => "random";
when i try register validator i get error
ruleBuilder.SetValidator(new Test<T>(min, propertyPath))
it complains that it cannot resolve method for it and candidates are (see pic) how am i supposed to do this?
AAccord1/30/2023
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.