cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Olivier Billard <obill...@rennes.jouve.fr>
Subject How to validate (range, min, max) a field depending on another (boolean) field value ? Was: [cforms] Optionally required fields
Date Wed, 07 Jan 2004 17:15:42 GMT
Hi all, Hi Sylvain,

Your post makes me wonder if it is possible to do validation of a field (any type of 
validation) depending of another field value, or "conditionize" the requirement of a field

depending on another field value :

Exemple :
  - boolean field "recall" : true/false
  - field "number of recalls" : required if recall is true and ranges from 1 to n

is it possible to do so ?

For the moment,I set "number of recalls" field required with a default value of 1, but 
display the field only if recall is true (hidden otherwise)... and deal with its 
requirement later in business code... but if woody could do this, it would be cool.

--
Olivier

On 07/01/2004 17:58, 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,
> - validators that need a value to do their job (e.g. regexp, range, 
> email, etc) will return "true" (valid) for a null value
> - other validators (such as assert) will behave according to their 
> semantics with null values.
> 
> What do you think?



Mime
View raw message