[TransWarp] Constraints on model attributes
Phillip J. Eby
pje at telecommunity.com
Sun Jul 27 21:23:28 EDT 2003
At 10:53 PM 7/27/03 +0200, Roché Compaan wrote:
>* Phillip J. Eby <pje at telecommunity.com> [2003-07-27 21:31]:
> > If what you really want is to "validate", you probably don't want to use
> > any of the existing machinery. Instead, you should define an interface
> > expected of features, that defines a validation method, and then require
> > features to have that method.
>
>This makes perfect sense but I must think of way that won't lead to a
>duplication of code because the validation code will have to do some of
>the same checks that mdl_normalize will do.
No reason why the validation code can't call mdl_normalize, too.
> > The distinction in my mind between normalization and validation, is
> that to
> > validate, you want to validate *all* your values and assemble a series of
> > messages, so that you can give them all to the user. So, you don't
> want to
> > throw an error in the midst of modifying, say, a multi-element sequence
> > because one of the items is wrong. You just want to validate the values
> > and see if they're okay.
>
>As long as you catch all the exceptions you can still display all the
>validation failures to the user.
True. But that won't check the really *interesting* constraints, which are
usually at the level of the object.
I'm going to give a bit more thought to the subject, because ideally I'd
like it to be possible to have a constraint validation framework for PEAK
that handles this kind of feedback.
More information about the PEAK
mailing list