ColdFusion 10: Is “5a” numeric?

I was sad to find that two bugs I logged for Adobe ColdFusion haven’t been resolved in the 10 Beta release.  What’s more they’re been marked closed and deferred due to “NotEnoughTime”, but I guess Adobe must be pretty busy as I didn’t think these would be that involved to fix.

When is a valid numeric, not a number?

Answer: When it’s a date / time string.  Currently IsValid(“Numeric”) doesn’t behave like IsNumeric() and accepts date / time string as valid.  In the following example IsNumeric will return false for all the values but IsValid(“Numeric”) returns true instead.

<cfscript>
  values = ['1a','2p','3am','4pm','23pm','01:13:24','23:45:12am',
           '01/01/2020','2010-09-08 07:06:05'];
  iEnd = ArrayLen(values);
  for (i = 1; i <= iEnd; i++) {
    WriteOutput('IsNumeric("' & values[i] & '") = ' & IsNumeric(values[i]) & '<br />');
    WriteOutput('IsValid("numeric", "' & values[i] & '") = ' & IsValid('numeric', values[i]) & '<br />');
  }
</cfscript>

You’ll find this registered with the Adobe Bugbase with ID 3042477.

Is this the right room for an argument?

Only if you want to argue over an argument type of “Numeric” accepting date / time strings.  Yup, just like the previous bug but this time it’s the “type” attribute for functions / component methods.

<cfscript>
  string function NumericOnlyPlease(required numeric num) {
    return "Accepted the value: " & arguments.num & " as an argument type of 'Numeric'.";
  }
  values = ['1a','2p','3am','4pm','23pm','01:13:24','23:45:12am',
           '01/01/2020','2010-09-08 07:06:05', 'zzz'];
  iEnd = ArrayLen(values);
  for (i = 1; i <= iEnd; i++) {
    try {
      WriteOutput('numericOnlyPlease("' & values[i] & '") = ' & numericOnlyPlease(values[i]) & '<br>');
    } catch(any e) {
      WriteOutput('numericOnlyPlease("' & values[i] & '") = <strong>ERROR</strong>: #HtmlEditFormat(e.message)#' & '<br>');
    }
  }
</cfscript>

With the above code, all the values in the array will be accepted apart from the last one which correctly throws an error since “zzz” is obviously not numeric.

Again this bug has been logged with Adobe under ID 3042477.

About these ads

2 thoughts on “ColdFusion 10: Is “5a” numeric?

  1. James Moberg

    Charlie Arehart has posted a list of NEW ColdFusion 10 features. (Currently at 215 as of this post.)

    I wish someone (at Adobe or one of their evangelists) would invest time reviewing all of the reported ColdFusion 9 bugs and identify anything that has been fixed in ColdFusion 10 and works as promoted/documented. I’ve personally encountered issues and have done my part in reporting them to Adobe, but have have yet to see any improvement:

    - carriage returns in CFMAIL are occasionally ignored
    - dataformat for dates in cfspreadsheet is non-functional (time dropped & not saved as a valid date object)
    - CFDocument creates bloated PDFs (that I shrink by ~85% using GhostScript)
    - 2bit GIF images are not rendered properly in PDFs
    - At least 297 more at https://bugbase.adobe.com/

    While I am interested in some of the new features, I can’t really convincingly sell CF10 to any of my clients if there’s no improvement regarding existing CF9 problems. I already have many of the new CF10 functions in the form of UDFs. I also use 3rd party image & charting libraries due to better performance & more features (80% faster + smaller files).

    If anyone is able to find a CF9-to-CF10 list of bugs that have been fixed, please post it here. Thanks.

    Reply
    1. misterdai Post author

      It might be worth digging up those bugs you’ve logged. As I find it strange that the two I’ve mentioned in this post have both been marked as closed. I would have thought that no bug that is still present should ever have the entry marked as closed, otherwise it won’t get noticed and fixed. I’d rather they have a target version for the fix, so at least it might stand a chance for whatever followed CF10.

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s