Validator.TryValidateProperty Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Validates the property.
public:
static bool TryValidateProperty(System::Object ^ value, System::ComponentModel::DataAnnotations::ValidationContext ^ validationContext, System::Collections::Generic::ICollection<System::ComponentModel::DataAnnotations::ValidationResult ^> ^ validationResults);
public static bool TryValidateProperty(object value, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> validationResults);
static member TryValidateProperty : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> -> bool
Public Shared Function TryValidateProperty (value As Object, validationContext As ValidationContext, validationResults As ICollection(Of ValidationResult)) As Boolean
Parameters
- value
- Object
The value to validate.
- validationContext
- ValidationContext
The context that describes the property to validate.
- validationResults
- ICollection<ValidationResult>
A collection to hold each failed validation.
Returns
true if the property validates; otherwise, false.
Exceptions
The MemberName property of validationContext is not a valid property.
Remarks
This method tests each ValidationAttribute instance that is associated with the property that is identified by the validationContext parameter.