ASP.NET MVC Localize Numeric (data-val-number) Validation
Another buggy experience in ASP.NET MVC. This has to do with validation, more specifically numeric validation. Whenever you have a numeric property on your view models, ASP.NET MVC automatically adds some implicit validation to ensure that whatever entered in fact is a numeric value. Might be good in most cases, but here’s the problem. The validation mechanism writes the error messages in english. So for any app that targets a non-english audience, this needs to be changes. But that’s easier said than done. The code in ASP.NET MVC that generates the error message for the implicit numeric validator, looks like this: private static string MakeErrorString(string displayName) { // use CurrentCulture since this message is intended for the site visitor return String.Format(CultureInfo.CurrentCulture, MvcResources.ClientDataTypeModelValidatorProvider_FieldMustBeNumeric, displayName); } To make matter worse, this is a method from an internal, sealed class. They didn’t want you to change this. … Continued