Please help me out in doing validation for the following scenario using Validation.xml
I have a drop down With 3 state values(ex: Kentucky,Michigan) and
a textbox which will accept the claim# for the state selected.
1. Both state dropdown and claim# can be null.
2. A value is selected from State dropdown but no values can be entered for claim#.
3. Claim# format for each of the state selected are different(for ex Kentucky takes a String of length 8 or 9, MI takes a String of length 5).
I tried both requiredif and validWhen constructs in validation.xml but its not satisfying all sceanrios.
No, seriously: the limitations of validWhen makes this difficult and/or impossible. Combine the two forms of validation.
The other best option is to write and register a custom validator: this keeps the logic in Java code, where it belongs, and it more easily testable, but allows the configuration to still be entire in XML.
I won't help you with the validWhen expression--it would be too difficult to set up a way to test it, it's too finicky because of the way it was built, and substantially better options exist. Consider going the custom validator route--it's easy, and makes it look like the validation is entirely in XML, even though the tricky bits are somewhere else (where they're manageable).
subject: how to validate this scenario using validation.xml