Right now, it is just displaying a generic
'Initials' should not be empty.
message for the following rule:
context.RulesFor(p => p.Initials).Required(p => p.Message("Initials are frikking required.")).Length(0, 8);
The initials propety is declared in a rather large model of type ApplicantProfileModel : MappedViewModel<ApplicantProfile>
as just plain public string Initials { get; set; }
, without even a display name attribute, yet I have the same problem even when I add a display name.
I have no Required
attributes left in the view models.
The controller action code is:
[HttpGet]
public ActionResult Create()
{
var applicant = _applicantService.BuildApplicantProfile();
var model = new ApplicantProfileModel();
model.MapFromEntity(applicant);
return View(model);
}
This is my standard code for my last umpteen projects, and everything works except the FluentValidation custom messages. Their validations wok fine.
The view is:
<li class="form-line">
@Html.LabelFor(m => m.Initials)
@Html.EditorFor(m => m.Initials)
@Html.ValidationMessageFor(m => m.Initials)
</li>
I tried TextBoxFor
as well, but no difference.