Not Null Validator

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

Class Name: NotNullValidator

Attribute Name: NotNullValidatorAttribute

Configuration tool name: Not Null Validator

Description

This validator checks that the value is non-null.

Properties

The following table lists the Not Null Validator properties.

Not Null Validator Properties

Property

Description

Negated

This is a Boolean property. If it is set to True, it changes the validator's behavior so that it will fail if the condition is met rather than when it is not met. The default is False.

Tag

This property is a user-supplied string. Typically, it is used to sort or categorize validation results that are in a log.

MessageTemplate

This property is a user-supplied string. Typically, it describes the validation result and is intended for a log.

MessageTemplateResourceName

If you do not want to use the MessageTemplate property to specify a message, you can use another template by specifying it with the MessageTemplateResourceName value. If you include both a MessageTemplate value and a MessageTemplateResourceName value, the MessageTemplate value takes precedence.

MessageTemplateResourceTypeName

If you specify a MessageTemplateResourceName value then you must specify a MessageTemplateResourceTypeName value, which is the type of the template you want to use.

Examples

The following examples show how to use the validator with attributes.

Attributes

The following code example checks whether the Manufacturer property contains the null value.

public class Product
{
   [NotNullValidator]
   public Company Manufacturer
   {
      get
      {
         return manufacturer;
      }
   }
// ...
}
'Usage
Public Class Product
    <NotNullValidator()> _
    ReadOnly Property Manufacturer(ByVal _manufacturer As Company)
        Get
            Return _manufacturer
        End Get
    End Property
' ...
End Class
Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.