RequiredAttribute Class
Specifies that a value must be provided for a property.
System.Object
System.Attribute
System.ComponentModel.DataAnnotations.ValidationAttribute
System.ComponentModel.DataAnnotations.RequiredAttribute
System.Attribute
System.ComponentModel.DataAnnotations.ValidationAttribute
System.ComponentModel.DataAnnotations.RequiredAttribute
Namespace: System.ComponentModel.DataAnnotations
Assembly: System.ComponentModel.DataAnnotations (in System.ComponentModel.DataAnnotations.dll)
The RequiredAttribute type exposes the following members.
| Name | Description | |
|---|---|---|
|
AllowEmptyStrings | Gets or sets a value that indicates whether an empty string is allowed. |
|
ErrorMessage | Gets or sets the non-localizable error message to display when validation fails. (Inherited from ValidationAttribute.) |
|
ErrorMessageResourceName | Gets or sets the property name on the resource type that provides the localizable error message. (Inherited from ValidationAttribute.) |
|
ErrorMessageResourceType | Gets or sets the resource type that provides the localizable error message. (Inherited from ValidationAttribute.) |
|
ErrorMessageString | Gets the localized or non-localized error message. (Inherited from ValidationAttribute.) |
| Name | Description | |
|---|---|---|
|
Equals | Infrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.) |
|
Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
|
FormatErrorMessage | Applies formatting to the error message. (Inherited from ValidationAttribute.) |
|
GetHashCode | Returns the hash code for this instance. (Inherited from Attribute.) |
|
GetType | Gets the Type of the current instance. (Inherited from Object.) |
|
GetValidationResult | Determines whether the specified object is valid and returns an object that includes the results of the validation check. (Inherited from ValidationAttribute.) |
|
IsValid | Determines whether the specified object is valid. (Inherited from ValidationAttribute.) |
|
Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.) |
|
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
|
ToString | Returns a string that represents the current object. (Inherited from Object.) |
|
Validate | Determines whether the specified object is valid and throws a ValidationException if the object is not valid. (Inherited from ValidationAttribute.) |
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Special processing by Validator
The RequiredAttribute gets special processing by Validator. If there is a RequriedAttribute attribute applied to a property it will be checked first during validation. If the RequiredAttribute returns an error then no other validators are called.
- 11/8/2011
- Colin Blair