h5Validate icon indicating copy to clipboard operation
h5Validate copied to clipboard

External Validators

Open christianlent opened this issue 10 years ago • 16 comments

I been using your library for a few months now and I've quite liked it. However, I came across a circumstance where I needed external (functional) validation. I couldn't figure out how to do this with the library as it was (if there's a way, I must have missed the documentation).

This is an extremely bare-bones implementation: A selector that is checked against each validated field to determine whether validation is run A validation function that takes the value of the field and returns a Boolean result

christianlent avatar Mar 13 '14 16:03 christianlent

Thank you very much for your contribution! =)

On the whole, this is good work. For a long time I've planned to revisit this project and move all validation types into their own modules using a mechanism like this.

Could you rename this to addValidator() to prep for that refactor? Basically, instead of calling it "external" anything, it becomes the core mechanism for hooking up validation types. Also, if you'd like to extract one of the built-in validators (like radio or checkbox) and wire it up with addValidator instead of validate(), that would go a long way toward making sure that it supports all the features we need.

ericelliott avatar Mar 14 '14 00:03 ericelliott

Thanks for the feedback! Let me address your core feedback first. I may make an attempt at refactoring some existing functionality, but my time is running low to work on this right now, so no guarantees. If I were going to refactor an existing piece of functionality, my inclination would be to tackle "validValues" (unless you have an objection).

christianlent avatar Mar 14 '14 13:03 christianlent

Nevermind, "validValues" is not a great refactor candidate.

christianlent avatar Mar 14 '14 14:03 christianlent

Don't feel obligated. I understand being busy. I appreciate the work you've done so far. This is the closest thing anyone has come up with to my plan to modularize validators. I appreciate the time you already took (including tests).

ericelliott avatar Mar 14 '14 16:03 ericelliott

OK, I addressed at least some of your feedback, but I haven't yet had time to refactor any existing functionality using the custom validators. I did add an "options" parameter however (currently used for naming validators), but I envision that being used for other really cool things like per-validator errorClass or validClass.

christianlent avatar Mar 14 '14 16:03 christianlent

Good call on the options. I'll take a look later. Working now.

ericelliott avatar Mar 14 '14 16:03 ericelliott

Anything I can do to help this along? I may have some time this weekend if that's what it needs to be completed.

christianlent avatar Apr 07 '14 17:04 christianlent

Have you managed to refactor any of the existing validations using this approach? I'd like to make sure it supports them all, ideally.

ericelliott avatar May 15 '14 06:05 ericelliott

Hmm, good question. Unfortunately, I haven't yet. I'll take a look next time I have a free weekend. It's definitely a worthy goal. Supposing I actually refactored some, and merely determined that the others are capable of being refactored - would that be sufficient? Also, do all the validations have decent unit tests (so I can tell if my refactoring incidentally breaks anything)?

christianlent avatar May 28 '14 19:05 christianlent

Yes, and yes. And I appreciate it! =)

ericelliott avatar May 29 '14 01:05 ericelliott

Any progress? I'd love to merge this work in...

ericelliott avatar Aug 01 '14 01:08 ericelliott

I'm sorry, I got very busy again! I'll try to take a look this weekend. Still loving h5Validate BTW.

christianlent avatar Aug 07 '14 20:08 christianlent

Thank you 1000x for your work on this. I wish I had more time to invest in this project, because it's a critically important aspect of every app.

ericelliott avatar Aug 08 '14 22:08 ericelliott

Let me know if there is anything else I can do to move this along. I'm looking forward to your comments on the changes!

christianlent avatar Aug 22 '14 16:08 christianlent

Sorry it's taken me so long to get around to this. I really need somebody else to take over primary responsibility for maintaining h5Validate if we want it to stay relevant.

ericelliott avatar Jan 04 '15 19:01 ericelliott

I completely understand and there's certainly no need to apologize! I'm grateful for the work you've already put into the library, and I've personally found it indepensible in one of my current projects.

christianlent avatar Jan 05 '15 02:01 christianlent