SourceForge Logo

SVT: Struts Validation Toolkit

SVT (Struts Validation Toolkit) is a form validation framework for Struts.

You can write a simple validating code in Java, rather than writing validation.xml files (which is supported in Struts 1.1). This enables you to do conditional validation, based on other properties, request, session or whatever.

Validation example

If the form bean has properties "name" and "age", both is required, and "age" must be a number, the validation code looks like this:

public class InputForm extends ActionForm {

    public ActionErrors validate(
        ActionMapping mapping,
        HttpServletRequest request) {
        Validator v = new Validator(getServlet(), this, mapping.getName());
        v.validate("name", Rules.required());
        v.validate("age", new Rule[] { Rules.required(), Rules.number() });
        return v.getErrors();


  1. Put dist/svt.jar into your WEB-INF/lib directory.
  2. Write your validation code in the form bean.
  3. Configure error messages in the resource file.
    (example is at src/example1/java/example1/