Problem with Regex Validator - VAB

Topics: Validation Application Block
Mar 21, 2010 at 12:37 PM


 I do the validation through configuration files.
But, RegexValidator does not work properly.

This Validator not disciplined even to unknown regular expression!!

Do you know about this problem?
Many thanks!!!

Mar 21, 2010 at 6:06 PM


Can you post the sample config that you've used and what is your expected behavior of the regex validator? And any sample codes that you can provide.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.

Mar 22, 2010 at 5:32 AM

Thank you for your desire to help!

For example:


    <type defaultRuleset="Default" assemblyName="MyAssembly”


      <ruleset name="Default">


          <property name="PhoneNo">

            <validator pattern="\d" options="None" patternResourceName=""

patternResourceType="" messageTemplate="" messageTemplateResourceName="ErrPhone"

              messageTemplateResourceType="ValidationResources.ErrorMessages, ValidationResources, Version=, Culture=neutral, PublicKeyToken=null"

              tag="" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.RegexValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

              name="Regex Validator" />






I do it by Enterprise Library Configuration tool.

I hope that you find me a solution!!

Mar 22, 2010 at 6:57 AM


I tried that but it seems to be working on my end. In the sample you've provided, tha pattern is "\d" which means the value must match at least one (1) number. I also, noticed that you are validating a typed dataset, am i correct? Is it only the regex validator mis behaving? I may send you a sample if you want.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.

Mar 22, 2010 at 8:29 AM

You're right.

I'm really validating a typed dataset

Meanwhile, it’s only the regex validator mis behaving.

If you can, I will be very happy to get a sample!!


You're right about to ‘\d’.

I still have a problem with regular expression.

If I write a pattern “^(\d{1,25})$” , validation fails if I write more than 15 numbers.

Mar 23, 2010 at 4:58 AM


I'm not having trouble with the pattern “^(\d{1,25})$” the validation allows me to have 1 to 25 numbers. where should i send the sample?

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.

Mar 23, 2010 at 5:31 AM

This however does not allow me to put more than 15 digits :-(

You can send me a sample to



Mar 23, 2010 at 12:19 PM

You sloved my problem!


The example you sent me helped me focus on the problem.

The problem was on my custom TextBox (inherits from TextBox)

One property somehow destroyed the validation behavior. 

Thanks for all the help!!