And Composite Validator
Class Name: AndCompositeValidator
Attribute Name: ValidatorCompositionAttribute
Configuration tool name: And Composite Validator
Description
This validator creates a composite validator. Validation requires that all the validators that make up the composite validator be true. For example, you can use the And composite validator to require that the not null validator AND the date time range validator be True. Because the Validation Application Block's default behavior is to AND validators, you only need this validator to implement complex logic.
Properties
The And composite validator has a single property named Name. This is the name of the validator. The default name is And Composite Validator.
Example
The following code example shows the construction of an AndCompositeValidator instance using attributes. The validator combines a NotNullValidator and a StringLengthValidator. Note that this is the default behavior when more than one validator attribute is used. As a result, the ValidatorComposition attribute could be omitted.
public class Product
{
[ValidatorComposition(CompositionType.And)]
[NotNullValidator]
[StringLengthValidator(10)]
string _productCode;
public string GetProductCode( )
{
return _productCode;
}
// ...
}
'Usage
Public Class Product
<ValidatorComposition(CompositionType.And)> _
<NotNullValidator()> _
<StringLengthValidator(10)> _
Function GetProductCode() As String
Return _productCode
End Function
' ...
End Class