1

I don't quite understand how MVC 2 is validating the datatypes, or how I could inject my own error-string/language.

Given a date-field in a View-Model:

 public DateTime Appointment { get; set; }

I would get the following error if I fill in an invalid date into the form: The value '01.03.20111' is not valid for Appointment.

I certainly know about DataAnnotations (DisplayName, Required etc.), but I don't know how the datatype-validation happens and where/how I could hook in?

Thx for any tipps sl3dg3

sl3dg3
  • 5,026
  • 12
  • 50
  • 74

1 Answers1

0

That message comes from the ModelBinder. You can write your own custom model binders if you would like. Scott Hanselman has examples here and here.

Bala R
  • 107,317
  • 23
  • 199
  • 210
  • Blimey... I really need to write a custom ModelBinder only to influence e.g. the language of this message? :-/ Seems like a flaw to me. – sl3dg3 Mar 01 '11 at 13:51
  • Seems that there is more about this [subject](http://stackoverflow.com/questions/2462690/mvc-localization-of-default-model-binder). – sl3dg3 Mar 01 '11 at 13:57