wnumb icon indicating copy to clipboard operation
wnumb copied to clipboard

Strict formatting

Open Crusader2010 opened this issue 3 years ago • 1 comments

Hi,

I found your library to be extremely useful, except for one case that doesn't really have a solution without doing some hacky stuff that i hate. I need a way to allow strict matching of numbers (when other characters are present

var doubleFormat = wNumb({ mark: ',', thousand: '.', decimals: 2 }); console.log(doubleFormat.from('thisStillReturnsAValidNumber1.231,1231'));

I would like an option such that the previous code returns the text itself, not just the number from it, since it cannot be directly converted to a number.

Crusader2010 avatar Jul 10 '20 08:07 Crusader2010

I'm not entirely sure what you'd like to do here, but if I understand it correctly you could implement this by using the decoder option (which applies before all other formatting), and invalidate the number there.

leongersen avatar Jul 17 '20 07:07 leongersen