StringLengthValidator logic problem - Request StringLengthNullableValidator!

Topics: Validation Application Block
Oct 28, 2009 at 7:13 PM

The StringLengthValidator will fail if the string passed to it is null. There are several problems with this:

  • Nothing in the world works this way - there's a column length validator in SQL server, but a query doesn't fail if you insert a null value!
  • This makes every StringLengthValidator effectively a NotNullValidator, which doesn't make much sense
  • Most people will want to validate that a string is eiher null or between a certain length, which is effectively now not possible without an unwieldly CompositeOrValidator (that, for some reason, I've yet to make word)

My request is either a) Take out the line of code in StringLengthValidator.cs that causes validation to fire if the value is null, or b) since I realize people probably have code that relies on that logic, create a StringLengthNullableValidator that effectively overrides StringLengthValidator to do this.

I really don't want to use a custom compiled version of the EnterpriseBlocks to do this, especially because I know a new release is about to come out.

Does anyone feel me on this?

 

Oct 29, 2009 at 6:10 AM

Hi,

You can log this one in the issue tracker. I think what you can do for now it to implement a custom validator if that's an option for you.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com