DataAnnotationsExtensions icon indicating copy to clipboard operation
DataAnnotationsExtensions copied to clipboard

Added a GreaterThan validator based upon the EqualTo

Open rschiefer opened this issue 13 years ago • 3 comments

Refactored EqualTo validator by pulling common comparison validation code to an abstract base class and added GreaterThan validator based upon the base.

Note: I added a GreaterThan jQuery validator to support the DataAnnotation validator. These need to be added to the NuGet package:

jquery.validate.additional-methods.js jquery.validate.unobtrusive.additional-methods.js

rschiefer avatar Sep 23 '11 14:09 rschiefer

Thanks for the code -- it looks really solid but I am hesitant to pull it into the project just yet because of the requirement to add the two additional JavaScript files, while all of the other validators will just work out of the box. I would eventually like to move in this direction and add more complex validators which require custom JavaScript, but I'm not sure how to communicate that to the user. Something like `[DataAnnotationsExtensions.AdditionalValidators.GreaterThan] might work, but seems a bit obtuse, and also I thought about having the "additional validation" validators like yours not initialized (on the client) by default so the user has to turn them on and thus know to add in the proper javascript. Anyway, let me know what you (the wider DataAnnotationsExtensions users) think, because eventually validators like Greater/Less Than, RequiredIf, Future/Past, etc, would be quite helpful but require more user intervention.

srkirkland avatar Oct 12 '11 02:10 srkirkland

Thanks for the kind words and creating this project! At this point it looks like you have covered all the "out-of-the-box" validators so isn't it time to start building custom validators :). I will be using this project (even if only in a local repo) for all my custom validators going forward. It is a far cleaner solution and abstraction point for all my apps to use instead of littering each app or each view with custom validators.

The un-initialized "AdditionalValidators" pattern is already a well known in my opinion because jQuery.Validation does the same.

rschiefer avatar Oct 13 '11 14:10 rschiefer

I merged to your latest code today and would like to avoid this in the future. Can we revisit pulling my additions into your source?

rschiefer avatar Mar 14 '13 17:03 rschiefer