I am using MVC 4 with Code First and just starting to use the Fluent API, but I can't find anywhere where it is mentioned how to provide validation error messages? Can this only be done by using Data Annotations?
-
One important thing to keep in mind is that you are talking about validation of the data model, which may be different from validation of the model in your user interface. For instance, you may have a field that is nullable in your database, but you require it in your UI. If you put a Required attribute on the data model, it will also require that the field in the database be non-nullable.Erik Funkenbusch– Erik Funkenbusch2012-10-18 16:28:27 +00:00Commented Oct 18, 2012 at 16:28
Add a comment
|
1 Answer
On possibility is to use Data Annotations. Another possibility is to use a differehnt validation framework such as FluentValidation.NET which allows you to specify the error message in your validator rules.
2 Comments
user517406
Does FluentValidation.NET allow for localization of error messages?
Darin Dimitrov
Of course it does: fluentvalidation.codeplex.com/…