Andy,
Will save work if validate hasn't been called first?  Why not call Validate
within the save method?

Andy

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of cf_nut
Sent: Monday, October 06, 2003 12:36 PM
To: [EMAIL PROTECTED]
Subject: Re: [CFCDev] Data validation


Hi Phillip,

You may want to take a look at the way we've done things, briefly
sketched here ...

http://www.redev.org/archives/000035.cfm

Our validate() method is not implicitly invoked by save() ( store()
in our case ). Instead, it's the callers responsibilty to call
validate() before calling save(). validate() returns a structure
indicating the properties that are in error and a text message
describing the error ( for eventual display in the presentation
layer, typically). If either (a) the validate() method is not
invoked, or (b) validate() indicates an error condition, then a
subsequent save() throws an exception. It's therefore up to the
calling code to ensure that if errors are returned by validate(),
that suitable action is taken, such as displaying an error message
to the user .

Cheers,  Andy


---  "Phillip Cave" <[EMAIL PROTECTED]> wrote:
>
> I'm attempting to do the same thing. In this case I have 2 objects
(Page and
> PageData). When Page.Save() is called, it passes itself to the
InsertPage()
> method of the PageData object which does the actual database
operations. I'm
> just confused as to what all of these methods should be returning.
If
> Page.Save() calls PageData.Validate() before PageData.InsertPage()
and there
> are actual validation errors, what would PageData.Validate()
return to
> Page.Save() (I would assume either an array of validation errors
or some
> sort of message object)... Furthermore, what in turn does Page.Save
() return
> to the calling program (assuming the object was not saved because
there were
> validation errors)?
>
> Thanks,
> Phillip
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of Justin Balog
> Sent: Friday, October 03, 2003 9:25 AM
> To: '[EMAIL PROTECTED]'
> Subject: RE: [CFCDev] Data validation
>
>
>
> Just to throw in my very humble 2 cents, I do not have save() as a
method of
> any of my objects.  I don't believe an object should be able to
persist
> itself. (Kind of like the terminator).  I create persister objects
that
> handle saving to the dB.  These persister objects take the type of
object to
> persist with a setObjToPerisit() getObjectToPersist().  That way
if my data
> platform changes, I don't have to revisit the objects themselves,
I just
> have to write a new persister method for that type of object.  In
my
> application each object has a corresponding persistor type object
that has a
> bunch of persist methods saveSQLServer, saveACCESS, saveWDDX,
saveCSV,
> saveORACLE, etc.  Just a thought.
>
> Take care,
>
> Justin
>
> -----Original Message-----
> From: Phillip Cave [mailto:[EMAIL PROTECTED]
> Sent: Friday, October 03, 2003 7:51 AM
> To: [EMAIL PROTECTED]
> Subject: [CFCDev] Data validation
>
>
>
> Where is the best place to handle data validation in an object?
Should an
> object's Save() method be responsible for validating it's internal
members
> before actually saving or should the calling program call a
Validate()
> method before attempting to save?
>
> Any advice is appreciated.
>
> Thanks,
> Phillip
>
> --
>
> Phillip Cave
> Director, ColdFusion Development
> Macromedia Certified ColdFusion Developer Carol/Trevelyan Strategy
Group
> 202.448.5212
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email to
> [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported by
Mindtool,
> Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at
> www.mail-archive.com/[EMAIL PROTECTED]
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email to
> [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported by
Mindtool,
> Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at
> www.mail-archive.com/[EMAIL PROTECTED]
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at www.mail-
archive.com/[EMAIL PROTECTED]

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at
www.mail-archive.com/[EMAIL PROTECTED]

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to