Reputation: 4587
I have a struct that I check for the existence of a key. I then need to test whether the value for that key is a string. I didn't spot anything in the Adobe CF docs like an isString()
function (similar to isNumeric()
).
Is there a good way other than using the seemingly broader isSimpleValue()
?
Upvotes: 9
Views: 5130
Reputation: 1969
Note that this works in CF 2018 only
if(getMetadata(<value>).getName() == 'java.lang.String') {
//<value> is String
}
It will be a good idea to create an user defined function isString
returning boolean
based on above condition
Upvotes: 4
Reputation: 11732
The good way will depend on your context. ColdFusion does not use explicit types for variables.
'123456' can be a string and '2016-05-18 13:08:00' can be a string too, you have a good question but testing the value depends on what you're trying to do and what happens next with it.
Upvotes: 7