I'm wondering whether conditions could be fleshed out some more or if I'm
missing some intention/design…
I was employing a technique described by Ramon Leon [1] for conditions that
affect multiple descriptions, namely:
```
descriptionContainer
^(super descriptionContainer)
addCondition: [:memento |
(memento cache at: self descriptionEndDate) > (memento cache at:
self descriptionStartDate)]
labelled: 'End date must be after start date';
yourself
```
I noticed a few seeming limitations of this technique (and conditions in
general):
1. The example above only works when using a cached memento. It fails due to
DNU #cache for other Memento types, as well as when validating objects
directly (e.g. `myDomainObject magritteDescription validate: self.`)
2. When the above fails, the exception bubbles up on its own instead of
being grouped together with failed conditions from individual descriptions
because `MAValidatorVisitor>>#visitContainer:` handles the container
validation separately (via `super visitContainer: aDescription.`) before
looping through the element descriptions to validate them.
3. In both the container and element validations, once one condition
per-[container | element] fails, others are not processed (for the same
[container | element]). I experimented with expanding the error handling
block, but couldn't see a great way to overcome this without a more
significant rewrite because MAValidationErrors are not resumable.
My quick fix idea would be to make MAValidationErrors resumable and expand
the error block to include the container along with the element validations.
Would that be the best way to address the issues above?
1.
http://onsmalltalk.com/multiple-field-validation-rules-in-magritte
-----
Cheers,
Sean
--
Sent from:
http://forum.world.st/Magritte-Pier-and-Related-Tools-f115649.html