Sorry, but I don't know how to create a validator for a boolean field if I always need to have a validator assigned.
I can't even assign it to Validator class and use the default "do nothing" field because that field had to change. Since the last example you gave me returned a boolean, the "do nothing" function had to be modified.
So now, it technically does something.
Code:
public class Validator<T>
{
public virtual bool Validate(T data) { return false; }
}
Three5Eight Using: MS C# 08 EE, MS SQL 05 EE, C++ .Net 08 EE, Vista Home Premium, XP Home
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010 In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
Ok, I'll make the changes then. I tried to stay away from returning true because no matter what is passed into the function will always be true even if it's not valid. I figured it was safer to return false and not assume the field was valid.
Now my IsValid() function will check all the field's Value property correctly. But I didn't know it was possible for a class to build a collection of all of the fields declared within it.
Right now I'm checking them all manually like I shown in my code example on Post # 40
Three5Eight Using: MS C# 08 EE, MS SQL 05 EE, C++ .Net 08 EE, Vista Home Premium, XP Home
If you remember,there was a time when the constructor for "Field" had a "this" parameter, but this broke things because we were using initializer lists....
Building the collection is done by implementing a set of calls. during construction (which is now taking place within the business objects constuuctor.
I dont have time tonight, but I will try to post an updated sample tomorrow morning.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010 In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
Interesting, I'll look forward to your example. I think that would be usefull in many places. Not just validation. I guess you learn something new everyday. In the mean time I'll keep working on cleaning up my classes after all this.
Three5Eight Using: MS C# 08 EE, MS SQL 05 EE, C++ .Net 08 EE, Vista Home Premium, XP Home
Ironically this process is leading directly toward some material I am preparing for publication (that does handle alot more than validation). If the current implementation works for your immediate needs, it may be best to wait a week or so, so you can see the "real" design.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010 In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
Well everything works except the IsValid() function right now. I have many more classes to design, and if I can get the IsValid() down first then I do not have to rewrite all those classes.
But, other then that everything seems to be working. However, I haven't tested it at run time yet to see if the code really does what its supposed to. I wanted to get this last piece worked out first so everything is working when I test it.
Three5Eight Using: MS C# 08 EE, MS SQL 05 EE, C++ .Net 08 EE, Vista Home Premium, XP Home
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.