System.ComponentModel.DataAnnotations 4.0.0.0 System.ComponentModel.DataAnnotations.ValidationAttribute System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Field | System.AttributeTargets.Parameter | System.AttributeTargets.All, AllowMultiple=true)

The attribute is used to perform custom validation when the method is invoked to perform validation. The method then redirects the call to the method that is identified by the property, which in turn performs the actual validation.

The attribute can be applied to types, properties, fields, methods, and method parameters. When it is applied to a property, the attribute is invoked whenever a value is assigned to that property. When it is applied to a method, the attribute is invoked whenever the program calls that method. When it is applied to a method parameter, the attribute is invoked before the method is called.

For more information about using attributes, see Extending Metadata Using Attributes.

Specifies a custom validation method that is used to validate a property or class instance.

- Constructor
  4.0.0.0

  This method specifies a custom class and a related method to call at run time in order to execute custom validation logic.

  Initializes a new instance of the class.

  The type that contains the method that performs custom validation.
  The method that performs custom validation.
- Method
  4.0.0.0
  System.String ``

  The error message is formatted at run time to include the value that is passed to this method.

  Formats a validation error message.

  An instance of the formatted error message.

  The name to include in the formatted message.
- Method
  4.0.0.0
  System.ComponentModel.DataAnnotations.ValidationResult `` `` To be added. To be added. To be added. To be added. To be added.
- Property
  4.0.0.0
  System.String To be added.

  The custom method specified by this property must be public and static, and it must return a Boolean value. It must also take at least one input parameter that specifies the object to validate. This parameter can be strongly typed. If a process passes a value of a different type, type conversion will be attempted.

  The specified method should return true if a given object is valid. Otherwise it should return false.

  The custom method can also take parameters that specify a input value and a output value. The parameter provides additional context information that the method can use to determine the context that it is used in. The output parameter enables the method to return an error message.

  If the method returns null for the parameter or if it returns an empty value for the property, the default method will be called to compose the error message.

  Gets the validation method.

- Property
  4.0.0.0
  System.Object To be added. To be added.

  Gets a unique identifier for this attribute.

- Property
  4.0.0.0
  System.Type To be added.

  This property returns the type that is passed to the ctor constructor overload.

  Gets the type that performs custom validation.