Test whether a value is a string in Coldfusion

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.


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

Tags:

Coldfusion