By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,694 Members | 2,122 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,694 IT Pros & Developers. It's quick & easy.

Validating WinForms Data

P: n/a
Hi There,

I want to be able to validate data entered by a user onto a form.

Different fields will have different validation requirements.

As an example, a text box may only allow numeric, alpha or alpha numeric
entry and/or may have limitations on length or value.

I thought about inheriting a control from one of the standard forms controls
and adding the validation code required but was thinking that this would make
the application heavier than necessary because certain fields only require
certain validation.

I wanted a way to add validation only where required so thought of creating
a validator object which could have various validationRule objects added as

The validator could respond to events like textChanged on a text box and
where it would then check the rules that had been applied.

I thought that the validationRule object would be either abstract or
impliment specific interface.

I like the GOF 'Chain of Responsibility' pattern as a way of getting the
rule objects to respond to a message from the validator however, I don't know
how to ensure that all the rule objects have received/responded to the

Does this concept make sense? Is this the best way to go about validating
user input? Is this pattern appropriate in this example?
Your thoughts/ideas/comments appreciated.

Wayne Phipps
Feb 2 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.