How to Create Custom Validators with EL4.1?

Topics: Building and extending application blocks, Validation Application Block
Jul 29, 2009 at 7:59 PM

Hi,

I want to create a set of custom validators for my project.  The will be used explicitly for attribute based validation.   I need to be able to provide MessageTemplate from my application's RESX file.  I am using EL4.1

Something like this:

 

[StringLengthValidator(0, RangeBoundaryType.Inclusive,
          500, RangeBoundaryType.Inclusive,
          MessageTemplateResourceName = INF.Shared.Constants.MessageTemplateResourceName.InvalidStringLength,
          MessageTemplateResourceType = typeof(INF.Shared.Resources.SystemMessageTemplate),
          Ruleset = INF.Shared.Constants.RuleSetName.InsertUpdate)]

[MyCustomStringLengthValidator(0, RangeBoundaryType.Inclusive,

          500, RangeBoundaryType.Inclusive,

          MessageTemplateResourceName = Constants.MessageTemplateResourceName.InvalidStringLength,

          MessageTemplateResourceType = typeof(Resources.SystemMessageTemplate),

          Ruleset = Constants.RuleSetName.InsertUpdate)]

 

 

 

How can I accomplish this easily.   Is there a quick sample anyone has?

I need this help quickly. 

 

Thanks in advance for any guidance you can provide.

Jul 30, 2009 at 8:04 AM

Hi,

There are some samples you can find in the Validation quick starts, you can find it in the installation folder of the Ent lib source, usually <Drive Letter>:\EntLib41Src\Quick Starts. Basically the sample has a class for the attribute validation and for the validation using the config. I just tried it and is working fine. Just follow the pattern on how that classes were created.

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

 

Jul 30, 2009 at 1:29 PM

Found them!  perfect.  we are using attribute and not config based validation...

 

Just got our first CustomeSample validator done.

 

Thanks!