Lukas,<br><br>Thanks for your reply. <br>I also thought that was the rationale behind it. <br>I will make a local extension that suits my needs and check if 'strange things' happen.<br><br>Regards,<br><br>Bart<br><br>
<div class="gmail_quote">On Wed, Sep 8, 2010 at 10:15 PM, Lukas Renggli <span dir="ltr"><<a href="mailto:renggli@gmail.com">renggli@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Bart,<br>
<br>
That validation code is indeed very ugly and tricky. The current<br>
design assumes that if a parent object fails to validate it shouldn't<br>
further try to validate its children. I suspect this is why you don't<br>
see some of the errors.<br>
<br>
Depending on context this might be the correct way of validation, in<br>
other cases you might need something more like you've implemented. I<br>
suggest that you create your own subclass of MAValidationVisitor (so<br>
that you don't need to change the core code) and set it for validation<br>
in your container description<br>
<br>
If people think the validation you propose is generally more useful we<br>
can of course change that in the Magritte code as well, but I am not<br>
sure. For validation of nested objects, as well as for references the<br>
different requirements of displaying and performing explode :-(<br>
<br>
Lukas<br>
<div><div></div><div class="h5"><br>
<br>
<br>
On 8 September 2010 21:55, Bart Gauquie <<a href="mailto:bart.gauquie@gmail.com">bart.gauquie@gmail.com</a>> wrote:<br>
> Dear list,<br>
><br>
> I have a question about the validation behaviour of Magritte 2.<br>
><br>
> I have a root entity an Animal. This animal has some properties that are<br>
> required. (beRequired specified on the descriptions). And a condition<br>
> between some properties:<br>
><br>
> Animal class>>conditionDateOfDeathVerplichtBijStatusDeath<br>
> ^[:value|<br>
> |dateOfDeath status|<br>
> dateOfDeath := value readUsing: self descriptionDateOfDeath.<br>
> status := value readUsing: self descriptionStatus.<br>
> (status == AnimalStatus dead)<br>
> ifTrue: [dateOfDeath isNil not]<br>
> ifFalse: [true]]<br>
><br>
> and:<br>
><br>
> Animal class>>descriptionContainer<br>
> ^super descriptionContainer<br>
> addCondition: (self conditionDateOfDeathVerplichtBijStatusDeath)<br>
> labelled: 'Date of death is verplicht bij status Death';<br>
> yourself.<br>
><br>
><br>
> Validation of this Animal entity works fine if I don't fill in the required<br>
> fields => 3 error messages appear. If I choose status=death, but forget to<br>
> fill in a date of death the message appears.<br>
><br>
> However if I do both: forget to fill in required fields, and choose<br>
> status=death and forget to fill in date of death; only the date of death<br>
> message appears... This is something I'm not expecting.<br>
><br>
> I've looked into the code and:<br>
><br>
> MAValidationVisitor>>visitContainer: aDescription<br>
> | errors |<br>
> super visitContainer: aDescription.<br>
> self object ifNil: [ ^ self ].<br>
> errors := OrderedCollection new.<br>
> aDescription do: [ :description |<br>
> [ self<br>
> use: (object readUsing: description)<br>
> during: [ self visit: description ] ]<br>
> on: MAValidationError<br>
> do: [ :err | errors add: err ] ].<br>
> errors isEmpty ifFalse: [<br>
> MAMultipleErrors<br>
> description: aDescription<br>
> errors: errors<br>
> signal: aDescription label ]<br>
><br>
> is the code that validates a container with its children.<br>
> the line:<br>
> super visitContainer: aDescription.<br>
> validates the container itself, so the extra condition=> if that one failes,<br>
> an error thrown up the stack and it does not validate the children any more<br>
> (the required conditions).<br>
><br>
> If I change the code to something like:<br>
> MAValidationVisitor>>visitContainer: aDescription<br>
> | errors |<br>
> errors := OrderedCollection new.<br>
> [super visitContainer: aDescription]<br>
> on: MAValidationError<br>
> do: [:err|errors add: err].<br>
> self object ifNil: [ ^ self ].<br>
><br>
> aDescription do: [ :description |<br>
> [ self<br>
> use: (object readUsing: description)<br>
> during: [ self visit: description ] ]<br>
> on: MAValidationError<br>
> do: [ :err | errors add: err ] ].<br>
> errors isEmpty ifFalse: [<br>
> MAMultipleErrors<br>
> description: aDescription<br>
> errors: errors<br>
> signal: aDescription label ]<br>
><br>
> I collect both errors and see a list of all errors in my gui. I'm not sure<br>
> if this is a correct fix.<br>
> Any advice on this problem? Or is it by design that Magritte behaves like<br>
> this.<br>
><br>
> Thanks for any help,<br>
><br>
> Bart<br>
><br>
> --<br>
> imagination is more important than knowledge - Albert Einstein<br>
> Logic will get you from A to B. Imagination will take you everywhere -<br>
> Albert Einstein<br>
> Learn from yesterday, live for today, hope for tomorrow. The important thing<br>
> is not to stop questioning. - Albert Einstein<br>
> The true sign of intelligence is not knowledge but imagination. - Albert<br>
> Einstein<br>
> However beautiful the strategy, you should occasionally look at the results.<br>
> - Sir Winston Churchill<br>
> It's not enough that we do our best; sometimes we have to do what's<br>
> required. - Sir Winston Churchill<br>
><br>
</div></div>> _______________________________________________<br>
> seaside mailing list<br>
> <a href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.squeakfoundation.org</a><br>
> <a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
><br>
><br>
<font color="#888888"><br>
<br>
<br>
--<br>
Lukas Renggli<br>
<a href="http://www.lukas-renggli.ch" target="_blank">www.lukas-renggli.ch</a><br>
_______________________________________________<br>
seaside mailing list<br>
<a href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>imagination is more important than knowledge - Albert Einstein<br>Logic will get you from A to B. Imagination will take you everywhere - Albert Einstein<br>Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning. - Albert Einstein<br>
The true sign of intelligence is not knowledge but imagination. - Albert Einstein<br>However beautiful the strategy, you should occasionally look at the results. - Sir Winston Churchill<br>It's not enough that we do our best; sometimes we have to do what's required. - Sir Winston Churchill<br>