Skip to content

Update number.ts#15

Open
drewmcfaul wants to merge 1 commit intocjdell:masterfrom
drewmcfaul:patch-1
Open

Update number.ts#15
drewmcfaul wants to merge 1 commit intocjdell:masterfrom
drewmcfaul:patch-1

Conversation

@drewmcfaul
Copy link

The allowNumeric option allows numerical strings to be parsed, but there is no case to handle strings with mixed content.

Consider how these strings are currently parsed:
'123' -> 123
'abc123' -> Error
'123abc' -> 123

In the third example the string is parsed as a number. This behaviour is okay but it would be good to also have the option to be strict about the full numeracy of the string.

Enabling the fullNumberOnlyOption in conjunction with allowNumeric changes the mapping to this
'19' -> 19
'a19' -> Error
'19a' -> Error

Code untested.

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

  • What is the current behavior? (You can also link to an open issue here)

  • What is the new behavior (if this is a feature change)?

  • Other information:

The allowNumeric option allows numerical strings to be parsed, but there is no case to handle strings with mixed content. 

Consider how these strings are currently parsed:
'123' -> 123
'abc123' -> Error
'123abc' -> 123

In the third example the string is parsed as a number. This behaviour is okay but it would be good to also have the option to be strict about the full numeracy of the string.

Enabling the fullNumberOnlyOption in conjunction with allowNumeric changes the mapping to this
'19' -> 19
'a19' -> Error
'19a' -> Error

Code untested.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant