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
Copy file name to clipboardExpand all lines: xml/System.ComponentModel.DataAnnotations/StringLengthAttribute.xml
+14-4Lines changed: 14 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -38,9 +38,11 @@
38
38
<formattype="text/markdown">< placeholders in the error message:
44
+
{0} is the name of the property; {1} is the maximum length; and {2} is the minimum length.
45
+
The placeholders correspond to arguments that are passed to the <xref:System.String.Format%2A?displayProperty=nameWithType> method at runtime.
44
46
45
47
## Examples
46
48
The following example shows how to limit the number of characters in a field. This example works with the ThumbnailPhotoFileName field in the Products table in the AdventureWorksLT database. The field is limited 4 characters by applying the <xref:System.ComponentModel.DataAnnotations.StringLengthAttribute> attribute to the partial class that represents the Product entity.
@@ -59,6 +61,10 @@ public class ProductMetadata
59
61
[StringLength(4, ErrorMessage = "The ThumbnailPhotoFileName value cannot exceed 4 characters. ")]
60
62
public object ThumbnailPhotoFileName;
61
63
64
+
[ScaffoldColumn(true)]
65
+
[StringLength(4, ErrorMessage = "The {0} value cannot exceed {1} characters. ")]
66
+
public object PhotoFileName;
67
+
62
68
}
63
69
```
64
70
@@ -74,6 +80,10 @@ Public Class ProductMetadata
74
80
<StringLength(4, ErrorMessage := "The ThumbnailPhotoFileName value cannot exceed 4 characters. ")> _
75
81
Public ThumbnailPhotoFileName As Object
76
82
83
+
<ScaffoldColumn(True)> _
84
+
<StringLength(4, ErrorMessage := "The {0} value cannot exceed {1} characters. ")> _
0 commit comments