- CFML Reference User Guide
- ColdFusion functions
- ColdFusion functions by category
- Functions a-b
- Abs
- ACos
- AddSOAPRequestHeader
- AddSOAPResponseHeader
- AjaxLink
- AjaxOnLoad
- ApplicationStop
- ArrayAppend
- ArrayAvg
- ArrayClear
- ArrayContains
- ArrayContainsNoCase
- ArrayDelete
- ArrayDeleteAt
- ArrayDeleteNoCase
- ArrayEach
- ArrayFilter
- ArrayFind
- ArrayFindAll
- ArrayFindAllNoCase
- ArrayFindNoCase
- ArrayInsertAt
- ArrayIsDefined
- ArrayIsEmpty
- ArrayLen
- ArrayMap
- ArrayMax
- ArrayMin
- ArrayNew
- ArrayPrepend
- ArrayReduce
- ArrayResize
- ArraySet
- ArraySetMetadata
- ArraySlice
- ArraySort
- ArraySum
- ArraySwap
- ArrayToList
- Asc
- ASin
- Atn
- AuthenticatedContext
- AuthenticatedUser
- BinaryDecode
- BinaryEncode
- BitAnd
- BitMaskClear
- BitMaskRead
- BitMaskSet
- BitNot
- BitOr
- BitSHLN
- BitSHRN
- BitXor
- BooleanFormat
- Abs
- Functions-c-d
- CacheGet
- CacheGetAllIds
- CacheGetMetadata
- CacheGetProperties
- CacheGetSession
- CacheIdExists
- CachePut
- CacheRegionExists
- CacheRegionNew
- CacheRegionRemove
- CacheRemove
- CacheRemoveAll
- CacheSetProperties
- CallStackDump
- CallStackGet
- CanDeSerialize
- Canonicalize
- CanSerialize
- Ceiling
- CharsetDecode
- CharsetEncode
- Chr
- CJustify
- Compare
- CompareNoCase
- Cos
- CreateDate
- CreateDateTime
- CreateObject
- CreateObject: .NET object
- CreateObject: COM object
- CreateObject: component object
- CreateObject: CORBA object
- CreateObject: Java or EJB object
- CreateObject: web service object
- CreateODBCDate
- CreateODBCDateTime
- CreateODBCTime
- CreateSignedJWT
- CreateEncryptedJWT
- CreateTime
- CreateTimeSpan
- CreateUUID
- CSRFGenerateToken
- CSRFVerifyToken
- CSVRead
- CSVWrite
- CSVProcess
- DateAdd
- DateCompare
- DateConvert
- DateDiff
- DateFormat
- DatePart
- DateTimeFormat
- Day
- DayOfWeek
- DayOfWeekAsString
- DayOfYear
- DaysInMonth
- DaysInYear
- DE
- DecimalFormat
- DecodeForHTML
- DecodeFromURL
- DecrementValue
- Decrypt
- DecryptBinary
- DeleteClientVariable
- Deserialize
- DeserializeJSON
- DeserializeXML
- DirectoryCopy
- DirectoryCreate
- DirectoryDelete
- DirectoryExists
- DirectoryList
- DirectoryRename
- DollarFormat
- DotNetToCFType
- Duplicate
- Functions-e-g
- EncodeForCSS
- EncodeForDN
- EncodeForHTML
- EncodeForHTMLAttribute
- EncodeForJavaScript
- EncodeForLDAP
- EncodeForURL
- EncodeForXML
- EncodeForXMLAttribute
- EncodeForXpath
- Encrypt
- EncryptBinary
- EntityDelete
- EntityLoad
- EntityLoadByExample
- EntityLoadByPK
- EntityMerge
- EntityNew
- EntityReload
- EntitySave
- EntityToQuery
- Evaluate
- Exp
- ExpandPath
- FileClose
- FileCopy
- FileDelete
- FileExists
- FileGetMimeType
- FileIsEOF
- FileMove
- FileOpen
- FileRead
- FileReadBinary
- FileReadLine
- FileSeek
- FileSetAccessMode
- FileSetAttribute
- FileSetLastModified
- FileSkipBytes
- FileUpload
- FileUploadAll
- FileWrite
- FileWriteLine
- Find
- FindNoCase
- FindOneOf
- FirstDayOfMonth
- Fix
- Floor
- FormatBaseN
- GeneratePBKDFKey
- GenerateSecretKey
- GetApplicationMetadata
- GetAuthUser
- GetBaseTagData
- GetBaseTagList
- GetBaseTemplatePath
- GetClientVariablesList
- GetComponentMetaData
- GetContextRoot
- GetCPUUsage
- GetCurrentTemplatePath
- GetCSPNonce
- GetDirectoryFromPath
- GetEncoding
- GetException
- GetFileFromPath
- GetFileInfo
- GetFreeSpace
- GetFunctionCalledName
- GetFunctionList
- GetGatewayHelper
- GetHttpRequestData
- GetHttpTimeString
- GetK2ServerDocCount
- GetK2ServerDocCountLimit
- GetLocale
- GetLocaleDisplayName
- GetLocalHostIP
- GetMetaData
- GetMetricData
- GetPageContext
- GetPropertyString
- GetPropertyFile
- GetPrinterInfo
- GetPrinterList
- GetProfileSections
- GetProfileString
- GetReadableImageFormats
- GetSafeHTML
- GetSAMLAuthRequest
- GetSAMLLogoutRequest
- Generate3DesKey
- GenerateSAMLSPMetadata
- GetSOAPRequest
- GetSOAPRequestHeader
- GetSOAPResponse
- GetSOAPResponseHeader
- GetSystemFreeMemory
- GetSystemTotalMemory
- GetTempDirectory
- GetTempFile
- GetTemplatePath
- GetTickCount
- GetTimeZoneInfo
- GetToken
- GetTotalSpace
- GetUserRoles
- GetVFSMetaData
- GetWriteableImageFormats
- Functions-h-im
- Hash
- HMac
- Hour
- HQLMethods
- HTMLCodeFormat
- HTMLEditFormat
- IIf
- ImageAddBorder
- ImageBlur
- ImageClearRect
- ImageCopy
- ImageCreateCaptcha
- ImageCrop
- ImageDrawArc
- ImageDrawBeveledRect
- ImageDrawCubicCurve
- ImageDrawLine
- ImageDrawLines
- ImageDrawOval
- ImageDrawPoint
- ImageDrawQuadraticCurve
- ImageDrawRect
- ImageDrawRoundRect
- ImageDrawText
- ImageFlip
- ImageGetBlob
- ImageGetBufferedImage
- ImageGetEXIFMetadata
- ImageGetEXIFTag
- ImageGetHeight
- ImageGetIPTCMetadata
- ImageGetIPTCTag
- ImageGetMetadata
- ImageGetWidth
- ImageGrayscale
- ImageInfo
- ImageMakeColorTransparent
- ImageMakeTranslucent
- ImageNegative
- ImageNew
- ImageOverlay
- ImagePaste
- ImageRead
- ImageReadBase64
- ImageResize
- ImageRotate
- ImageRotateDrawingAxis
- ImageScaleToFit
- ImageSetAntialiasing
- ImageSetBackgroundColor
- ImageSetDrawingColor
- ImageSetDrawingStroke
- ImageSetDrawingTransparency
- ImageSharpen
- ImageShear
- ImageShearDrawingAxis
- ImageTranslate
- ImageTranslateDrawingAxis
- ImageWrite
- ImageWriteBase64
- ImageXORDrawingMode
- Functions-in-k
- IncrementValue
- InputBaseN
- Insert
- Int
- InterruptThread
- InvalidateOauthAccesstoken
- Invoke
- InitSAMLAuthRequest
- InitSAMLLogoutRequest
- InvokeCFClientFunction
- IsArray
- IsAuthenticated
- IsAuthorized
- IsBinary
- IsBoolean
- IsClosure
- IsCustomFunction
- IsDate
- IsDateObject
- IsDDX
- IsDebugMode
- IsDefined
- IsImage
- IsImageFile
- IsInstanceOf
- IsIPv6
- IsJSON
- IsK2ServerABroker
- IsK2ServerDocCountExceeded
- IsK2ServerOnline
- IsLeapYear
- IsLocalHost
- IsNull
- IsNumeric
- IsNumericDate
- IsObject
- isOnline
- IsPDFArchive
- IsPDFFile
- IsPDFObject
- IsProtected
- IsQuery
- isSamlLogoutResponse
- isSafeHTML
- IsSimpleValue
- IsSOAPRequest
- IsSpreadsheetFile
- IsSpreadsheetObject
- IsStruct
- isThreadInterrupted
- IsUserInAnyRole
- IsUserInRole
- IsUserLoggedIn
- IsValid
- IsValidOauthAccesstoken
- IsWDDX
- IsXML
- IsXmlAttribute
- IsXmlDoc
- IsXmlElem
- IsXmlNode
- IsXmlRoot
- JavaCast
- JSStringFormat
- Functions-l
- LCase
- Left
- Len
- ListAppend
- ListChangeDelims
- ListContains
- ListContainsNoCase
- ListDeleteAt
- ListEach
- ListFilter
- ListFind
- ListFindNoCase
- ListFirst
- ListGetAt
- ListGetDuplicates
- ListInsertAt
- ListLast
- ListLen
- ListMap
- ListPrepend
- ListQualify
- ListReduce
- ListRemoveDuplicates
- ListRest
- ListSetAt
- ListSort
- ListToArray
- ListValueCount
- ListValueCountNoCase
- LJustify
- Location
- Log
- Log10
- LSCurrencyFormat
- LSDateFormat
- LSDateTimeFormat
- LSEuroCurrencyFormat
- LSIsCurrency
- LSIsDate
- LSIsNumeric
- LSNumberFormat
- LSParseCurrency
- LSParseDateTime
- LSParseEuroCurrency
- LSParseNumber
- LSTimeFormat
- LTrim
- Functions-m-r
- Max
- Mid
- Min
- Minute
- Month
- MonthAsString
- Now
- NumberFormat
- ObjectEquals
- ObjectLoad
- ObjectSave
- OnWSAuthenticate
- ORMClearSession
- ORMCloseAllSessions
- ORMCloseSession
- ORMEvictCollection
- ORMEvictEntity
- ORMEvictQueries
- ORMExecuteQuery
- ORMFlush
- ORMFlushall
- ORMGetSession
- ORMGetSessionFactory
- ORMIndex
- ORMIndexPurge
- ORMReload
- ORMSearch
- ORMSearchOffline
- ParagraphFormat
- ParameterExists
- ParseDateTime
- Pi
- PrecisionEvaluate
- ProcessSAMLResponse
- ProcessSAMLLogoutRequest
- Quarter
- PreserveSingleQuotes
- QueryAddColumn
- QueryAddRow
- QueryConvertForGrid
- QueryExecute
- QueryFilter
- QueryGetResult
- QueryGetRow
- QueryKeyExists
- QueryMap
- QueryNew
- QueryReduce
- QuerySetCell
- QuotedValueList
- QueryEach
- Rand
- Randomize
- RandRange
- ReEscape
- REFind
- REFindNoCase
- ReleaseComObject
- REMatch
- REMatchNoCase
- RemoveCachedQuery
- RemoveChars
- RepeatString
- Replace
- ReplaceList
- ReplaceNoCase
- REReplace
- REReplaceNoCase
- RestDeleteApplication
- RestSetResponse
- RestInitApplication
- Reverse
- Right
- RJustify
- Round
- RTrim
- Functions-s
- Second
- SendGatewayMessage
- SendSAMLLogoutResponse
- Serialize
- SerializeJSON
- SerializeXML
- SessionInvalidate
- SessionRotate
- SessionGetMetaData
- SessionInvalidate
- SessionRotate
- SetDay
- SetEncoding
- SetHour
- SetLocale
- SetMonth
- SetProfileString
- SetPropertyString
- SetVariable
- SetYear
- Sgn
- Sin
- Sleep
- SpanExcluding
- SpanIncluding
- SpreadsheetAddAutoFilter
- SpreadsheetAddColumn
- SpreadsheetAddFreezePane
- SpreadsheetAddImage
- SpreadsheetAddInfo
- SpreadsheetAddPageBreaks
- SpreadsheetAddRow
- SpreadsheetAddRows
- SpreadsheetAddSplitPane
- SpreadsheetCreateSheet
- SpreadsheetDeleteColumn
- SpreadsheetDeleteColumns
- SpreadsheetDeleteRow
- SpreadsheetDeleteRows
- SpreadsheetFormatCell
- SpreadsheetFormatColumn
- SpreadsheetFormatCellRange
- SpreadsheetFormatColumn
- SpreadsheetFormatColumns
- SpreadsheetFormatRow
- SpreadsheetFormatRows
- SpreadsheetGetCellComment
- SpreadsheetGetCellFormula
- SpreadsheetGetCellValue
- SpreadsheetGetColumnCount
- SpreadsheetInfo
- SpreadsheetMergeCells
- SpreadsheetNew
- SpreadsheetRead
- SpreadsheetReadBinary
- SpreadsheetRemoveSheet
- SpreadsheetSetActiveSheet
- SpreadsheetSetActiveSheetNumber
- SpreadsheetSetCellComment
- SpreadsheetSetCellFormula
- SpreadsheetSetCellValue
- SpreadsheetSetColumnWidth
- SpreadsheetSetFooter
- SpreadsheetSetHeader
- SpreadsheetSetRowHeight
- SpreadsheetShiftColumns
- SpreadsheetShiftRows
- SpreadsheetWrite
- StreamingSpreadsheetNew
- StreamingSpreadsheetCleanup
- StreamingSpreadsheetRead
- StreamingSpreadsheetProcess
- SpreadsheetSetFooterImage
- SpreadsheetSetHeaderImage
- SpreadsheetSetFittoPage
- SpreadsheetUngroupColumns
- SpreadsheetGroupColumns
- SpreadsheetUngroupRows
- SpreadsheetGroupRows
- SpreadsheetRemoveColumnBreak
- SpreadsheetSetColumnBreak
- SpreadsheetRemoveRowBreak
- SpreadsheetSetRowBreak
- SpreadsheetRemovePrintGridlines
- SpreadsheetAddPrintGridlines
- SpreadsheetGetColumnWidth
- SpreadsheetSetColumnHidden
- SpreadsheetSetRowHidden
- SpreadsheetisColumnHidden
- SpreadsheetisRowHidden
- SpreadsheetisStreamingXmlFormat
- SpreadsheetisXmlFormat
- SpreadsheetisBinaryFormat
- SpreadsheetRenameSheet
- SpreadsheetRemoveSheetNumber
- SpreadsheetGetLastRowNumber
- SpreadsheetGetPrintOrientation
- Sqr
- StripCR
- StructAppend
- StructClear
- StructCopy
- StructCount
- StructDelete
- StructEach
- StructFilter
- StructFind
- StructFindKey
- StructFindValue
- StructGet
- StructGetMetadata
- StructInsert
- StructIsEmpty
- StructKeyArray
- StructKeyExists
- StructKeyList
- StructMap
- StructNew
- StructReduce
- StructSetMetadata
- StructSort
- StructToSorted
- StructUpdate
- StructValueArray
- StoreSetMetadata
- StoreGetACL
- StoreGetMetadata
- StoreAddACL
- StoreSetACL
- Functions-t-z
- Tan
- ThreadJoin
- ThreadTerminate
- Throw
- TimeFormat
- ToBase64
- ToBinary
- ToScript
- ToString
- Trace
- Transactionandconcurrency
- TransactionCommit
- TransactionRollback
- TransactionSetSavePoint
- Trim
- UCase
- URLDecode
- URLEncodedFormat
- URLSessionFormat
- Val
- ValueList
- VerifyClient
- Week
- Wrap
- WriteDump
- WriteLog
- WriteOutput
- WSGetAllChannels
- WSGetSubscribers
- WSPublish
- WSSendMessage
- XmlChildPos
- XmlElemNew
- XmlFormat
- XmlGetNodeType
- XmlNew
- XmlParse
- XmlSearch
- XmlTransform
- XmlValidate
- Year
- YesNoFormat
- ColdFusion tags
- ColdFusion tag summary
- ColdFusion tags by category
- Application framework tags
- Communications tags
- Database manipulation tags
- Data output tags
- Debugging tags
- Exception handling tags
- Extensibility tags
- File management tags
- Flow-control tags
- Forms tags
- Internet Protocol tags
- Page processing tags
- Security tags
- Variable manipulation tags
- Other tags
- Tags a-b
- Tags c
- cfcache
- cfcalendar
- cfcase
- cfcatch
- cfchart
- cfchart tag in ColdFusion
- Get started with cfchart
- Customize a chart using cfchart
- Advanced cfchart customization options
- Create an area chart in ColdFusion
- Create line charts in ColdFusion
- Create bar charts in ColdFusion
- Create floating bar charts in ColdFusion
- Create histograms in ColdFusion
- Create pie charts in ColdFusion
- Create funnel charts in ColdFusion
- Create pyramid charts in ColdFusion
- Create curve charts in ColdFusion
- Create boxplots in ColdFusion
- Create donut charts in ColdFusion
- Create bubble charts in ColdFusion
- Create scatterplots in ColdFusion
- Create radar charts in ColdFusion
- Other chart types in ColdFusion (Cone, Cylinder, Piano, and Bullet)
- Advanced customization options in cfchart
- cfchartdata
- cfchartseries
- cfchartset
- cfclient
- cfclientsettings
- cfcol
- cfcollection
- cfcomponent
- cfcontent
- cfcontinue
- cfcookie
- Tags f
- cffeed
- cffile
- cffile action = "append"
- cffile action = "copy"
- cffile action = "delete"
- cffile action = "move"
- cffile action = "read"
- cffile action = "readBinary"
- cffile action = "rename"
- cffile action = "upload"
- cffile action = "uploadAll"
- cffile action = "write"
- cffileupload
- cffinally
- cfflush
- cfform
- cfformgroup
- cfformitem
- cfftp
- cfftp: Connection: file and directory operations
- cfftp: Opening and closing FTP server connections
- cfftp : Opening and closing secure FTP server connections
- cfftp action = "listDir"
- cffunction
- Tags g-h
- Tags i
- Tags j-l
- cfjava
- cflayout
- cflayoutarea
- cfldap
- cflocation
- cflock
- cflog
- cflogin
- cfloginuser
- cflogout
- cfloop
- cfloop : conditional loop
- cfloop : index loop
- cfloop : looping over a COM collection or structure
- cfloop : looping over a date or time range
- cfloop : looping over a list, a file, or an array
- cfloop : looping over a query
- Tags m-o
- cfmail
- cfmailparam
- cfmailpart
- cfmap
- cfmapitem
- cfmediaplayer
- cfmenu
- cfmenuitem
- cfmessagebox
- cfmodule
- cfNTauthenticate
- cfoauth
- cfobject
- cfobject: .NET object
- cfobject: COM object
- cfobject: component object
- cfobject: CORBA object
- cfobject: Java or EJB object
- cfobject: web service object
- cfobjectcache
- cfoutput
- Tags p-q
- Tags r-s
- Tags t
- Tags u-z
- CFML Reference
- Reserved words and variables
- Ajax JavaScript functions
- Ajax JavaScript functions
- Function summary Ajax
- ColdFusion.Ajax.submitForm
- ColdFusion.Autosuggest.getAutosuggestObject
- ColdFusion.Layout.enableSourceBind
- ColdFusion.MessageBox.getMessageBoxObject
- ColdFusion.ProgressBar.getProgressBarObject
- ColdFusion.MessageBox.isMessageBoxDefined
- JavaScriptFunctionsinColdFusion9Update1
- ColdFusion ActionScript functions
- ColdFusion mobile functions
- Application.cfc reference
- Script functions implemented as CFCs
- ColdFusion Flash Form style reference
- Styles valid for all controls
- Styles for cfform
- Styles for cfformgroup with horizontal or vertical type attributes
- Styles for box-style cfformgroup elements
- Styles for cfformgroup with accordion type attribute
- Styles for cfformgroup with tabnavigator type attribute
- Styles for cfformitem with hrule or vrule type attributes
- Styles for cfinput with radio, checkbox, button, image, or submit type attributes
- Styles for cftextarea tag and cfinput with text, password, or hidden type attributes
- Styles for cfselect with size attribute value of 1
- Styles for cfselect with size attribute value greater than 1
- Styles for cfcalendar tag and cfinput with dateField type attribute
- Styles for the cfgrid tag
- Styles for the cftree tag
- ColdFusion Flash Form Style Reference
- ColdFusion event gateway reference
- ColdFusion Event Gateway reference
- addEvent
- CFEvent
- CFEventclass
- Constructor
- Gateway development interfaces and classes
- getStatus
- setCFCPath
- setCFCMethod
- getOriginatorID
- getLogger
- getBuddyList
- getBuddyInfo
- IM gateway message sending commands
- IM Gateway GatewayHelper class methods
- onIncomingMessage
- onIMServerMessage
- onBuddyStatus
- onAddBuddyResponse
- onAddBuddyRequest
- IM Gateway CFC incoming message methods
- IM gateway methods and commands
- CFML CFEvent structure
- warn
- info
- setOriginatorID
- data command
- submit Multi command
- submit command
- setGatewayType
- setGatewayID
- setData
- setCFCListeners
- outgoingMessage
- getStatusTimeStamp
- numberOfMessagesReceived
- numberOfMessagesSent
- removeBuddy
- removeDeny
- removePermit
- setNickName
- setPermitMode
- setStatus
- SMS Gateway CFEvent structure and commands
- SMS Gateway incoming message CFEvent structure
- getStatusAsString
- getProtocolName
- getPermitMode
- getPermitList
- getNickName
- getName
- getDenyList
- getCustomAwayMessage
- getQueueSize
- getMaxQueueSize
- getHelper
- getGatewayType
- getGatewayServices
- getGatewayID_1
- getGatewayID
- getData
- getCFCTimeout
- setCFCTimeout
- getCFCPath
- getCFCMethod
- GatewayServices class
- Gateway interface
- GatewayHelper interface
- addPermit
- addDeny
- addBuddy
- error
- debug
- Logger class
- stop
- start
- CFML event gateway SendGatewayMessage data parameter
- restart
- fatal
- SMS gateway message sending commands
- ColdFusion C++ CFX Reference
- ColdFusion Java CFX reference
- WDDX JavaScript Objects
- Cloud services
- ColdFusion and GCP Storage
- ColdFusion and GCP Firestore
- ColdFusion and GCP PubSub
- ColdFusion and Amazon S3
- ColdFusion and DynamoDB
- ColdFusion and Amazon SQS
- ColdFusion and Amazon SNS
- ColdFusion and MongoDB
- ColdFusion and Azure Blob
- ColdFusion and Azure Service Bus
- Multi-cloud storage services
- Multi-cloud RDS databases
- ColdFusion and Azure Cosmos DB
Description
Tests whether a value meets a validation or data type rule.
Returns
True, if the value conforms to the rule; False, otherwise.
Category
Function syntax
IsValid(type, value)
isValid("range", value, min, max)
isValid("regex" or "regular_expression", value, pattern)
See also
cfparam , cfform , IsBoolean, IsDate, IsNumeric, IsSimpleValue; Validating data with the IsValid function and the cfparam tag in the Developing ColdFusion Applications
History
ColdFusion (2016 release) Update 3: Added datetime_object as type.
ColdFusion 11: Behavioral change
Prior to ColdFusion 11, this function allowed currency symbols at the start and commas inside the number. Starting from ColdFusion 11, this function evaluates on a more strict basis. To revert to the old behavior use the application-level setting STRICTNUMBERVALIDATION to false.
ColdFusion 8: Added the component value for to the type parameter.
ColdFusion MX 7: Added this function.
Parameters
Parameter |
Description |
|---|---|
type |
The valid format for the data; one of the following. For detailed information on validation algorithms, see Validating form data using hidden fields in the Developing ColdFusion Applications.
|
value |
The value to test |
min |
The minimum valid value; used only for range validation |
max |
The maximum valid value; used only for range validation |
pattern |
A JavaScript regular expression that the parameter must match; used only for regex or regular_expression validation. |
Usage
The IsValid function lets you assure that validation is performed on the server. You can use the cfparam tag to perform equivalent validation.
Example
The following example checks whether a user has submitted a numeric ID and a valid e-mail address and phone number. If any of the submitted values does not meet the validation test, it displays an error message.
<cfif isDefined("form.saveSubmit")>
<cfif isValid("integer", form.UserID) and isValid("email", form.emailAddr)
and isValid("telephone", form.phoneNo)>
<cfoutput>
<!--- Application code to update the database goes here --->
<h3>The email address and phone number for user #Form.UserID#
have been added</h3>
</cfoutput>
<cfelse>
<H3>You must supply a valid User ID, phone number, and email address.</H2>
</cfif>
<cfelse>
</cfif>
<cfform action="#CGI.SCRIPT_NAME#">
User ID:<cfinput type="Text" name="UserID"><br>
Phone: <cfinput type="Text" name="phoneNo"><br>
email: <cfinput type="Text" name="emailAddr"><br>
<cfinput type="submit" name="saveSubmit" value="Save Data"><br>
</cfform>
In ColdFusion 11, the isValid function behaves in a different way. Setting strictnumbervalidation to false makes the isValid function to behave in a way just like in the previous versions (ColdFusion 10 or earlier). Starting from ColdFusion 11, a more strict approach will be followed for validation. However, if you need the isValid function behavior to be of ColdFusion 10, set the key/tag attribute strictnumbervalidation to false in application cfc/cfm.
Application.cfm
<cfapplication name="hello" STRICTNUMBERVALIDATION="false" >
Application.cfc
<cfcomponent>
<cfscript>
{
this.STRICTNUMBERVALIDATION = false;
}
</cfscript>
</cfcomponent>
Example
<cfscript>
// check if 50 is an integer
writeOutput(isValid("integer",50)) // Yes
// check if 3.14 is a numeric
writeOutput(isValid("numeric",3.14)) // Yes
// check if it is a valid url
writeOutput(isValid("URL","http://www.example.com")) // Yes
</cfscript>
Real-world uses of the isValid function
User registration and form validation
E-commerce platforms, SaaS applications, and membership sites process thousands of user registrations daily, requiring comprehensive validation of personal information, contact details, and account credentials. Invalid user data leads to failed communications, poor user experience, and database corruption. Manual validation is impractical at scale. Poor data quality costs businesses an average of $15M annually in operational inefficiencies. Use IsValid to validate email addresses, phone numbers, passwords, and personal information in real-time during user registration and profile updates.
<cfscript>
// Sample user registration data from different sources
userRegistrations = [
{"name": "John Doe", "email": "john.doe@company.com", "phone": "555-123-4567", "age": "28", "website": "https://johndoe.com", "password": "SecurePass123!", "zipCode": "12345"},
{"name": "Jane Smith", "email": "invalid-email-format", "phone": "555-CALL-NOW", "age": "thirty", "website": "not-a-valid-url", "password": "weak", "zipCode": "invalid"},
{"name": "Bob Johnson", "email": "bob@example.org", "phone": "1-800-555-1234", "age": "35", "website": "http://bobjohnson.net", "password": "StrongP@ssw0rd", "zipCode": "90210"},
{"name": "Alice Brown", "email": "alice.brown@domain.co.uk", "phone": "555.987.6543", "age": "42", "website": "", "password": "MySecure2024!", "zipCode": "10001"},
{"name": "Mike Wilson", "email": "mike@startup.io", "phone": "555-987-1234", "age": "31", "website": "https://startup.io", "password": "Innovation2024##", "zipCode": "94102"}
];
</cfscript>
<cfoutput>
<h2>📊 User Registration Validation Results</h2>
<cfloop array="#userRegistrations#" index="user">
<cfscript>
// Validate user registration fields using IsValid
nameValid = Len(Trim(user.name)) GTE 2;
emailValid = IsValid("email", user.email);
phoneValid = IsValid("telephone", user.phone);
ageValid = IsValid("integer", user.age) AND Val(user.age) GTE 18 AND Val(user.age) LE 120;
websiteValid = Len(Trim(user.website)) EQ 0 OR IsValid("url", user.website);
zipCodeValid = IsValid("regex", user.zipCode, "^[0-9]{5}(-[0-9]{4})?$");
// Password strength validation using regex pattern
strongPasswordRegex = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&##])[A-Za-z\d@$!%*?&##]{8,}$";
passwordValid = IsValid("regex", user.password, strongPasswordRegex);
// Calculate registration score
registrationScore = 0;
if (nameValid) registrationScore += 10;
if (emailValid) registrationScore += 25;
if (phoneValid) registrationScore += 20;
if (ageValid) registrationScore += 15;
if (websiteValid) registrationScore += 10;
if (passwordValid) registrationScore += 15;
if (zipCodeValid) registrationScore += 5;
// Determine registration quality
if (registrationScore GTE 90) {
registrationQuality = "Excellent";
qualityColor = "##28a745";
} else if (registrationScore GTE 75) {
registrationQuality = "Good";
qualityColor = "##17a2b8";
} else if (registrationScore GTE 50) {
registrationQuality = "Fair";
qualityColor = "##ffc107";
} else {
registrationQuality = "Poor";
qualityColor = "##dc3545";
}
// Count valid fields
validFieldCount = 0;
totalFields = 7;
if (nameValid) validFieldCount++;
if (emailValid) validFieldCount++;
if (phoneValid) validFieldCount++;
if (ageValid) validFieldCount++;
if (websiteValid) validFieldCount++;
if (passwordValid) validFieldCount++;
if (zipCodeValid) validFieldCount++;
</cfscript>
<div style="background: white; padding: 20px; margin: 15px 0; border-radius: 8px; border-left: 5px solid #qualityColor#; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; align-items: start;">
<!-- User Information -->
<div>
<h3 style="margin-top: 0; color: ##333;">User Registration</h3>
<p><strong>Name:</strong> #user.name#</p>
<p><strong>Email:</strong> #user.email#</p>
<p><strong>Phone:</strong> #user.phone#</p>
<p><strong>Age:</strong> #user.age#</p>
<p><strong>Website:</strong> #Len(user.website) GT 0 ? user.website : 'Not provided'#</p>
<p><strong>Zip Code:</strong> #user.zipCode#</p>
</div>
<!-- IsValid Results -->
<div>
<h4 style="margin-top: 0;">✅ Validation Results</h4>
<div style="background: ##f8f9fa; padding: 10px; border-radius: 3px; font-family: monospace; font-size: 0.85em;">
<p><strong>Name Valid:</strong> #nameValid ? 'Yes' : 'No'#</p>
<p><strong>Email Valid:</strong> #emailValid ? 'Yes' : 'No'#</p>
<p><strong>Phone Valid:</strong> #phoneValid ? 'Yes' : 'No'#</p>
<p><strong>Age Valid:</strong> #ageValid ? 'Yes' : 'No'#</p>
<cfif Len(user.website) GT 0>
<p><strong>Website Valid:</strong> #websiteValid ? 'Yes' : 'No'#</p>
<cfelse>
<p><strong>Website:</strong> Optional (not provided)</p>
</cfif>
<p><strong>Password Strong:</strong> #passwordValid ? 'Yes' : 'No'#</p>
<p><strong>Zip Code Valid:</strong> #zipCodeValid ? 'Yes' : 'No'#</p>
</div>
</div>
<!-- Registration Quality -->
<div>
<h4 style="margin-top: 0;">📊 Registration Quality</h4>
<p><strong>Valid Fields:</strong> #validFieldCount#/#totalFields#</p>
<p><strong>Score:</strong> #registrationScore#/100 points</p>
<p><strong>Quality:</strong> <span style="color: #qualityColor#; font-weight: bold;">#registrationQuality#</span></p>
<p><strong>Completion:</strong> #NumberFormat((validFieldCount/totalFields)*100, "0")#%</p>
</div>
</div>
<!-- Progress Bar -->
<div style="margin-top: 15px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px;">
<h5 style="margin: 0;">📈 Registration Progress</h5>
<span style="font-weight: bold; color: #qualityColor#;">#NumberFormat((registrationScore/100)*100, "0.0")#%</span>
</div>
<div style="background: ##e9ecef; height: 25px; border-radius: 12px; overflow: hidden; position: relative;">
<div style="background: #qualityColor#; height: 100%; width: #NumberFormat((registrationScore/100)*100, "0.0")#%; transition: width 0.3s ease;"></div>
<div style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; font-size: 0.9em; text-shadow: 1px 1px 2px rgba(0,0,0,0.7);">
#validFieldCount# of #totalFields# fields valid
</div>
</div>
</div>
<!-- Field Validation Details -->
<div style="background: ##f8f9fa; padding: 15px; border-radius: 5px; margin-top: 15px;">
<h5 style="margin-top: 0;">🔍 Field Validation Details:</h5>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px;">
<!-- Contact Information -->
<div style="background: white; padding: 10px; border-radius: 3px;">
<h6 style="margin-top: 0; color: ##17a2b8;">Contact Information</h6>
<p style="margin: 2px 0; color: #emailValid ? '##28a745' : '##dc3545'#;">
Email: #emailValid ? '✓ Valid format' : '✗ Invalid format'#
</p>
<p style="margin: 2px 0; color: #phoneValid ? '##28a745' : '##dc3545'#;">
Phone: #phoneValid ? '✓ Valid US format' : '✗ Invalid format'#
</p>
<p style="margin: 2px 0; color: #zipCodeValid ? '##28a745' : '##dc3545'#;">
Zip Code: #zipCodeValid ? '✓ Valid format' : '✗ Invalid format'#
</p>
</div>
<!-- Personal Information -->
<div style="background: white; padding: 10px; border-radius: 3px;">
<h6 style="margin-top: 0; color: ##28a745;">Personal Information</h6>
<p style="margin: 2px 0; color: #nameValid ? '##28a745' : '##dc3545'#;">
Name: #nameValid ? '✓ Valid length' : '✗ Too short'#
</p>
<p style="margin: 2px 0; color: #ageValid ? '##28a745' : '##dc3545'#;">
Age: #ageValid ? '✓ Valid age (18-120)' : '✗ Invalid age'#
</p>
<cfif Len(user.website) GT 0>
<p style="margin: 2px 0; color: #websiteValid ? '##28a745' : '##dc3545'#;">
Website: #websiteValid ? '✓ Valid URL' : '✗ Invalid URL'#
</p>
<cfelse>
<p style="margin: 2px 0; color: ##6c757d;">Website: Optional field</p>
</cfif>
</div>
<!-- Security -->
<div style="background: white; padding: 10px; border-radius: 3px;">
<h6 style="margin-top: 0; color: ##fd7e14;">Security</h6>
<p style="margin: 2px 0; color: #passwordValid ? '##28a745' : '##dc3545'#;">
Password: #passwordValid ? '✓ Strong password' : '✗ Weak password'#
</p>
<cfif NOT passwordValid>
<p style="margin: 2px 0; font-size: 0.8em; color: ##721c24;">
Requires: 8+ chars, upper, lower, number, special
</p>
</cfif>
</div>
</div>
</div>
<!-- Registration Actions -->
<div style="background: rgba(255,255,255,0.8); padding: 12px; border-radius: 5px; margin-top: 15px;">
<strong>📋 Registration Actions:</strong>
<cfif registrationQuality EQ "Excellent">
<br>• ✓ Approve registration immediately
<br>• ✓ Send welcome email to #user.email#
<br>• ✓ Set up user account with full privileges
<br>• ✓ Add to marketing automation system
<cfelseif registrationQuality EQ "Good">
<br>• ⚠ Request verification for weak fields
<br>• ✓ Allow registration with email confirmation
<br>• ⚠ Send data quality improvement suggestions
<br>• ✓ Set up basic user account
<cfelseif registrationQuality EQ "Fair">
<br>• ⚠ Require field corrections before approval
<br>• ⚠ Send validation error messages to user
<br>• ⚠ Offer assistance with data entry
<br>• ⚠ Hold registration pending improvements
<cfelse>
<br>• ✗ Reject registration - too many errors
<br>• ✗ Display comprehensive error messages
<br>• ✗ Offer customer service contact information
<br>• ✗ Log failed registration attempt
</cfif>
</div>
</div>
</cfloop>
<h2>📈 Registration Analytics Dashboard</h2>
<div style="background: ##f8f9fa; padding: 20px; border-radius: 8px; margin: 15px 0;">
<cfscript>
// Calculate registration statistics
totalRegistrations = ArrayLen(userRegistrations);
successfulRegistrations = 0;
averageScore = 0;
totalScore = 0;
emailSuccessRate = 0;
phoneSuccessRate = 0;
passwordSuccessRate = 0;
overallValidCount = 0;
for (user in userRegistrations) {
local.emailValid = IsValid("email", user.email);
local.phoneValid = IsValid("telephone", user.phone);
local.ageValid = IsValid("integer", user.age) AND Val(user.age) GTE 18 AND Val(user.age) LE 120;
local.passwordValid = IsValid("regex", user.password, "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&##])[A-Za-z\d@$!%*?&##]{8,}$");
local.zipValid = IsValid("regex", user.zipCode, "^[0-9]{5}(-[0-9]{4})?$");
local.websiteValid = Len(Trim(user.website)) EQ 0 OR IsValid("url", user.website);
local.nameValid = Len(Trim(user.name)) GTE 2;
local.score = 0;
if (local.nameValid) local.score += 10;
if (local.emailValid) local.score += 25;
if (local.phoneValid) local.score += 20;
if (local.ageValid) local.score += 15;
if (local.websiteValid) local.score += 10;
if (local.passwordValid) local.score += 15;
if (local.zipValid) local.score += 5;
totalScore += local.score;
if (local.score GTE 75) successfulRegistrations++;
if (local.emailValid) emailSuccessRate++;
if (local.phoneValid) phoneSuccessRate++;
if (local.passwordValid) passwordSuccessRate++;
}
averageScore = totalScore / totalRegistrations;
emailSuccessRate = (emailSuccessRate / totalRegistrations) * 100;
phoneSuccessRate = (phoneSuccessRate / totalRegistrations) * 100;
passwordSuccessRate = (passwordSuccessRate / totalRegistrations) * 100;
successRate = (successfulRegistrations / totalRegistrations) * 100;
</cfscript>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px;">
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##28a745;">#successfulRegistrations#</h3>
<p style="margin: 5px 0 0 0;">Successful Registrations</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##17a2b8;">#NumberFormat(averageScore, "0.0")#</h3>
<p style="margin: 5px 0 0 0;">Average Quality Score</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##ffc107;">#NumberFormat(successRate, "0.0")#%</h3>
<p style="margin: 5px 0 0 0;">Success Rate</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##6f42c1;">#totalRegistrations#</h3>
<p style="margin: 5px 0 0 0;">Total Registrations</p>
</div>
</div>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 20px; margin-top: 20px;">
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##28a745;">#NumberFormat(emailSuccessRate, "0")#%</h3>
<p style="margin: 5px 0 0 0;">Valid Emails</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##17a2b8;">#NumberFormat(phoneSuccessRate, "0")#%</h3>
<p style="margin: 5px 0 0 0;">Valid Phone Numbers</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##fd7e14;">#NumberFormat(passwordSuccessRate, "0")#%</h3>
<p style="margin: 5px 0 0 0;">Strong Passwords</p>
</div>
</div>
</div>
</cfoutput>
API parameter validation and security
Modern applications expose APIs for mobile apps, third-party integrations, and microservices, requiring robust parameter validation to prevent security vulnerabilities and ensure reliable data processing. Invalid API parameters cause system errors, security breaches, and data corruption. Manual parameter checking is error-prone and inconsistent. API security vulnerabilities cost organizations a lot of money per breach. Use IsValid to validate API request parameters, ensuring data types, formats, and business rules are enforced before processing requests.
<cfscript>
// Sample API requests from various sources
apiRequests = [
{"endpoint": "/api/orders", "userId": "12345", "amount": "299.99", "currency": "USD", "itemCount": "3", "priority": "high", "apiKey": "abc123xyz789", "timestamp": "1698765432"},
{"endpoint": "/api/payments", "userId": "invalid_user", "amount": "not_a_number", "currency": "INVALID", "itemCount": "-5", "priority": "urgent", "apiKey": "invalid", "timestamp": "invalid"},
{"endpoint": "/api/orders", "userId": "67890", "amount": "1500.00", "currency": "EUR", "itemCount": "1", "priority": "normal", "apiKey": "def456uvw901", "timestamp": "1698765500"},
{"endpoint": "/api/refunds", "userId": "11111", "amount": "0.99", "currency": "GBP", "itemCount": "10", "priority": "low", "apiKey": "ghi789rst234", "timestamp": "1698765600"},
{"endpoint": "/api/orders", "userId": "22222", "amount": "5000.00", "currency": "CAD", "itemCount": "25", "priority": "high", "apiKey": "jkl012mno567", "timestamp": "1698765700"}
];
</cfscript>
<cfoutput>
<h2>📊 API Request Validation Results</h2>
<cfloop array="#apiRequests#" index="request">
<cfscript>
// Generate unique request ID
requestId = "REQ" & DateFormat(Now(), "yyyymmdd") & TimeFormat(Now(), "HHmmss") & RandRange(100, 999);
// Validate API parameters using IsValid
userIdValid = IsValid("integer", request.userId) AND Val(request.userId) GT 0;
amountValid = IsValid("numeric", request.amount) AND Val(request.amount) GTE 0;
itemCountValid = IsValid("integer", request.itemCount) AND Val(request.itemCount) GT 0 AND Val(request.itemCount) LE 100;
timestampValid = IsValid("integer", request.timestamp) AND Len(request.timestamp) EQ 10;
// Validate business rules
validCurrencies = "USD,EUR,GBP,CAD,AUD,JPY";
currencyValid = ListFind(validCurrencies, UCase(request.currency)) GT 0;
validPriorities = "low,normal,high,urgent";
priorityValid = ListFind(validPriorities, LCase(request.priority)) GT 0;
validEndpoints = "/api/orders,/api/payments,/api/refunds";
endpointValid = ListFind(validEndpoints, request.endpoint) GT 0;
// API Key validation (basic format check)
apiKeyValid = IsValid("regex", request.apiKey, "^[a-zA-Z0-9]{12}$");
// Calculate security score
securityScore = 100;
parametersPassed = 0;
totalParameters = 8;
if (userIdValid) parametersPassed++; else securityScore -= 15;
if (amountValid) parametersPassed++; else securityScore -= 20;
if (itemCountValid) parametersPassed++; else securityScore -= 10;
if (timestampValid) parametersPassed++; else securityScore -= 10;
if (currencyValid) parametersPassed++; else securityScore -= 10;
if (priorityValid) parametersPassed++; else securityScore -= 5;
if (endpointValid) parametersPassed++; else securityScore -= 15;
if (apiKeyValid) parametersPassed++; else securityScore -= 15;
// Additional security checks
if (amountValid AND Val(request.amount) GT 10000) {
securityScore -= 5; // Large transaction warning
}
if (itemCountValid AND Val(request.itemCount) GT 50) {
securityScore -= 3; // High volume warning
}
// Determine security level
if (securityScore GTE 95) {
securityLevel = "High Security";
securityColor = "##28a745";
requestStatus = "APPROVED";
} else if (securityScore GTE 80) {
securityLevel = "Medium Security";
securityColor = "##17a2b8";
requestStatus = "APPROVED";
} else if (securityScore GTE 60) {
securityLevel = "Low Security";
securityColor = "##ffc107";
requestStatus = "REVIEW REQUIRED";
} else {
securityLevel = "Security Risk";
securityColor = "##dc3545";
requestStatus = "REJECTED";
}
</cfscript>
<div style="background: white; padding: 20px; margin: 15px 0; border-radius: 8px; border-left: 5px solid #securityColor#; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; align-items: start;">
<!-- Request Details -->
<div>
<h3 style="margin-top: 0; color: ##333;">API Request</h3>
<p><strong>Request ID:</strong> #requestId#</p>
<p><strong>Endpoint:</strong> #request.endpoint#</p>
<p><strong>User ID:</strong> #request.userId#</p>
<p><strong>Amount:</strong> $#request.amount# #request.currency#</p>
<p><strong>Items:</strong> #request.itemCount#</p>
<p><strong>Priority:</strong> #request.priority#</p>
</div>
<!-- IsValid Results -->
<div>
<h4 style="margin-top: 0;">✅ Parameter Validation</h4>
<div style="background: ##f8f9fa; padding: 10px; border-radius: 3px; font-family: monospace; font-size: 0.85em;">
<p><strong>User ID:</strong> #userIdValid ? 'Valid ✓' : 'Invalid ✗'#</p>
<p><strong>Amount:</strong> #amountValid ? 'Valid ✓' : 'Invalid ✗'#</p>
<p><strong>Item Count:</strong> #itemCountValid ? 'Valid ✓' : 'Invalid ✗'#</p>
<p><strong>Timestamp:</strong> #timestampValid ? 'Valid ✓' : 'Invalid ✗'#</p>
<p><strong>Currency:</strong> #currencyValid ? 'Valid ✓' : 'Invalid ✗'#</p>
<p><strong>Priority:</strong> #priorityValid ? 'Valid ✓' : 'Invalid ✗'#</p>
<p><strong>Endpoint:</strong> #endpointValid ? 'Valid ✓' : 'Invalid ✗'#</p>
<p><strong>API Key:</strong> #apiKeyValid ? 'Valid ✓' : 'Invalid ✗'#</p>
</div>
</div>
<!-- Security Assessment -->
<div>
<h4 style="margin-top: 0;">🔒 Security Assessment</h4>
<p><strong>Parameters Passed:</strong> #parametersPassed#/#totalParameters#</p>
<p><strong>Security Score:</strong> #securityScore#/100</p>
<p><strong>Security Level:</strong> <span style="color: #securityColor#; font-weight: bold;">#securityLevel#</span></p>
<p><strong>Request Status:</strong> <span style="color: #securityColor#; font-weight: bold;">#requestStatus#</span></p>
</div>
</div>
<!-- Security Progress Bar -->
<div style="margin-top: 15px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px;">
<h5 style="margin: 0;">🛡️ Security Score</h5>
<span style="font-weight: bold; color: #securityColor#;">#securityScore#/100</span>
</div>
<div style="background: ##e9ecef; height: 25px; border-radius: 12px; overflow: hidden; position: relative;">
<div style="background: #securityColor#; height: 100%; width: #securityScore#%; transition: width 0.3s ease;"></div>
<div style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; font-size: 0.9em; text-shadow: 1px 1px 2px rgba(0,0,0,0.7);">
#parametersPassed# of #totalParameters# parameters valid
</div>
</div>
</div>
<!-- Validation Details -->
<div style="background: ##f8f9fa; padding: 15px; border-radius: 5px; margin-top: 15px;">
<h5 style="margin-top: 0;">🔍 Validation Details:</h5>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px;">
<!-- Data Type Validation -->
<div style="background: white; padding: 10px; border-radius: 3px;">
<h6 style="margin-top: 0; color: ##17a2b8;">Data Type Validation</h6>
<p style="margin: 2px 0; color: #userIdValid ? '##28a745' : '##dc3545'#;">
User ID (Integer): #userIdValid ? '✓ Valid positive integer' : '✗ Must be positive integer'#
</p>
<p style="margin: 2px 0; color: #amountValid ? '##28a745' : '##dc3545'#;">
Amount (Numeric): #amountValid ? '✓ Valid positive number' : '✗ Must be positive number'#
</p>
<p style="margin: 2px 0; color: #itemCountValid ? '##28a745' : '##dc3545'#;">
Item Count: #itemCountValid ? '✓ Valid range (1-100)' : '✗ Must be 1-100'#
</p>
<p style="margin: 2px 0; color: #timestampValid ? '##28a745' : '##dc3545'#;">
Timestamp: #timestampValid ? '✓ Valid Unix timestamp' : '✗ Invalid timestamp'#
</p>
</div>
<!-- Business Rule Validation -->
<div style="background: white; padding: 10px; border-radius: 3px;">
<h6 style="margin-top: 0; color: ##28a745;">Business Rules</h6>
<p style="margin: 2px 0; color: #currencyValid ? '##28a745' : '##dc3545'#;">
Currency: #currencyValid ? '✓ Supported currency' : '✗ Unsupported currency'#
</p>
<p style="margin: 2px 0; color: #priorityValid ? '##28a745' : '##dc3545'#;">
Priority: #priorityValid ? '✓ Valid priority level' : '✗ Invalid priority'#
</p>
<p style="margin: 2px 0; color: #endpointValid ? '##28a745' : '##dc3545'#;">
Endpoint: #endpointValid ? '✓ Authorized endpoint' : '✗ Unauthorized endpoint'#
</p>
</div>
<!-- Security Validation -->
<div style="background: white; padding: 10px; border-radius: 3px;">
<h6 style="margin-top: 0; color: ##fd7e14;">Security Checks</h6>
<p style="margin: 2px 0; color: #apiKeyValid ? '##28a745' : '##dc3545'#;">
API Key: #apiKeyValid ? '✓ Valid format' : '✗ Invalid format'#
</p>
<cfif amountValid AND Val(request.amount) GT 10000>
<p style="margin: 2px 0; color: ##ffc107;">⚠ Large transaction detected</p>
</cfif>
<cfif itemCountValid AND Val(request.itemCount) GT 50>
<p style="margin: 2px 0; color: ##ffc107;">⚠ High volume transaction</p>
</cfif>
</div>
</div>
</div>
<!-- API Response Actions -->
<div style="background: rgba(255,255,255,0.8); padding: 12px; border-radius: 5px; margin-top: 15px;">
<strong>📋 API Response Actions:</strong>
<cfif requestStatus EQ "APPROVED">
<br>• ✓ Process request normally
<br>• ✓ Log successful validation
<br>• ✓ Return 200 OK with response data
<cfif securityScore LT 95>
<br>• ⚠ Monitor for unusual patterns
</cfif>
<cfelseif requestStatus EQ "REVIEW REQUIRED">
<br>• ⚠ Flag for manual review
<br>• ⚠ Return 202 Accepted (pending review)
<br>• ⚠ Send notification to security team
<br>• ⚠ Log security concern for analysis
<cfelse>
<br>• ✗ Reject request immediately
<br>• ✗ Return 400 Bad Request with error details
<br>• ✗ Log security violation attempt
<br>• ✗ Consider rate limiting for this source
</cfif>
</div>
</div>
</cfloop>
<h2>📈 API Security Dashboard</h2>
<div style="background: ##f8f9fa; padding: 20px; border-radius: 8px; margin: 15px 0;">
<cfscript>
// Calculate API security statistics
totalRequests = ArrayLen(apiRequests);
approvedRequests = 0;
reviewRequests = 0;
rejectedRequests = 0;
averageSecurityScore = 0;
totalSecurityScore = 0;
highSecurityCount = 0;
mediumSecurityCount = 0;
lowSecurityCount = 0;
riskCount = 0;
for (request in apiRequests) {
local.userIdValid = IsValid("integer", request.userId) AND Val(request.userId) GT 0;
local.amountValid = IsValid("numeric", request.amount) AND Val(request.amount) GTE 0;
local.itemCountValid = IsValid("integer", request.itemCount) AND Val(request.itemCount) GT 0 AND Val(request.itemCount) LE 100;
local.timestampValid = IsValid("integer", request.timestamp) AND Len(request.timestamp) EQ 10;
local.currencyValid = ListFind("USD,EUR,GBP,CAD,AUD,JPY", UCase(request.currency)) GT 0;
local.priorityValid = ListFind("low,normal,high,urgent", LCase(request.priority)) GT 0;
local.endpointValid = ListFind("/api/orders,/api/payments,/api/refunds", request.endpoint) GT 0;
local.apiKeyValid = IsValid("regex", request.apiKey, "^[a-zA-Z0-9]{12}$");
local.score = 100;
if (NOT local.userIdValid) local.score -= 15;
if (NOT local.amountValid) local.score -= 20;
if (NOT local.itemCountValid) local.score -= 10;
if (NOT local.timestampValid) local.score -= 10;
if (NOT local.currencyValid) local.score -= 10;
if (NOT local.priorityValid) local.score -= 5;
if (NOT local.endpointValid) local.score -= 15;
if (NOT local.apiKeyValid) local.score -= 15;
if (local.amountValid AND Val(request.amount) GT 10000) local.score -= 5;
if (local.itemCountValid AND Val(request.itemCount) GT 50) local.score -= 3;
totalSecurityScore += local.score;
if (local.score GTE 95) {
approvedRequests++;
highSecurityCount++;
} else if (local.score GTE 80) {
approvedRequests++;
mediumSecurityCount++;
} else if (local.score GTE 60) {
reviewRequests++;
lowSecurityCount++;
} else {
rejectedRequests++;
riskCount++;
}
}
averageSecurityScore = totalSecurityScore / totalRequests;
approvalRate = (approvedRequests / totalRequests) * 100;
</cfscript>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px;">
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##28a745;">#approvedRequests#</h3>
<p style="margin: 5px 0 0 0;">Approved Requests</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##ffc107;">#reviewRequests#</h3>
<p style="margin: 5px 0 0 0;">Review Required</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##dc3545;">#rejectedRequests#</h3>
<p style="margin: 5px 0 0 0;">Rejected Requests</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##17a2b8;">#NumberFormat(approvalRate, "0.0")#%</h3>
<p style="margin: 5px 0 0 0;">Approval Rate</p>
</div>
</div>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 20px; margin-top: 20px;">
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##28a745;">#highSecurityCount#</h3>
<p style="margin: 5px 0 0 0;">High Security</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##17a2b8;">#mediumSecurityCount#</h3>
<p style="margin: 5px 0 0 0;">Medium Security</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##ffc107;">#lowSecurityCount#</h3>
<p style="margin: 5px 0 0 0;">Low Security</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##dc3545;">#riskCount#</h3>
<p style="margin: 5px 0 0 0;">Security Risks</p>
</div>
</div>
<div style="margin-top: 20px; text-align: center;">
<div style="background: white; padding: 15px; border-radius: 5px;">
<h3 style="margin: 0; color: ##6f42c1;">#NumberFormat(averageSecurityScore, "0.0")#</h3>
<p style="margin: 5px 0 0 0;">Average Security Score</p>
</div>
</div>
</div>
</cfoutput>
Financial data processing and compliance
Financial services, e-commerce platforms, and accounting systems process monetary transactions requiring strict validation of amounts, account numbers, and regulatory compliance data. Invalid financial data causes payment failures, regulatory violations, and accounting discrepancies. Financial errors can result in millions in losses and regulatory fines. Manual validation is inadequate for high-volume transactions. Use IsValid to validate monetary amounts, account numbers, tax IDs, and financial instrument data ensuring accuracy and compliance.
<cfscript>
// Sample customer data requiring validation
customerData = [
{"type": "Email", "value": "john.doe@company.com", "required": true},
{"type": "Email", "value": "jane.smith@invalid-domain", "required": true},
{"type": "Phone", "value": "555-123-4567", "required": true},
{"type": "Phone", "value": "1-800-SUPPORT", "required": false},
{"type": "Account ID", "value": "ACC-2024-001234", "required": true},
{"type": "Reference", "value": "REF##INV-2024-5678", "required": true},
{"type": "SSN", "value": "123-45-6789", "required": true},
{"type": "Credit Card", "value": "4532-1234-5678-9012", "required": false}
];
</cfscript>
<cfoutput>
<h2>📊 Data Validation Results</h2>
<cfloop array="#customerData#" index="dataItem">
<cfscript>
// Validate different data types using Find function
dataValue = dataItem.value;
dataType = dataItem.type;
isValid = false;
validationMessages = [];
errorMessages = [];
// Email validation
if (dataType EQ "Email") {
atPos = Find("@", dataValue);
dotPos = Find(".", dataValue);
if (atPos GT 1 AND dotPos GT atPos AND dotPos LT Len(dataValue)) {
isValid = true;
ArrayAppend(validationMessages, "Valid email structure detected");
// Check for common invalid patterns
if (Find("invalid", dataValue) GT 0) {
isValid = false;
ArrayAppend(errorMessages, "Domain contains 'invalid' keyword");
}
} else {
ArrayAppend(errorMessages, "Missing required @ symbol or domain extension");
}
}
// Phone number validation
else if (dataType EQ "Phone") {
dashPos = Find("-", dataValue);
digitCount = 0;
// Count digits
for (i = 1; i LTE Len(dataValue); i++) {
if (IsNumeric(Mid(dataValue, i, 1))) {
digitCount++;
}
}
if (dashPos GT 0 AND digitCount GTE 10) {
if (Find("555-", dataValue) GT 0 AND digitCount EQ 10) {
isValid = true;
ArrayAppend(validationMessages, "Valid US phone number format");
} else if (Find("1-800", dataValue) GT 0) {
isValid = true;
ArrayAppend(validationMessages, "Valid toll-free number");
} else {
ArrayAppend(errorMessages, "Unrecognized phone format");
}
} else {
ArrayAppend(errorMessages, "Missing hyphens or insufficient digits");
}
}
// Account ID validation
else if (dataType EQ "Account ID") {
accPos = Find("ACC-", dataValue);
if (accPos EQ 1 AND Len(dataValue) GTE 10) {
isValid = true;
ArrayAppend(validationMessages, "Valid account ID format");
} else {
ArrayAppend(errorMessages, "Must start with ACC- and be at least 10 characters");
}
}
// Reference ID validation
else if (dataType EQ "Reference") {
refPos = Find("REF", dataValue);
hashPos = Find("##", dataValue);
if (refPos EQ 1 AND hashPos EQ 4) {
isValid = true;
ArrayAppend(validationMessages, "Valid reference ID format");
} else {
ArrayAppend(errorMessages, "Must start with REF## pattern");
}
}
// SSN validation
else if (dataType EQ "SSN") {
firstDash = Find("-", dataValue);
secondDash = Find("-", dataValue, firstDash + 1);
if (firstDash EQ 4 AND secondDash EQ 7 AND Len(dataValue) EQ 11) {
isValid = true;
ArrayAppend(validationMessages, "Valid SSN format (XXX-XX-XXXX)");
} else {
ArrayAppend(errorMessages, "Must follow XXX-XX-XXXX format");
}
}
// Credit Card validation
else if (dataType EQ "Credit Card") {
dashCount = 0;
dashPos = 1;
while (dashPos GT 0) {
dashPos = Find("-", dataValue, dashPos + 1);
if (dashPos GT 0) dashCount++;
}
if (dashCount EQ 3 AND Len(dataValue) EQ 19) {
isValid = true;
ArrayAppend(validationMessages, "Valid credit card format (XXXX-XXXX-XXXX-XXXX)");
} else {
ArrayAppend(errorMessages, "Must follow XXXX-XXXX-XXXX-XXXX format");
}
}
// Determine validation status color
statusColor = isValid ? "##28a745" : "##dc3545";
typeColor = "##17a2b8";
</cfscript>
<div style="background: white; padding: 20px; margin: 15px 0; border-radius: 8px; border-left: 5px solid #statusColor#; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; align-items: start;">
<!-- Data Item Info -->
<div>
<h3 style="margin-top: 0; color: ##333;">Data Validation</h3>
<p><strong>Type:</strong> <span style="color: #typeColor#; font-weight: bold;">#dataType#</span></p>
<p><strong>Value:</strong> #dataValue#</p>
<p><strong>Required:</strong> #dataItem.required ? 'Yes' : 'No'#</p>
<p><strong>Status:</strong> <span style="color: #statusColor#; font-weight: bold;">#isValid ? 'Valid' : 'Invalid'#</span></p>
</div>
<!-- Find Function Analysis -->
<div>
<h4 style="margin-top: 0;">🔍 Pattern Detection</h4>
<div style="background: ##f8f9fa; padding: 10px; border-radius: 3px; font-family: monospace; font-size: 0.85em;">
<cfif dataType EQ "Email">
<p><strong>@ symbol:</strong> position #Find("@", dataValue)#</p>
<p><strong>. symbol:</strong> position #Find(".", dataValue)#</p>
<cfelseif dataType EQ "Phone">
<p><strong>- symbol:</strong> position #Find("-", dataValue)#</p>
<cfif Find("1-800", dataValue) GT 0>
<p><strong>1-800:</strong> position #Find("1-800", dataValue)#</p>
</cfif>
<cfelseif dataType EQ "Account ID">
<p><strong>ACC- prefix:</strong> position #Find("ACC-", dataValue)#</p>
<cfelseif dataType EQ "Reference">
<p><strong>REF prefix:</strong> position #Find("REF", dataValue)#</p>
<p><strong>## symbol:</strong> position #Find("##", dataValue)#</p>
<cfelseif dataType EQ "SSN">
<p><strong>First -:</strong> position #Find("-", dataValue)#</p>
<p><strong>Second -:</strong> position #Find("-", dataValue, 5)#</p>
<cfelseif dataType EQ "Credit Card">
<p><strong>Dash count:</strong> #Len(dataValue) - Len(Replace(dataValue, "-", "", "ALL"))#</p>
</cfif>
</div>
</div>
<!-- Validation Results -->
<div>
<h4 style="margin-top: 0;">✅ Validation Details</h4>
<cfif ArrayLen(validationMessages) GT 0>
<div style="color: ##28a745;">
<cfloop array="#validationMessages#" index="message">
<p style="margin: 2px 0; font-size: 0.9em;">✓ #message#</p>
</cfloop>
</div>
</cfif>
<cfif ArrayLen(errorMessages) GT 0>
<div style="color: ##dc3545;">
<cfloop array="#errorMessages#" index="error">
<p style="margin: 2px 0; font-size: 0.9em;">✗ #error#</p>
</cfloop>
</div>
</cfif>
</div>
</div>
<!-- Compliance and Security Notes -->
<cfif dataType EQ "SSN" OR dataType EQ "Credit Card">
<div style="background: ##fff3cd; padding: 12px; border-radius: 5px; margin-top: 15px;">
<h6 style="margin-top: 0;">🔒 Security & Compliance Notes:</h6>
<cfif dataType EQ "SSN">
<p>• SSN data requires PII protection and GDPR compliance</p>
<p>• Encrypt during storage and transmission</p>
<p>• Log all access for audit purposes</p>
<cfelseif dataType EQ "Credit Card">
<p>• Credit card data requires PCI DSS compliance</p>
<p>• Never store full card numbers in plain text</p>
<p>• Use tokenization for payment processing</p>
</cfif>
</div>
</cfif>
</div>
</cfloop>
<h2>📈 Data Quality Dashboard</h2>
<div style="background: ##f8f9fa; padding: 20px; border-radius: 8px; margin: 15px 0;">
<cfscript>
// Calculate validation statistics
totalRecords = ArrayLen(customerData);
validRecords = 0;
invalidRecords = 0;
requiredRecords = 0;
validRequiredRecords = 0;
emailCount = 0;
phoneCount = 0;
accountCount = 0;
piiCount = 0;
for (dataItem in customerData) {
// Re-validate for statistics
local.isValid = false;
dataValue = dataItem.value;
dataType = dataItem.type;
if (dataType EQ "Email") {
emailCount++;
local.atPos = Find("@", dataValue);
local.dotPos = Find(".", dataValue);
if (local.atPos GT 1 AND local.dotPos GT local.atPos AND Find("invalid", dataValue) EQ 0) {
local.isValid = true;
}
} else if (dataType EQ "Phone") {
phoneCount++;
if (Find("-", dataValue) GT 0 AND (Find("555-", dataValue) GT 0 OR Find("1-800", dataValue) GT 0)) {
local.isValid = true;
}
} else if (dataType EQ "Account ID") {
accountCount++;
if (Find("ACC-", dataValue) EQ 1) {
local.isValid = true;
}
} else if (dataType EQ "Reference") {
if (Find("REF", dataValue) EQ 1 AND Find("##", dataValue) EQ 4) {
local.isValid = true;
}
} else if (dataType EQ "SSN" OR dataType EQ "Credit Card") {
piiCount++;
if (dataType EQ "SSN" AND Find("-", dataValue) EQ 4) {
local.isValid = true;
} else if (dataType EQ "Credit Card" AND Len(dataValue) EQ 19) {
local.isValid = true;
}
}
if (local.isValid) validRecords++;
else invalidRecords++;
if (dataItem.required) {
requiredRecords++;
if (local.isValid) validRequiredRecords++;
}
}
validationRate = (validRecords / totalRecords) * 100;
requiredValidationRate = requiredRecords GT 0 ? (validRequiredRecords / requiredRecords) * 100 : 0;
</cfscript>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px;">
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##28a745;">#validRecords#</h3>
<p style="margin: 5px 0 0 0;">Valid Records</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##dc3545;">#invalidRecords#</h3>
<p style="margin: 5px 0 0 0;">Invalid Records</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##17a2b8;">#NumberFormat(validationRate, "0.0")#%</h3>
<p style="margin: 5px 0 0 0;">Overall Validation Rate</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##fd7e14;">#NumberFormat(requiredValidationRate, "0.0")#%</h3>
<p style="margin: 5px 0 0 0;">Required Fields Valid</p>
</div>
</div>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 20px; margin-top: 20px;">
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##6f42c1;">#emailCount#</h3>
<p style="margin: 5px 0 0 0;">Email Addresses</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##28a745;">#phoneCount#</h3>
<p style="margin: 5px 0 0 0;">Phone Numbers</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##17a2b8;">#accountCount#</h3>
<p style="margin: 5px 0 0 0;">Account IDs</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##dc3545;">#piiCount#</h3>
<p style="margin: 5px 0 0 0;">PII Records</p>
</div>
</div>
</div>
</cfoutput>
