[Seaside] object validation pattern?

Jon Paynter kittle31 at gmail.com
Mon Oct 15 16:46:30 UTC 2012


On Mon, Oct 15, 2012 at 9:15 AM, Chris Muller <asqueaker at gmail.com> wrote:

> The answer depends on why you want to validate.  I tend to want to
> make validation as late and lazy as possible.  For example, have you
> ever used one of those UI's where, when try to tab off a field and it
> won't let you because it says "Required" or "Invalid format".  That
> approach is wrong.  :)
>
> For implementation just use good ol'e exception handling in select
> places (usually pretty high up).  That leaves the vast majority of the
> code clean and unburdened by exception-handling/validation code.
>
>
> I come from the other side, and chose not to use exception handlers for
validation, and rather let seaside/smalltalk raise an exception if there is
an issue in my model during normal execution.  This tells me theres a bug
somewhere that needs fixing.

I found a nice component in the seaside book used to display messages
(StMessageComponent), and built a validation setup around that. I make sure
all validation is done from the UI.  It just calls #validate:  with a msg
component as the argument.  each class in my model validates itself, and
returns true or false, and if false the msg component has the message to
display.  The UI does not return from the edit/add/delete/whatever until
all validation passes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20121015/f51c05ae/attachment.htm


More information about the seaside mailing list