The best approach is to make validate() deal with syntax validation. At the
beginning of your execute() method, run business logic validation and
construct ActionErrors if your business logic fails. You really shouldn't
be trying to stuff business logic in the validate() method -- keep that for
data syntax validation only.

Paul

On Fri, Mar 22, 2013 at 1:51 PM, J.V. <jvsr...@gmail.com> wrote:

> I have some code that does not use the Apache commons validator plugin.
>  There is a method in LoginForm.java validate() that calls
> isPasswordValid(password) that will query the database and validate the
> password and set an error message if not, and this error message is
> retrieved in the Action and a message displayed if the password was not
> valid.
>
> What I want to do is to eliminate the 'validate()' method in all of the
> *Form.java classes and goto the Apache commons validator and enter the
> rules for the password field in an entry in validator-user.xml.
>
> With this file I can see things like minimum length etc, but how would I
> validate the password if I remove the validate() method (seems easier to do
> in code).
>
> Ideally I need a combination of leaving the validate() method there (for
> just this one case) and also have it check the requirements in the
> validator-user.xml file (check the validator.xml file first for not empty,
> min length etc) and then ultimately and finally check the entered value
> against the database.
>
> What is the best approach here for refactoring the application to remove
> all validator() methods (all of which 90% of the time check the same
> things), and go to using Apache commons validator (I need a hybrid approach
> for the password field).
>
> thanks
>
> J.V.
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: 
> user-unsubscribe@struts.**apache.org<user-unsubscr...@struts.apache.org>
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

Reply via email to