Or Composite 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: OrCompositeValidator
Attribute Name: ValidatorCompositionAttribute
Configuration tool name: Or Composite Validator
Description
This validator creates a composite validator. Validation requires that at least one of the validators that make up the composite validator be True. For example, you can use the Or Composite Validator to require that the Not Null Validator OR the Date Time Range Validator be True.
Properties
The following table lists the Or Composite Validator properties.
Property |
Description |
---|---|
MessageTemplate |
This property is a string containing template tokens that the validator replaces with values as it validates the target. Typically, it describes the validation result. |
MessageTemplateResourceName |
If you do not want to use the MessageTemplate property to hard-code a message template (perhaps for internationalization), you can use a template stored in the application resources. You must also specify a MessageTemplateResourceTypeName value. If you include both a MessageTemplate value and a MessageTemeplateResourceName value, the MessageTemplate value takes precedence. |
MessageTemplateResourceTypeName |
The resource type for the template you want to use. If you specify a MessageTemplateResourceName value, you must specify this value. |
Tag |
This property is a user-supplied string. Typically, it is used to sort or categorize validation results. |
Example
The following example shows how to use the validators with attributes. The validator combines a NotNullValidator and a StringLengthValidator.
public class Product
{
[ValidatorComposition(CompositionType.Or)]
[NotNullValidator]
[StringLengthValidator(10)]
public string ProductCode
{
get
{
return _productCode;
}
}
// ...
}
'Usage
Public Class Product
<ValidatorComposition(CompositionType.Or)> _
<NotNullValidator()> _
<StringLengthValidator(10)> _
ReadOnly Property ProductCode(ByVal _productCode As String)
Get
Return _productCode
End Get
End Property
' ...
End Class