Positive thinking



  • I work for a company that has a large IT base as a storeman.
    Looking at some of the javascript validation for their main database application, I came across this:

    [code]
    function isaPosNum(s)

    {

    return (parseInt(s) < 99999999999)

    }

    ...
    [/code]



  • You should put this in sidebar.



  • @blakeyrat said:

    You should put this in sidebar.

    Let's use the magical morbiusdhromwiltersed to move it to the sidebar for them!


  • Discourse touched me in a no-no place

    I'm wondering if it's deserving of a place anywhere on here, since it's clearly a ID-10-T/PEBCAK bug, rather than a wtf, since even the minimalist of testing would show it to be clearly incorrect.


  • Considered Harmful

    My guess? The original business rule validated that the number was positive, then the validation requirement changed, and rather than refactor and rename the method they just made it do something different.



  • Right-click, select "Rename Fun--" oh wait let me guess, you're not using an IDE with refactoring tools.



  •  @jedda said:

    I work for a company that has a large IT base as a storeman. Looking at some of the javascript validation for their main database application, I came across this:

    <font face="Lucida Console" size="2">function isaPosNum(s)
    {
    return (parseInt(s) < 99999999999)
    }
    ... </font>

    Necro...

    This really intruiged me, and I found that if the input is in a known and expected format, the function works just fine.  The known format is a string where positives are "1", "10","100.50", and negatives are in the format "(1)", "(10)", "(100.50)".  However ".3" returns false unless padded with a leading zero, "0.3".

    Since it is JS, it's probably working with formatted fields displayed on a page.  And if the users are Exceliots, then they would want to see numbers formatted like Excel. 


Log in to reply