If you don't require a date, then you can't qualify the argument as a date, because CF has no concept of NULL. The closest you can get is saying "" is equivalent to null, and then using the string type as you propose. You should do validation inside your method like this:
<cfif len(arguments.myDate) GT 0 AND NOT isDate(arguments.myDate)> <cfthrow type="IllegalArgumentException" message="myDate is not a valid date" /> </cfif> That way you preserve your argument type checking, even though CF is forcing you to do it manually. If you ask me, CF's lack of NULL is really quite a burden. CF is a loosely typed language, which is fine, but then they came and added in strong typing all over the place, but didn't provide the ability to use NULL, so the strong typing is often either cumbersome or simply unusable. This is a perfect example of that. cheers, barneyb On 9/20/05, Peter Hardy <[EMAIL PROTECTED]> wrote: > Hi guys, > > I've seen this on the forum before but I'm can't remember the answer at all. > > I've created a transfer object that takes amongst others a couple of date > parameters. Trouble is, they are optional parameters so sometimes they are a > valid date and sometimes they are equal to "". If my cfargument type to date > cf just throws an exception. > > How do I handle this? Shoudl I just store it as a string? > > Cheers, Pete (aka lad4bear) -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 100 invites. ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). CFCDev is supported by New Atlanta, makers of BlueDragon http://www.newatlanta.com/products/bluedragon/index.cfm An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
