Using the Validator Framework with Struts
Subject:   Field Dependent Processing?
Date:   2003-02-27 17:48:28
From:   anonymous2
I'm using the Jakarta Validator classes to do some validation on my JavaBeans. The problem is that some of the fields in my bean should only be filled in if other fields in the bean are filled in.

For example my bean consists of the fields:

int a;
String b;
String c;

Now a is always supposed to be there so I know how to check for that. Field b is optional, so I don't need to check whether its there or not, I just need to check its type when it is there. However, if b is there, then c has to be there. Is it possible to check for this using the Validator classes? If so, how would I make my rule?


Full Threads Newest First

Showing messages 1 through 2 of 2.

  • Field Dependent Processing?
    2003-06-26 10:33:48  anonymous2 [View]

    I'm afraid we'll have to wait for someone to add a "depends" attribute to the "form" tag that can access to every field. Anyway, the idea behind Validation Framework is not to render useless the "validate" method, but to avoid writing always the same rules. Your rule seem to be quite "peculiar" so I imagine you don't have it in 45 places on your site.

    Nevertheless, a "form dependent" validation wolud be a nice touch.


    • Field Dependent Processing?
      2003-06-26 10:38:33  anonymous2 [View]


      There is a documentation about a "validwhen" features that could suit your needs...

      I should have RTFDocs :-)