Hmmm. Very good point.  Most of our cases, we are entering only the nine
digits.  However, we have people who can't think of an SSN without
hyphens.  They may it harder by entering the hyphens.  Usually, I strip
those when input because all of our SSNs are store without hyphens.

To keep functions totally separate, I may need another function that
"sets up" the SSN in the right format such as:

<cffunction name="fixSSNFormat" returntype="string" ...>
    <cfargument name="ssn" type="string" required="true">
    <cfreturn right("000000000" & arguments.ssn, 9)>
</cffunction> 

This function would add any leading zeros to make a nine-digit-long SSN.
It may still not be a valid SSN, but at least the length will be
correct.

Then, I can wrap this function with the other functions such as:

#maskSSN(fixSSNFormat(mySSN))#

My original dilemna is why can't my maskSSN() function just go ahead and
add the leading zeros?  I would guess that would be bad because I may
have many different SSN functions that would all have similar "leading
zero" code.  In that case, I would be better off creating the "fixSSN"
function and use it within the other functions.

I finally have some time to play around with these recent suggestions.

Thanks!

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Bill Rawlinson
Sent: Wednesday, December 01, 2004 9:27 PM
To: [EMAIL PROTECTED]
Subject: Re: [CFCDev] Intelligence of Functions

just curious but what if someone passes in a ssn that is already
formated 123-45-6789 it isn't just nine characters, it is a valid ssn,
it is the actual expected output.

It doesn't seem to me that this really violates the contract - and
throwing an exception would be an unwanted result.

based on my understanding of the problem your trying to solve it seems
that if the ssn is not in the format 123456789 or 123-45-6789 then you
should throw an exception.  If you get it in either of these two formats
then you should either format it (if needed) and return the validly
formatted ssn.

personally, I would probably have two functions - one that formats a SSN
and one that masks a ssn (xxx-xx-6789)

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words '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 
[EMAIL PROTECTED]

Reply via email to