If all you want to do is check that either field is entered, that can be done quite easliy with the validwhen validation rule. Example:
You're right, though, about the fact that validwhen has some serious limitations. In this example, if you not only wanted to check that either name or SSN is entered, but also that the SSN if entered contains only digits, validwhen doesn't give you a way to do that. You'd have to write a custom validation rule.
Then why would I even need a Validator framework explicitly??
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joined: Feb 15, 2005
Let's not lose sight of the fact that the validator framework was designed to handle only the simple validations. Example: is it non-blank? is it an integer? is it a valid email address?
Anything much more complicated than that requires you to write your own validation code. Example: Is the account number valid? Were at least three of the five checkboxes checked?
In answer to Jothi's question, there are a lot of good reasons for using the validation framework. The most obvious is that it provides a codeless way of performing simple validations. The fact that it also provides client-side validation is also a big plus.
In Sandeep's example, if this is a validation that occurs only once in your application, then I agree that it's easier just to put the logic in the validate() method. However, if the same validation is used multiple times in the application, it might be worth while to create a custom validation rule.