Ignoring nulls with configuration based validation

Topics: Validation Application Block
Sep 5, 2010 at 5:29 PM

I'm trying to make the StringLengthValidator ignore null values while using the configuration based validation. When using the attribute based approach we can simply do this by decorating an element with the [IgnoreNulls] attribute, as shown in the following example:

public string Name { get; set; }

But how do we achieve this same behavior when using the configuration based approach?

Thanks in advance.

Sep 6, 2010 at 4:50 AM

There's actually no IgnoreNulls validator in the config tool.  It maps to an Or-Composition of the validator you specified and a negated NotNullValidator.  In your case, you would add an Or Composite validator and within it, add astring length validator and a negated not null validator.


Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.