ianring/Chloroform

"addrule" method should be renamed, for clarity

Opened this issue · 0 comments

Chloroform needs two new methods, to add and remove a rule from the rules collection. Instead of adding the rule to the global scope, which is what's expected now.

the problem is, there's already an "addrule" method, and it doesn't add a rule. It takes a rule that already exists and adds it to an element's validation criteria.

I propose that the methods be renamed:

  • addrule(rule) - add a new named rule to the rules collection
  • removerule(rule) - remove a named rule from the rules collection
  • applyrule(element,rule,args) - apply a rule to an element. Rule is either a rule name from the rules collection, or an object that contains a named function
  • revokerule(element, rule) - removes a rule from an element's validation

I'm open to other suggestions