You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Vadim Gritsenko <va...@reverycodes.com> on 2005/07/08 20:58:39 UTC

[CForms] ValidationError, Was: Add isValid() to a widget?

Carsten Ziegeler wrote:
> Carsten Ziegeler wrote:
> 
>>Reinhard Poetz wrote:
>>
>>>no, but the interface ValidationErrorAware has and it is implemented by most 
>>>model implementations.
>>>
>>>What's your usecase?
>>
>>I just want to check if a widget is valid and then output something in
>>an own transformer. Ok, I could cast it to ValidationErrorAware but it
>>seems a little bit strange to have a validate() method on the widget but
>>no isValid() method.
> 
> So anyone against it?

While on the subject of forms validation... I noticed several very annoying things:

  * Field.getValidationError() *does not* simply return validation error:
    it has side effects!!! It calls getValue() which can invoke parsing
    and validation - depending on state, resulting in weird behavior.

  * Field.setValidationError() *does not* simply set validation error:
    it *also* has side effects!!! For some reason it changes widget state,
    which can results in weird behavior.

Any objections on fixing these violations as well?

Vadim

Re: [CForms] ValidationError, Was: Add isValid() to a widget?

Posted by Joerg Heinicke <jo...@gmx.de>.
On 08.07.2005 20:58, Vadim Gritsenko wrote:

> While on the subject of forms validation... I noticed several very 
> annoying things:
> 
>  * Field.getValidationError() *does not* simply return validation error:
>    it has side effects!!! It calls getValue() which can invoke parsing
>    and validation - depending on state, resulting in weird behavior.
> 
>  * Field.setValidationError() *does not* simply set validation error:
>    it *also* has side effects!!! For some reason it changes widget state,
>    which can results in weird behavior.
> 
> Any objections on fixing these violations as well?

+1 Of course no objections for fixing side effects.

Joerg

Re: [CForms] ValidationError, Was: Add isValid() to a widget?

Posted by Carsten Ziegeler <cz...@apache.org>.
Vadim Gritsenko wrote:
> 
> While on the subject of forms validation... I noticed several very annoying things:
> 
>   * Field.getValidationError() *does not* simply return validation error:
>     it has side effects!!! It calls getValue() which can invoke parsing
>     and validation - depending on state, resulting in weird behavior.
> 
>   * Field.setValidationError() *does not* simply set validation error:
>     it *also* has side effects!!! For some reason it changes widget state,
>     which can results in weird behavior.
> 
> Any objections on fixing these violations as well?
> 
Side effects are always bad! +1 from me to fix this.

Carsten

-- 
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/