You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by David Winterfeldt <dw...@yahoo.com> on 2000/12/30 00:07:36 UTC
Validation Framework
What is the status of having basic validation built
into struts?
I have a basic validation framework that I can
contribute if it is wanted. All validation rules are
stored in an XML file. It can check if a field is
required and apply a regular expression to it using
the jakarta Regexp package. There are default
messages in the resource file.
ex: {0} is required. - For required
{0} is invalid. - For mask/regexp validation
It retrieves the 'displayname' from the resource file
and applies it to the default messages. There is the
option of specifying a custom message for the regular
expression.
All that would need to changed in struts is to add the
digester init code to the ActionServlet. Add the
validation code to the validate method in the
ActionForm.
David Winterfeldt
<form-validation>
<form name="adminUserForm">
<field property="username"
displayname="adminUserForm.username.displayname"
required="true"
mask="^\w+$"/>
<field property="password"
displayname="adminUserForm.password.displayname"
required="true"
mask="^\w+$"
maskMsg="adminUserForm.password.maskmsg"/>
<field property="password2"
displayname="adminUserForm.password2.displayname"
required="true"
mask="^\w+$"
maskMsg="adminUserForm.password.maskmsg"/>
</form>
<form-validation>
__________________________________________________
Do You Yahoo!?
Yahoo! Photos - Share your holiday photos online!
http://photos.yahoo.com/
Re: Validation Framework
Posted by Oleg V Alexeev <go...@penza.net>.
Hello David,
Great! Can you publish it?
Saturday, December 30, 2000, 2:07:36 AM, you wrote:
DW> What is the status of having basic validation built
DW> into struts?
DW> I have a basic validation framework that I can
DW> contribute if it is wanted. All validation rules are
DW> stored in an XML file. It can check if a field is
DW> required and apply a regular expression to it using
DW> the jakarta Regexp package. There are default
DW> messages in the resource file.
DW> ex: {0} is required. - For required
DW> {0} is invalid. - For mask/regexp validation
DW> It retrieves the 'displayname' from the resource file
DW> and applies it to the default messages. There is the
DW> option of specifying a custom message for the regular
DW> expression.
DW> All that would need to changed in struts is to add the
DW> digester init code to the ActionServlet. Add the
DW> validation code to the validate method in the
DW> ActionForm.
DW> David Winterfeldt
DW> <form-validation>
DW> <form name="adminUserForm">
DW> <field property="username"
DW> displayname="adminUserForm.username.displayname"
DW> required="true"
DW> mask="^\w+$"/>
DW> <field property="password"
DW> displayname="adminUserForm.password.displayname"
DW> required="true"
DW> mask="^\w+$"
DW> maskMsg="adminUserForm.password.maskmsg"/>
DW> <field property="password2"
DW> displayname="adminUserForm.password2.displayname"
DW> required="true"
DW> mask="^\w+$"
DW> maskMsg="adminUserForm.password.maskmsg"/>
DW> </form>
DW> <form-validation>
DW> __________________________________________________
DW> Do You Yahoo!?
DW> Yahoo! Photos - Share your holiday photos online!
DW> http://photos.yahoo.com/
--
Best regards,
Oleg mailto:gonza@penza.net