[Magritte] Validation object existence in collection.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Magritte] Validation object existence in collection.

Humber Aquino
Hi Seasiders :P  I have a Magritte question. It´s about validating and
managing a collection of described objects.
For example:
I have a Person class with 2 descriptions:
Person class>>descriptionName
 ^ (MAStringDescription auto: 'name' label: 'Name' priority: 10)
           beRequired;
           yourself.
and
Person class>>descriptionAge.
 ^ MANumberDescription auto: 'name' label: 'Name' priority: 10.

When i want a seaside component for editing or creating a Person Object i call
person := self call:(Person new asComponent addValidatedForm; yourself).

Thats pretty standard. he Thing is, all the validations for each
description in this container are validated but only for this object.
Do i have to make my own validations if i want to validate the
existence of this object in a Collection. I know this sound really
dumb but i would like to know if theres a clean way to do this. I want
to use Seaside with Magritte for building and validating my objects
and persist them with magma.
I created a magma repository with a Dictionary as a root. This
dictionary has one entry called people with a OrderedCollection as
it's value.
So, which strategy is the best in this case? Is there a clean way to
do it? Am i missing something? Sorry for the verbosity and thanks
again!

One last thing. In the MAReport class is a method called NOW that says
we shouldn't use that class. I works that bad? I Used it and still now
it's working ok.

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: [Magritte] Validation object existence in collection.

Lukas Renggli
> Thats pretty standard. he Thing is, all the validations for each
> description in this container are validated but only for this object.
> Do i have to make my own validations if i want to validate the
> existence of this object in a Collection. I know this sound really
> dumb but i would like to know if theres a clean way to do this. I want
> to use Seaside with Magritte for building and validating my objects
> and persist them with magma.
> I created a magma repository with a Dictionary as a root. This
> dictionary has one entry called people with a OrderedCollection as
> it's value.
> So, which strategy is the best in this case? Is there a clean way to
> do it? Am i missing something? Sorry for the verbosity and thanks
> again!

Yeah, see MADescription in the #validating protocol. To check if all
you objects are valid you can do:

    anOrderedCollection allSatisfy: [ :ea | ea description isSatisfiedBy: ea ]

To validate your all your objects and trigger an exception in case of
a problem you can do:

    anOrderedCollection do: [ :ea | ea description validate: ea ]

> One last thing. In the MAReport class is a method called NOW that says
> we shouldn't use that class. I works that bad? I Used it and still now
> it's working ok.

That comment has been there for years and most people have been
ignoring it. MAReport is even used in several industrial application,
so I guess its save to ignore that comment. It definitely needs a
cleanup ...

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside