Replies: 1 comment 1 reply
-
@mishael-o public bool IsDateFromValid() => new DateValidator().Validate(DateFrom).IsValid; Then call the function in the other abstract validator using Must or MustAsync public class FooValidator : AbstractValidator<Foo>
{
DateTime dateFrom , dateTo;
publicFooValidator()
{
RuleFor(x => x.DateFrom)
.Must(date => new DateValidator.Validate(dateFrom = date).IsValid)
.WithMessage("SomeMsg");
RuleFor(x => x.DateTo)
.Must(date => new DateValidator().Validate(dateFrom).IsValid &&
new DateValidator().Validate(dateTo = date).IsValid)
.WithMessage("SomeMsg");
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I have a scenario where I would want to revalidate a property when another property has changed.
Example
DateFrom
andDateTo
properties. WhenDateFrom
changes I want to call validations forDateTo
and vice versa to ensure their states is in sync.I see the
FluentValidationValidator
exposesValidate
andValidateAsync
however there is no API validating a property.Beta Was this translation helpful? Give feedback.
All reactions