cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Giacomo Pati <>
Subject Re: [cforms] Optionally required fields
Date Thu, 08 Jan 2004 10:55:20 GMT

Sylvain Wallez wrote:
> Hi all,
> I encountered a problem today: I have a form where a field is required 
> or not depending on the value of another field. I wanted to control this 
> using the validation (with a <wd:assert>) but couldn't as the validators 
> aren't called if the value is null.
> To allow this, I wanted to propose that, when a field isn't explicitely 
> marked as required, validators be called even if the value is null.
> But then comes another problem, since most validators expect a non-null 
> value and will break on NPE if no value is given.
> So what about the following changes:
> - when a field isn't marked as required, validators are called even if 
> the value is null,

If a value is not required isn't it always valid on null-values?

> - validators that need a value to do their job (e.g. regexp, range, 
> email, etc) will return "true" (valid) for a null value

If the value is null and the field is not required it should be valid 
without even consulting the validator. Do I miss something?

> - other validators (such as assert) will behave according to their 
> semantics with null values.

Giacomo Pati
Otego AG, Switzerland -
Orixo, the XML business alliance -

View raw message