• Type: Icon: Sub-task Sub-task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • bson-6.7.0
    • Affects Version/s: None
    • Component/s: None
    • 0
    • Not Needed
    • Hide

      Create a copy of the Kickoff Template with the issue key (NODE-XXX) in the filename and share a link to the new doc via this field.

      Show
      Create a copy of the Kickoff Template with the issue key (NODE-XXX) in the filename and share a link to the new doc via this field.
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Currently, users can pass in invalid input into Double constructor, and the inputs will be coerced to a value regardless of if the input is valid.

      This subtask will create a Double.fromString helper that will validate input for these classes and throw on inputs that are not representable as a Double.

      In V7, we will add these helpers to the Double constructor when a string input is passed in, so the numeric conversion will only happen after validation.

       Use Case

      As a... BSON Double Class user
      I want... my string inputs to throw when they will lose precision
      So that... the value stored in the Double instance is the desired value

      Acceptance Criteria

      Implementation Requirements

      • General Approach
        • Remove leading zeros in comparison
        • Don't allow whitespace (decimal 128 precedent)
        • Only allow decimal input
      •  Error Cases
        • Don't allow non-decimal inputs (if string contains, a 'x' 'c' 'b')
        • Empty string
        • Number(value) === NaN but value is not 'NaN'
          • (something other than a NaN is coerced to a NaN)
        • !Number.isFinite(+value) but value is not 'Infinity' or '-Infinity'
      • If not error case, return Number(value)

      Testing Requirements

      • Double Cases
        • Success Cases:
          • 'NaN', 'Infinity', '-Infinity', 0, -0
          •  Fraction
          • Basic test case for decimal
          • whitespace leading, trailing
          • leading zeros
        • Error Cases:
          • 'foo'
          •  ex: '2e308' (coerced to Infinity by Number(), but is not actually infinity'
          • Non-decimal inputs

      Documentation Requirements

      • add API docs for Double.fromString

      Follow Up Requirements

      • file v7 ticket (in subtasks)

            Assignee:
            aditi.khare@mongodb.com Aditi Khare
            Reporter:
            aditi.khare@mongodb.com Aditi Khare
            Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: