On Wed Jun 13 18:50:14 2007, GTERMARS wrote:
Show quoted text> I recently wanted to make use of some of the methods in
> DFV::ConstraintFactory, but couldn't get any of them to work properly.
> Dug a bit deeper into the code and saw that this module (1) doesn't
> have a test suite, and (2) doesn't work properly. Doh!
>
> I've attached a patch here which addresses both issues...
>
> Firstly, it updates the "t/constraint_factory.t" test suite so
> that -all- of the methods in this module now have a test suite.
>
> Secondly, it fixes the actual DFV::ConstraintFactory module so that it
> actually now passes the tests.
>
> FYI, although I agree that some of the function names are unwieldy, I
> also think that its useful to have these constraints around; its a
> whole lot quicker/easier to just use "make_set_constraint()"
> or "make_clamp_constraint()" than it is to build your own constraint
> methods.
I've reviewed this patch now.
There are two kinds of constraints in DFV. There is the old kind, which
received the value as the input, and there are the new "constraint
methods", which pass in a DFV object as the first argument.
Your patch didn't "fix" the constraint factory so much as it changed the
behavior of the constraints generated from the old way to the new way.
Applying your patch will surely break someones code if they upgrade DFV,
perhaps even some of my own code.
In the ::Constraints module, I made all the constraints available the
old and a new ways, through some hoop jumping.
The reality is that the new way you've switched it to is better, and
supporting both is more complicated, without adding much value, except
backwards compatibility. However, DFV has generally always tried to be
backwards compatible, and I want to continue that trend.
I suggest releasing the updated module and tests in their own
distribution, under the name Data::FormValidator::ConstraintMethodsFactory.
And since it won't need to be compatible then, improve some of the names
and add and remove usual functions as you see fit! For example, maybe
"make_or_constraint" could become just "FV_or". (The FV_ prefix is used
some other new DFV constraint methods).
I would be happy to then update the DFV docs to promote the new solution
, and would likely start using it myself.
Mark