-
Type: New Feature
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: BSON
Use Case
As a BSON and driver user
I want to ensure strings that represent longs only contain valid digits and no overflows
So that int64s are constructed from proper digit sequences.
User Impact
- New opt-in feature API
Dependencies
- None
Unknowns
None.
Acceptance Criteria
Implementation Requirements
- Add a new static method to the Long class fromStringStrict that throws when the input contains invalid characters, whitespace or overflows
- Long.fromStringStrict(str: string, unsigned?: boolean, radix?: number): Long
- The method must support radixes from 2 through 36 inclusive
- radix is an optional parameter that must default to 10
- The method will return the Long representation if it is valid and throw an error if it is not.
Testing Requirements
- Test valid and invalid inputs
Documentation Requirements
- Put API docs on {{Long.fromStringStrict }}with example usage
Follow Up Requirements
- In v7 (next BSON major) NODE-5638 Long.fromString Strict will be called inside Long.fromString