You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Ugo Cei <ug...@apache.org> on 2004/09/02 11:47:38 UTC

[CForms] Validation of non-required fields

Dear Cocooners,

am I wrong or the behaviour of validation in 2.2 changed so that it's 
now practically impossible to validate optional fields?

                 <fd:field id="email" required="false">
                         <fd:label>E-mail</fd:label>
                         <fd:datatype base="string">
                                 <fd:validation>
                                         <fd:email/>
                                 </fd:validation>
                         </fd:datatype>
                 </fd:field>

If the field is not filled-in, you get a not-so-nice NPE under 
2.2.0-dev. What I want is to have the validation be performed only if 
the value is not null, and this seems to be impossible now, whereas it 
was possible (IIRC) in 2.1.5.

	Ugo

-- 
Ugo Cei - http://beblogging.com/

Re: [CForms] Validation of non-required fields

Posted by Sylvain Wallez <sy...@apache.org>.
Bruno Dumon wrote:

>On Thu, 2004-09-02 at 11:47, Ugo Cei wrote:
>  
>
>>Dear Cocooners,
>>
>>am I wrong or the behaviour of validation in 2.2 changed so that it's 
>>now practically impossible to validate optional fields?
>>
>>                 <fd:field id="email" required="false">
>>                         <fd:label>E-mail</fd:label>
>>                         <fd:datatype base="string">
>>                                 <fd:validation>
>>                                         <fd:email/>
>>                                 </fd:validation>
>>                         </fd:datatype>
>>                 </fd:field>
>>
>>If the field is not filled-in, you get a not-so-nice NPE under 
>>2.2.0-dev. What I want is to have the validation be performed only if 
>>the value is not null, and this seems to be impossible now, whereas it 
>>was possible (IIRC) in 2.1.5.
>>    
>>
>
>I noticed that too.
>
>It will work if you put the fd:validation tag outside of the
>fd:datatype, which is the new way of doing things. fd:validation inside
>fd:datatype needs to be deprecated (or temporarily fixed until it is
>deprecated).
>  
>

Yup. I plan to work on CForms in the coming weeks so that we can achieve 
a stable state, and this is on the todo list.

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }


Re: [CForms] Validation of non-required fields

Posted by Ugo Cei <ug...@apache.org>.
Il giorno 02/set/04, alle 11:56, Bruno Dumon ha scritto:

> It will work if you put the fd:validation tag outside of the
> fd:datatype, which is the new way of doing things. fd:validation inside
> fd:datatype needs to be deprecated (or temporarily fixed until it is
> deprecated).

Thanks, it works now!

-- 
Ugo Cei - http://beblogging.com/

Re: [CForms] Validation of non-required fields

Posted by Bruno Dumon <br...@outerthought.org>.
On Thu, 2004-09-02 at 11:47, Ugo Cei wrote:
> Dear Cocooners,
> 
> am I wrong or the behaviour of validation in 2.2 changed so that it's 
> now practically impossible to validate optional fields?
> 
>                  <fd:field id="email" required="false">
>                          <fd:label>E-mail</fd:label>
>                          <fd:datatype base="string">
>                                  <fd:validation>
>                                          <fd:email/>
>                                  </fd:validation>
>                          </fd:datatype>
>                  </fd:field>
> 
> If the field is not filled-in, you get a not-so-nice NPE under 
> 2.2.0-dev. What I want is to have the validation be performed only if 
> the value is not null, and this seems to be impossible now, whereas it 
> was possible (IIRC) in 2.1.5.

I noticed that too.

It will work if you put the fd:validation tag outside of the
fd:datatype, which is the new way of doing things. fd:validation inside
fd:datatype needs to be deprecated (or temporarily fixed until it is
deprecated).

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org