Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Success Field
Collapse the table of content
Expand the table of content

ValidationResult.Success Field

A value that indicates the entity member successfully validated.

Namespace:  System.ComponentModel.DataAnnotations
Assembly:  System.ComponentModel.DataAnnotations (in System.ComponentModel.DataAnnotations.dll)

public static readonly ValidationResult Success

The following example shows how to return a validation result that indicates success or failure.


using System.ComponentModel.DataAnnotations;

public class AWValidation
{
  public static ValidationResult ValidateSalesPerson(string salesPerson)
  {
    bool isValid;

    // Perform validation logic here and set isValid to true or false.

    if (isValid)
    {
      return ValidationResult.Success;
    }
    else
    {
      return new ValidationResult(
          "The selected sales person is not available for this customer.");
    }
  }

  public static ValidationResult ValidateAddress(CustomerAddress addressToValidate)
  {
    bool isValid;

    // Perform validation logic here and set isValid to true or false.

    if (isValid)
    {
      return ValidationResult.Success;
    }
    else
    {
      return new ValidationResult(
          "The address for this customer does not match the required criteria.");
    }
  }
}


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2015 Microsoft