I have successfully integrated FluentValidation into my MVC5 project. One of the simpler rules in my validator class is:
Any suggestions on what I'm doing incorrectly here? I noticed that FluentValidation automatically inserted a space "DisplayName", which is great for the validation summary. Any chance that is messing up the individual validator?
Thanks.
RuleFor(x => x.DisplayName)
.NotEmpty()
.WithLocalizedMessage(() => SharedResources.VALIDATOR_REQUIRED);
VALIDATOR_REQUIRED is set to "{PropertyName} Required". In my view, I have a Validation Summary and this:<div class="editor-field">
@Html.EditorFor(m => m.DisplayName)
@Html.ValidationMessageFor(m => m.DisplayName)
</div>
Which becomes<div class="editor-field">
<input name="DisplayName" class="text-box single-line" id="DisplayName" type="text" value="">
<span class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="DisplayName"></span>
</div>
When I submit with a blank DisplayName, the validation summary has the text "Display Name Required" as expected, but the validation message does not show up next to the editor.Any suggestions on what I'm doing incorrectly here? I noticed that FluentValidation automatically inserted a space "DisplayName", which is great for the validation summary. Any chance that is messing up the individual validator?
Thanks.