Skip to content

Format function should support decimal#327

Open
wapgear wants to merge 1 commit into
s-yadav:masterfrom
wapgear:format-function-v2
Open

Format function should support decimal#327
wapgear wants to merge 1 commit into
s-yadav:masterfrom
wapgear:format-function-v2

Conversation

@wapgear

@wapgear wapgear commented Jul 25, 2019

Copy link
Copy Markdown

On our project we had a problem with your library - for some reason with typeof props.format === "function" library worked only with integers, with this PR it'll also support decimal values.

@wapgear

wapgear commented Aug 5, 2019

Copy link
Copy Markdown
Author

@s-yadav hey sorry if I disturb you but what do you think about this?

Comment thread src/number_format.js
val = removeFormatting(val);
} else {
val = (val.match(/\d/g) || []).join('')
val = this.removePrefixAndSuffix(val);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not handle other formatting props, when format function is provided.

@s-yadav

s-yadav commented Aug 5, 2019

Copy link
Copy Markdown
Owner

I don't think we should handle prefix / suffix, and other formatting props if format prop is defined as function. If we do so that will lead to lots of corner case which is not meant to be solved by here.

We can look for some regex instead which allows all the valid character of a number and let the format method handle the cases.

Also, If a user needs to have more control on removing formatting he can pass removeFormat method.
I guess we can work on improving the documentation of format (as function) and removeFormatting method, so people are aware of it while using custom format function. What do you say?

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.

2 participants