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 required. (beRequired specified on the descriptions). And a condition between some properties:<br>
<br>Animal class&gt;&gt;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 clear="all"><br>and: <br><br>Animal class&gt;&gt;descriptionContainer<br>    ^super descriptionContainer<br>
        addCondition: (self conditionDateOfDeathVerplichtBijStatusDeath) labelled: &#39;Date of death is verplicht bij status Death&#39;;<br>        yourself.<br><br><br>Validation of this Animal entity works fine if I don&#39;t fill in the required fields =&gt; 3 error messages appear. If I choose status=death, but forget to fill in a date of death the message appears.<br>
<br>However if I do both: forget to fill in required fields, and choose status=death and forget to fill in date of death; only the date of death message appears... This is something I&#39;m not expecting.<br><br>I&#39;ve looked into the code and:<br>
<br>MAValidationVisitor&gt;&gt;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=&gt; if that one failes, an error thrown up the stack and it does not validate the children any more (the required conditions).<br>
<br>If I change the code to something like: <br>MAValidationVisitor&gt;&gt;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&#39;m not sure if this is a correct fix. <br>Any advice on this problem? Or is it by design that Magritte behaves like 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 - 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&#39;s not enough that we do our best; sometimes we have to do what&#39;s required. - Sir Winston Churchill<br>