proposal: custom validator, that validates an empty field

From: Marten Lehmann <>
Date: Fri, 12 Aug 2005 20:49:54 +0200


if I understood the description of this mailing list correctly this is
the right place to come up with proposals, that may be discussed and
later added to the spec.

Hereby, I'd like to propose an option so that a custom validator is
called even when an input-field is empty. The current specs says, that
in this case the validator isn't called.

This would be very usefull, because otherwise it's impossible to
generate custom per-field error messages. If you have a table of
error-messages like you have with

<h:messages layout="table"/>

it's stupid to see a dozend of lines showing "validation error, value
required". Instead, you could generate a custom message like "Please
enter your phone number" or "please choose a country".

An even more important case is the country/states problem in the USA.
many shops require you to select a state if your country is the USA. But
if you are outside of the USA, you don't have to enter it. Currently,
there is no way to solve this problem with JSF 1.1. With a custom
validator, that is called even with an empty field, you could show an
error-message like "You selected country 'USA', please specify your
state, too".