Contains the results of a validation request.
Assembly: System.ComponentModel.DataAnnotations (in System.ComponentModel.DataAnnotations.dll)
Thetype exposes the following members.
|ValidationResult(String)||Initializes a new instance of the class with the specified error message.|
|ValidationResult(String, IEnumerable(Of String))||Initializes a new instance of the class with the specified error message and a collection of member names that are associated with the validation result.|
|Equals(Object)||Determines whether the specified Object is equal to the current Object. (Inherited from Object.)|
|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.)|
|GetHashCode||Serves as a hash function for a particular type. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ToString||Returns a string value that represents the current validation result. (Overrides Object.ToString.)|
The class stores the outcome of a validation check. The IsValid and GetValidationResult methods return an instance of the class, which contains values to indicate whether the value of the entity member matches the validation attributes applied to that member.
If the value of the member successfully validates, the returned object equals the value of the Success field. To determine whether validation succeeded, you should check whether the returned object equals Success. If the value of the member does not validate, the returned object contains an error message and a collection of member names for the validation error, if they can be retrieved.
The following example shows how to return a validation result that indicates success or failure.
Imports System.ComponentModel.DataAnnotations Public Class AWValidation Public Shared Function ValidateSalesPerson(salesPerson As String) As ValidationResult Dim isValid As Boolean ' Perform validation logic here and set isValid to true or false. If (IsValid) Then ValidateSalesPerson = ValidationResult.Success Else ValidateSalesPerson = New ValidationResult( _ "The selected sales person is not available for this customer.") End If End Function Public Shared Function ValidateAddress(addressToValidate As CustomerAddress) As ValidationResult Dim isValid As Boolean ' Perform validation logic here and set isValid to true or false. If (IsValid) Then ValidateAddress = ValidationResult.Success Else ValidateAddress = New ValidationResult( _ "The address for this customer does not match the required criteria.") End If End Function End Class
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.