I have integrated my Validat stuff with Model-Glue 2 and the Widget example app, and uploaded it to a new RIAforge project that I called
Walidget. I have not yet created a ZIP download but the source on SVN is stable enough for others to try out.
I encourage anyone who uses Validat to download the code from SVN and
take a look at it. If you want to look at the code but don't know how
to use an SVN repository, email me directly and I'll supply you a ZIP
file. I'd apprecate any feedback on the Validat addons or the
Model-Glue integration.
With the recent stirring on mailing
lists and blogs about Model-Glue, I'm likely to migrate my Walidget
application to Gesture (Model-Glue 3) in the coming weeks in the hopes
that it will be useful in bringing Gesture closer to release.
In addition to the features I already mentioned, Walidget includes a "compare2" validator to perform a relational comparison (lt, gte, neq, etc.) of a field against a second field in the dataset. I used the Strategy design pattern to write one validator CFC (validateCompare2.cfc) for three different validator beans in ColdSpring (validateCompare2Numbers, validateCompare2Strings, and validateCompare2Dates). The string variant has an optional caseSensitive argument, and the date variant has an optional datepart argument.
Here's how I use validateCompare2Dates in an example form:
<validationRules>
<rule name="compare2datetimes" validator="validateCompare2Dates">
<arg name="datepart" value="s" />
</rule>
</validationRules>
<dataSets>
<dataSet name="widget.Widget">
<dataElement name="OrderDate" required="false">
...
</dataElement>
<dataElement name="ShipDate" required="false">
...
<assert rule="compare2datetimes">
<arg name="resultIfSecondValueMissing" value="noOrderDate" />
<arg name="operator" value="gte" />
<depend name="secondValue" value="OrderDate" />
<message name="invalid" value="The ship date must on or after the order date." />
<message name="noOrderDate" value="The ship date must not be provided without an order date." />
</assert>
</dataElement>
</dataSet>
</dataSets>
If I change the datepart value in the compare2datetimes rule from "s" to "d", the assertion would then ignore the time parts of OrderDate and ShipDate when performing the comparision.
The resultIfSecondValueMissing is optional and can be used to either generate a different validation message when the second value is missing or to force the assertion to pass when the second value is missing (use value="true").
Cheers,
Dennis