Yes, that should be possible, although you'll need to use Must rules rather than the standard length rules etc. Something like this should probably work:
public class FieldModelValidator : AbstractValidator<FieldViewModel> {
public FieldModelValidator() {
RuleFor(x => x.FieldValue).Must(BeADate).When(x => x.IsDate);
RuleFor(x => x.FieldValue).Must(NotExceedLength).When(x => x.Maxlength != null);
}
bool NotExceedLength(FieldViewModel model, string value) {
return value != null && value.Length <= model.MaxLength.Value;
}
private bool BeADate(string value) {
DateTime d;
return DateTime.TryParse(value, out d);
}
}
Jeremy