How do validate a string as DateTime using FluentValidation

Posted by Richard Nienaber on Stack Overflow See other posts from Stack Overflow or by Richard Nienaber
Published on 2010-04-01T13:54:16Z Indexed on 2010/04/01 14:03 UTC
Read the original article Hit count: 618

Filed under:
|
|
|

With FluentValidation, is it possible to validate a string as a parseable DateTime without having to specify a Custom() delegate?

Ideally, I'd like to say something like the EmailAddress function, e.g.:

RuleFor(s => s.EmailAddress).EmailAddress().WithMessage("Invalid email address");

So something like this:

RuleFor(s => s.DepartureDateTime).DateTime().WithMessage("Invalid date/time");

© Stack Overflow or respective owner

Related posts about fluentvalidation

Related posts about string