Search code examples
javavalidationstruts-1

Struts 1.2 validation framework: a separate class for validations


I want to validate user inputs. Struts 1.2 provides a validation framework itself. But its validation is not enough for me. Also I don't like to put my validation (because it may have more codes and logic) into the Form class and need to keep separately from Action class's business logic and Form class. Is there any way to use a separate validate class in Struts 1.2 ? Any useful link with sample code snippets would be appreciated.


Solution

  • Struts uses Commons Validator. You can use its validators in your code where you want (e.g. your action extracts data from form bean into POJO and invokes business logic, and only then business logic uses Calendar validator to check entered dates).