Quantcast
Channel: Fluent Validation for .NET
Viewing all articles
Browse latest Browse all 1917

New Post: Chaining validators with "Or" syntax

$
0
0
Hi,

I have a Expiry Date property the can have either Date or Relative Expiration Date.
  • In case of Date the format should be "dd-MMM-yyyy".
  • In case of Relative Expiration Date the format should be, for example, "3W" for three weeks.
The validation should pass if any of the validators passes.

How would I define it using Fluent Validation?

pseudo code:
RuleFor(dto => dto.ExpiryDate).IsValidDate().Or().IsValidRaltiveDateExpression()
Where IsValidDate() and IsValidRaltiveDateExpression() are extension methods to set the validators and Or() is what I'm after.

Viewing all articles
Browse latest Browse all 1917

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>