tracker issue : CF-3516706

select a category, or use search below
(searches all categories and all time range)


| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 03/09/2013

Components: Language

Versions: 10.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: Final /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Platforms All

Vote Count: 3

Listed in the version 2016.0.0.297996 Issues Fixed doc
Verification notes: verified_fixed on August 26, 2019 using build 2016.0.01.298513
CFML has yesNoFormat() which is lovely, but a bit arcane. Most people think true/false 1/0 for booleans I think (except CFML, which often returns yes/no from its built-in functions for some reason).

To work around this quirk of CFML, it'd be handly to have a booleanFormat() function (analogous to numberFormat() for numbers) which works along these lines:

booleanFormat(booleanValue); // returns true or false as appropriate
booleanFormat(booleanValue, "TRUEFALSE"); // returns true or false as appropriate
booleanFormat(booleanValue, "YESNO"); // returns "yes" or "no" as appropriate (or maybe a locale specific version of same? Dunno)
booleanFormat(booleanValue, "ONEZERO"); // returns 1 or 0 as appropriate

I'm not married to the approach I've suggested the mask takes, but something along those lines.

This would not be the most useful function ever, but I have had a number of occasions when interchanging data with other systems wherein I've needed more control over boolean values like this.


----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3516706

External Customer Info:
External Company:  
External Customer Name: Adam Cameron.
External Customer Email:  
External Test Config: My Hardware and Environment details:



Would be useful, especially if respected in json
Vote by External U.
16071 | September 30, 2015 10:37:11 PM GMT
Good idea, but honestly booleans should always be returned as true/false. If you want yes/no, use yesNoFormat()! Since that'll never happen (because backwards compat), I'd vote to also have the double-bang return a true/false format. Like !!"yes" would return the formatted boolean: true. Lucee way: ACF way:
Comment by External U.
16064 | October 01, 2015 01:08:01 PM GMT
This is a string formatting function, Abram. The result is not intended to be used as a boolean, but for various view situations when various presentations of a boolean might be required. Think dateFormat().
Comment by External U.
16065 | October 01, 2015 01:10:06 PM GMT
(sorry, when I say "string formatting", I mean "takes some non-string object - in this case a boolean - and returns a formatted string). But definitely intended as a "last mile" function, not a data-processing one.
Comment by External U.
16066 | October 01, 2015 01:11:05 PM GMT
That's what I was driving at, the formatting should always have been "true/false" not "yes/no". I like the idea of having the booleanFormat() function, but that's a whole lotta typing. I'm just suggesting that in addition to this function, using the !! convention would also output the formatted true/false.
Comment by External U.
16067 | October 01, 2015 01:22:13 PM GMT
+1. . . . . . . . . . . . . . . . . . . .
Vote by External U.
16072 | October 01, 2015 02:20:53 PM GMT
Abram/Adam - are either of you of a bug/ER to make true/false the default boolean display format? I'd vote the heck out of that.
Comment by External U.
16068 | October 01, 2015 09:26:57 PM GMT
I'm unaware of one. You might want to raise one...
Comment by External U.
16069 | October 02, 2015 05:52:14 AM GMT
+1 - would be useful ...........
Vote by External U.
16073 | October 03, 2015 08:02:00 PM GMT
yesNoFormat() returns title case "Yes" or "No". This is handy as it's simple to get the other 2 most popular cases (lower/upper case) by using .lCase() and .uCase(). booleanFormat() and yesNoFormat() are very much related. It would be nice if booleanFormat() can return title case using this precedent in CF. Thanks!, -Aaron
Comment by External U.
16070 | December 20, 2015 06:21:27 AM GMT
Hi Adobe, I've verified this is fixed in CF2016 Update 1 (build 2016.0.01.298513), well except for title case =P. Thanks!, -Aaron
Comment by Aaron N.
31218 | August 26, 2019 05:33:08 AM GMT