vivin / regula

Regula: An annotation-based form-validation framework in Javascript
126 stars 24 forks source link

bind vs validate: element vs elementId #26

Open troyji opened 13 years ago

troyji commented 13 years ago

regula.bind takes an option parameter of 'element', which is a DOM element to operate on. regula.validate takes an option parameter of 'elementId', a string id of an element to operate on. This is inconsistent.

Instead of changing to one or the other, I would propose that both functions should simply allow either parameter.

It could also be argued that both methods should accept an array of element id strings of elements ('elementIds') to operate on in addition to their already existing parameter that takes a list of DOM elements ('elements') to operate on.

vivin commented 13 years ago

The reason I used elementId in validate() initially was to enforce the requirement that all elements that are validated, require id's. But since regula automatically adds id's to elements that don't have id's, I'd say this requirement isn't necessary anymore; your suggestions make sense and I'll put this on my list of things to do :).