[aida] Validation enhancements?

Friedrich Dominicus frido at q-software-solutions.de
Wed Nov 24 14:01:40 CET 2010


Another question which I should forward to this list.

The validation of elements. If we add input elements to forms we do it
via the  add..Aspect:for: functions. But we have to declare the
validation in an extra step. According to Janko the following code does
that:


field := e newCell addInputFieldAspect: #tanNr for: self observee.
	field 
		validIfTrue: [:value | self observee parent noOtherTanMatches: value ];
		errorText: 'Tan numbers must be unique'.

Shouldn't this validatoin functoin be added to the above line with e.g a
block?

like this:
field := e newCell addInputField: ... for: ... validateAgainst:
someBlock? someValidatorObject?


And building upon this shouldn't we than have either some extra classes
which make this "easier accessible".

field := e newCell addNumericConraintField: #tanNr....

well than we still have the question on when this validation will be
handeled. If JavaScript is active this validation can be run directly
on the Client, but we probably need some other validation rules (either
if someone does not have JavaScript active) or if we want to assure that
our model data are ok. Anyway the code probably has to emit two
different validation functions. One in JavaScript one in Smalltalk.

I think it would be terrible to have 

field := e newCell addNumericContraintField: #tanNr
clientSideValidation: [someJavaScript validation block]
serverSideValidatin: [some Smalltalk validation block]

if I look over this we probably be bette of using ValidationObjects.

something like
WebValidatorObject

    clientSideValidatorFun: whatToValidateOnClient
    serverSideValidationFun: whatToValidateOnServer
    modelValidationFun: ValidatorForTheModel.

.
yes indeed it looks clumsy, but the use of it would be simple


field := e newCell addNumericContraintField: #tanNr validator:
IntegerInputFieldValidator .....

or the like. 

It would be best of course to get at least some logging if the
validatoin failed. It seems debugging Aida wite the Smalltalk debugger
is not that "nice". At least I wasn't able to step through my code
because some other context function was debugged while I just said step
over.

But maybe it's just me beeing to dumb...

Regards
Friedrich





-- 
Q-Software Solutions GmbH; Sitz: Bruchsal; Registergericht: Mannheim 
Registriernummer: HRB232138; Geschaeftsfuehrer: Friedrich Dominicus


More information about the Aida mailing list