I have a property of type Datetime?
that I want to validate with FluentValidation.
Here is the property :
public DateTime? StartContractDate { get; set; }
Here is my actual Validator who works very good with a good formated date :
RuleFor(x => x.StartContractDate).Cascade(CascadeMode.StopOnFirstFailure)
.NotNull().WithMessage(localizationService.GetLocaleStringResourceByName("Contract.Create.Create_Identification.Validate.StartContractDate").ResourceValue)
.Must(StartContractDateValidation).WithMessage(localizationService.GetLocaleStringResourceByName("Contract.Create.Create_Identification.Validate.StartContractDateValidation").ResourceValue);
I tried what I saw in that link Validate DateTime with FluentValidator without success, I go in the BeAValidDate
function but in the navigator I still have the error "The value 'XXX' is not valid for 'StartContractDate' instead of my custom message that I put in WithMessage(...)
.
If you have any suggestion ?