I am using FluentValidation to validate my models, and it works awesome.
One question I have though is how do you handle messages that are not attached to a property?
Example: A customer login view. When the login is invalid I want to display a simple message.
What I did was add a property to the model, Message, and then created a validation message for that property on the view.
It works, but was looking to see what others are doing.
Update
So for simplicity, consider the following:
View Model
'Uses a FluentValidation Validator
Public Class LogonViewModel
Public Property UserName AS String<br>
Public Property Password AS String
End Class
View
<div id="GenericMessage">--Generic Messages Go Here--</div>
@<table border="0" cellpadding="2" cellspacing="0">
<tr>
<td>User Name:</td>
<td>@Html.EditorFor(Function(x) x.UserName) @Html.ValidationMessageFor(Function(x) x.UserName)</td>
</tr>
<tr>
<td>Password:</td>
<td>@Html.EditorFor(Function(x) x.Password) @Html.ValidationMessageFor(Function(x) x.Password)</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Logon" /></td>
</tr>
</table>
What I want to do is have a generic message div that I can display messages in, like "Invalid Login". My question is where to I put that in the model? Do I create a property and then set it in the controller ModelState? Or should I be using ViewData?