vivin/regula

Run.validate should not always throw error on unbound constraints

saunders99999 opened this issue · 1 comments

I have a tree of elements, and want to run validation on element A and its descendants
A->B1->C(constraint)
A->B2(constraint)

Use Case 1 - all is well when running validate on all constraints in Tree A

  • On Page load, I search A and its descendants for constraints and bind C,B2
  • Page Handler runs validate on Tree A elements (C, B2)

Use Case 2 - ERROR when running validate on select constraints in Tree A

  • On Page load, I search A and its descendants for constraints and bind C,B2
  • Page logic occurs
  • Page handler unbinds the constraint on element C
  • Page handler runs validate on Tree A elements (C,B2)
    • NOTE: cannot use API to check that constraint on C is unbound
  • Regula.validate throws an error as constraint C is unbound

To help support select validation of Tree A. I am requesting that either

  • Regula.validate has a flag to set so it will not throw an error on unbound constraints OR...
  • Regula.isbound be added to the API so I can check and include only elements with bounded constraints to the Regula.validate method.

I would think Regula.bind and Regula.unbind is a good way to turn on/off constraints during validation checks.

I think a state-inspection method like regula.isBound(...) would make sense. This is the typical way to check to see if a situation could potentially throw an exception. Thank you for bringing this to my attention. :) I will commit a fix as soon as I can.