Regex Validator - The value for Pattern can not be null

Topics: Validation Application Block
Jul 5, 2009 at 10:32 PM

I have a Regex Validator (see below) in the Config file, that works as expected.  No problems.
How ever if I attempt to edit my config file with Enterprise Library Configuration Tool (4.1), I get a validation error that states "The value for Pattern can not be null"
Is there a known workaround for this issue?

<validator pattern="" options="None" patternResourceName="SafeRegexPattern"
   patternResourceType="MyApp.Common.Properties.Resources, MyApp.Common, Version=, Culture=neutral, PublicKeyToken=null"
   messageTemplate="" messageTemplateResourceName="NicknameRegexPatternErrorMessage"
   messageTemplateResourceType="MyApp.Common.Properties.Resources, MyApp.Common, 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" /

Jul 6, 2009 at 3:35 AM
Edited Jul 6, 2009 at 3:36 AM


According to the Ent lib documentation, the "pattern" property of the RegularExpressionValidator is required. You must add a pattern in your config for the value that you are validating.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.

Jul 7, 2009 at 12:22 AM


I read that the documentation says that the pattern is required. 

The same documentation states that for the PatternResourceName property - If you include both a Pattern value and a PatternResourceName value, the Pattern value takes precedence.

Does this mean that for the Regular Expression Validator it is impossible to set up resources via a config file?



Jul 7, 2009 at 12:50 AM

That is a bug in EntLib, could you try specifiying the Pattern property using the tool and then delete its value by editing it in xml editor?  See if that works.


Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.

Jul 12, 2009 at 9:24 PM

The scenario you describe above does work.  I had already coded the xml without using the Configuration Tool and all works as expected i.e. validation works off the config file.  See the example I gave in my original question above.

 I then started to use the configuration tool.  When I try to exit the configuration tool I receive the error that I originally described.  It quite annoying because it means the configuration tool is of no use to me?

 Good tool otherwise!