|
From: Steven D. <ste...@gm...> - 2005-04-09 13:45:24
|
> At the moment SWF does not have any direct binding & validation support of
> its own: it just uses the Spring binding and validation infrastructure
> (DataBinder, Errors, Validator). I don't think binding and validation is
> really a feature that we should build *into* SWF. Instead we need to
> integrate with existing solutions.
I hear you. It's just that I really would like to see declarative
validation rules. Besides, a validator that would support this would
simply be a specialization of the Validator interface.
>
> Could you elaborate on the "XWork validators" a bit?
>
This example says it all:
<validators>
<field name="bar">
<field-validator type="required">
<message>You must enter a value for bar.</message>
</field-validator>
<field-validator type="int">
<param name="min">6</param>
<param name="max">10</param>
<message>bar must be between ${min} and ${max}, current
value is ${bar}.</message>
</field-validator>
</field>
<field name="date">
<field-validator type="date">
<param name="min">12/22/2002</param>
<param name="max">12/25/2002</param>
<message>The date must be between 12-22-2002 and
12-25-2002.</message>
</field-validator>
</field>
<field name="foo">
<field-validator type="int">
<param name="min">0</param>
<param name="max">100</param>
<message key="foo.range">Could not find foo.range!</message>
</field-validator>
</field>
<validator type="expression">
<param name="expression">foo > bar</param>
<message>Foo must be greater than Bar. Foo = ${foo}, Bar =
${bar}.</message>
</validator>
</validators>
|