Search code examples
coldfusion

Test whether a value is a string in Coldfusion


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()?


Solution

  • 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.