[aida] Post Tutorial comments - validation
efinley.lists at gmail.com
Thu Apr 21 00:43:18 CEST 2011
2011/4/20 Janko Mivšek <janko.mivsek at eranova.si>:
> Hi Elliot,
> Let me split this thread in two branches, first one about validation:
> On 18. 04. 2011 06:54, Elliot Finley wrote:
>> 2011/4/11 Janko Mivšek <janko.mivsek at eranova.si>:
>>>> #1) Where would I hook in data validations?
>>> See the WebDemoApp>>ajaxValidationExample :
>>> field := e cell addInputFieldAspect: #year for: self size: 4.
>>> validIfTrue: [:value | value asInteger = Date today year];
>>> errorText: 'Wrong!'.
>>> e newCell add: field errorElement.
>>> So, #validIfTrue: aBlock is the main thing for making a validation of
>>> your data. If this block doesn’t pass, submitting of a whole form is
>>> blocked. Only until all fields on form are valid, submitting will succeed.
>>> What you see in above demo is an additional ajaxified validation and
>>> error reporting immediately after data entry.
>> how would I do a validation based on another form field. For example
>> if I had a scheduling application and I had a startDate and endDate.
>> I would want to validate that both dates were in the future and I
>> would want to validate that startDate < endDate.
> If you do Ajax single field posting as in above example, you have value
> of first field already saved into domain object, so you can use it in
> validation of second field, something like:
> validIfTrue: [:endDate | self observee startDate < endDate ]
Okay. This leads to another question though. If the first field is
already committed to the domain object by the time they are at the
second field, then you have the possibility of leaving a domain object
in an invalid state. i.e. the user could update some fields and not
others. Ideally, you'd want to have an all or nothing approach. Is
there a way to do total form validation before the fields are
More information about the Aida