Validate Field Text without using ValidationProvider

Topics: General discussion, Validation Application Block
Mar 10, 2010 at 7:17 PM

Hello,

I was curious if there was a way to go about "field level" validation without having to use the ValidationProvider. My situation is this, I want the capability to be able to validate a single textbox value on a form; out of a group textboxes, without having the creator; client,  of that form to have to utilize the ValidationProvider. Instead, I want them to be able to utilize a service I have already created that handles validation for them. Currently, my works as so, an object that they pass to me that has their data wrapped up into it gets validated when they call my 'DoValidationWork' method. Right I would like to be able to simply add another method to my service called 'ValidateField', that excepts as parameters a rule set (string), object to validate, and the type name (string); the type name is the property within the configuration file that has a range validator or not null validator attached to it.  I thought these might make the most sense for what I am trying to accomplish; I could be wrong. Is there a good way to go about accomplishing this before I get to far off track? Any help is appreciated, thanks.

Mar 11, 2010 at 6:05 AM

Hi,

First thing i have in mind is why would not prefer to use the ValidationProvider of ent lib? As I understand your inquiry, you will use your service to validate the value of the text box, yes it is possible as you described that in your service you will validate the value against the config file that is configured for that. I'm just thinkin' how would you render the validation messages from your service to the UI, wouldn't that cause extra work? Correct me if my understanding is wrong.

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

Mar 11, 2010 at 12:20 PM

Hi  Valiant,

I do agree that it will be extra work on my end, however, this round about way of accomplishing this issomething I was requested to do by my leads so I am kind of stuck with it at the moment. As far as rendering the validation messages from my service to the UI, each textbox will have only one validator used on it; e.g. Range Validator, so at most there will be only one message returned if the value is invalid. With that being the case, all I would have to do is return the message; string, to the UI not the entire validation message.

As I said, I know this may seem as a VERY round about way of accomplishing things, but I was told to investigate other options rather than using the ValidationProvider at the moment and the methodolgy I described in this posting seems like the most feasible one I have at my disposal if I'm not utilizing the ValidationProvider component. Do you have any ideas how I can accomplish this with what I described earlier? Thanks for all your help in this matter too!

Mar 15, 2010 at 8:58 AM

Hi,

Actually that would be also my idea. Wherein i have a service that will contain all the validation, then after the validation process, i'l just return the resulting message. One thing, if you are using the error provider control in windows forms. You can dynamically invoke it to show an error next to the control. Its the SetError method of the error provider. Just like when you use the ValidationProvider, its also tied up with the error provider. If another idea hits my head, I'll let you know.

 

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