2006/11/2, Ramon Leon <ramon.leon(a)allresnet.com>:
Anyone know of any good resources for working with the validation
Magritte. Specifically I'm interested in what it takes to have fields that
depend on the value of each other. Say an end date that must be before a
start date, both of which have just been edited.
I was thinking something like this on the instance side...
^self class description collect: [:each |
each accessor selector = #eventEndDate
ifTrue: [each addCondition: [:value | value > self
But that doesn't work because I can't rely on eventStartDate having a value
yet, it may not have been set by its description, or it may be invalid for
some other reason. Are the any public sample apps that use Magritte heavily
one could look at?
I need something like that for events in ICalMagritte where either
duration or end has to be nil. I define a condition on the object
(event) like this:
MACondition subclass: #ICMEventCondition
^(self endOf: aCheckedMemento) isNil
or: [ (self durationOf: aCheckedMemento) isNil ]
^aCheckedMemento cache at: ICEvent descriptionEnd
^aCheckedMemento cache at: ICEvent descriptionDuration
ICEvent class >> #descriptionContainer
addCondition: ICMEventCondition new labelled: ICMEventCondition defaultLabel;
There are probably better ways but this works nice for me.