You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No examples are given on how to create a TypeConverter, and it is unclear how to write the TypeConverter to give an informative message when binding fails. E,g., if I had a custom "Date" type, and the provided value is "Bob", how should that be communicated from the TypeConverter implementation? In the custom modelbinder, you have access to ModelState, but not so in the TypeConverter.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
ID: cfb00531-4ac6-8bf6-9bd8-1eed6446397f
Version Independent ID: ed418d09-6c33-699a-0d48-9aabc99457be
ASP.NET Core doesn't special-case DateTime values at all; binding is done using the default TypeConverter for the type. This is the same for most simple types though we add special cases for decimal, double, enum, and float. The details should already be described in the .NET and .NET Core docs.
If we don't already cover fact TypeConverters are used in model binding, that might be worth documenting somewhere so readers know where to look for supported formats. And, if we take the time to do that, might also mention the following special cases:
support thousands separators in received strings for decimal, double and float values unless FloatingPointTypeModelBinderProvider is removed from MvcOptions.ModelBinderProviders
disallow binding undefined integer values to an enum unless EnumTypeModelBinderProvider is removed from MvcOptions.ModelBinderProviders
No examples are given on how to create a TypeConverter, and it is unclear how to write the TypeConverter to give an informative message when binding fails. E,g., if I had a custom "Date" type, and the provided value is "Bob", how should that be communicated from the TypeConverter implementation? In the custom modelbinder, you have access to ModelState, but not so in the TypeConverter.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: