Can we automate struts2.x validations framework?

61 Views Asked by At

Is there a way to automate the validation framework usage in struts2.x. i mean automatically generate the validation xmls by looking at the form???

1

There are 1 best solutions below

0
On

Nutshell: no.

How would that even work? Without specifying explicit validation information, e.g., types, ranges, regex, etc. there's no metadata with which to magically guess what's "valid".

You could do something trivial in an interceptor by enforcing that all values must have some value.

You could use a naming convention, but that doesn't build an XML file as you're requesting.

You could use annotations, which also doesn't create an XML file.

It's unclear what problem you're actually trying to solve.