Composite string placeholders in validation attributes #2047
Labels
area-System.ComponentModel.DataAnnotations
help wanted
Good for community contributors to help [up-for-grabs]
Pri3
Indicates issues/PRs that are low priority
Milestone
Many validation attributes compose their error messages using
String.Format
with one or more arguments. You can use placeholders like {0}, {1}, {2}, etc. in the error message string passed to the attribute. For example:If the property name is "Name" and the maximum length is 25, the error message would be "The Name value cannot exceed 25 characters."
The composite string capability has not been documented for most of the validation attributes. The first one (
StringLength
) has been done, and that PR #2011 can be used as a template to follow when doing the others.To find out which parameters are passed to
String.Format
for a particular attribute's error message, see the DataAnnotations source code.The text was updated successfully, but these errors were encountered: